cachefiles.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. /* CacheFiles tracepoints
  2. *
  3. * Copyright (C) 2016 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #undef TRACE_SYSTEM
  12. #define TRACE_SYSTEM cachefiles
  13. #if !defined(_TRACE_CACHEFILES_H) || defined(TRACE_HEADER_MULTI_READ)
  14. #define _TRACE_CACHEFILES_H
  15. #include <linux/tracepoint.h>
  16. /*
  17. * Define enums for tracing information.
  18. */
  19. #ifndef __CACHEFILES_DECLARE_TRACE_ENUMS_ONCE_ONLY
  20. #define __CACHEFILES_DECLARE_TRACE_ENUMS_ONCE_ONLY
  21. enum cachefiles_obj_ref_trace {
  22. cachefiles_obj_put_wait_retry = fscache_obj_ref__nr_traces,
  23. cachefiles_obj_put_wait_timeo,
  24. cachefiles_obj_ref__nr_traces
  25. };
  26. #endif
  27. /*
  28. * Define enum -> string mappings for display.
  29. */
  30. #define cachefiles_obj_kill_traces \
  31. EM(FSCACHE_OBJECT_IS_STALE, "stale") \
  32. EM(FSCACHE_OBJECT_NO_SPACE, "no_space") \
  33. EM(FSCACHE_OBJECT_WAS_RETIRED, "was_retired") \
  34. E_(FSCACHE_OBJECT_WAS_CULLED, "was_culled")
  35. #define cachefiles_obj_ref_traces \
  36. EM(fscache_obj_get_add_to_deps, "GET add_to_deps") \
  37. EM(fscache_obj_get_queue, "GET queue") \
  38. EM(fscache_obj_put_alloc_fail, "PUT alloc_fail") \
  39. EM(fscache_obj_put_attach_fail, "PUT attach_fail") \
  40. EM(fscache_obj_put_drop_obj, "PUT drop_obj") \
  41. EM(fscache_obj_put_enq_dep, "PUT enq_dep") \
  42. EM(fscache_obj_put_queue, "PUT queue") \
  43. EM(fscache_obj_put_work, "PUT work") \
  44. EM(cachefiles_obj_put_wait_retry, "PUT wait_retry") \
  45. E_(cachefiles_obj_put_wait_timeo, "PUT wait_timeo")
  46. /*
  47. * Export enum symbols via userspace.
  48. */
  49. #undef EM
  50. #undef E_
  51. #define EM(a, b) TRACE_DEFINE_ENUM(a);
  52. #define E_(a, b) TRACE_DEFINE_ENUM(a);
  53. cachefiles_obj_kill_traces;
  54. cachefiles_obj_ref_traces;
  55. /*
  56. * Now redefine the EM() and E_() macros to map the enums to the strings that
  57. * will be printed in the output.
  58. */
  59. #undef EM
  60. #undef E_
  61. #define EM(a, b) { a, b },
  62. #define E_(a, b) { a, b }
  63. TRACE_EVENT(cachefiles_ref,
  64. TP_PROTO(struct cachefiles_object *obj,
  65. struct fscache_cookie *cookie,
  66. enum cachefiles_obj_ref_trace why,
  67. int usage),
  68. TP_ARGS(obj, cookie, why, usage),
  69. /* Note that obj may be NULL */
  70. TP_STRUCT__entry(
  71. __field(struct cachefiles_object *, obj )
  72. __field(struct fscache_cookie *, cookie )
  73. __field(enum cachefiles_obj_ref_trace, why )
  74. __field(int, usage )
  75. ),
  76. TP_fast_assign(
  77. __entry->obj = obj;
  78. __entry->cookie = cookie;
  79. __entry->usage = usage;
  80. __entry->why = why;
  81. ),
  82. TP_printk("c=%p o=%p u=%d %s",
  83. __entry->cookie, __entry->obj, __entry->usage,
  84. __print_symbolic(__entry->why, cachefiles_obj_ref_traces))
  85. );
  86. TRACE_EVENT(cachefiles_lookup,
  87. TP_PROTO(struct cachefiles_object *obj,
  88. struct dentry *de,
  89. struct inode *inode),
  90. TP_ARGS(obj, de, inode),
  91. TP_STRUCT__entry(
  92. __field(struct cachefiles_object *, obj )
  93. __field(struct dentry *, de )
  94. __field(struct inode *, inode )
  95. ),
  96. TP_fast_assign(
  97. __entry->obj = obj;
  98. __entry->de = de;
  99. __entry->inode = inode;
  100. ),
  101. TP_printk("o=%p d=%p i=%p",
  102. __entry->obj, __entry->de, __entry->inode)
  103. );
  104. TRACE_EVENT(cachefiles_mkdir,
  105. TP_PROTO(struct cachefiles_object *obj,
  106. struct dentry *de, int ret),
  107. TP_ARGS(obj, de, ret),
  108. TP_STRUCT__entry(
  109. __field(struct cachefiles_object *, obj )
  110. __field(struct dentry *, de )
  111. __field(int, ret )
  112. ),
  113. TP_fast_assign(
  114. __entry->obj = obj;
  115. __entry->de = de;
  116. __entry->ret = ret;
  117. ),
  118. TP_printk("o=%p d=%p r=%u",
  119. __entry->obj, __entry->de, __entry->ret)
  120. );
  121. TRACE_EVENT(cachefiles_create,
  122. TP_PROTO(struct cachefiles_object *obj,
  123. struct dentry *de, int ret),
  124. TP_ARGS(obj, de, ret),
  125. TP_STRUCT__entry(
  126. __field(struct cachefiles_object *, obj )
  127. __field(struct dentry *, de )
  128. __field(int, ret )
  129. ),
  130. TP_fast_assign(
  131. __entry->obj = obj;
  132. __entry->de = de;
  133. __entry->ret = ret;
  134. ),
  135. TP_printk("o=%p d=%p r=%u",
  136. __entry->obj, __entry->de, __entry->ret)
  137. );
  138. TRACE_EVENT(cachefiles_unlink,
  139. TP_PROTO(struct cachefiles_object *obj,
  140. struct dentry *de,
  141. enum fscache_why_object_killed why),
  142. TP_ARGS(obj, de, why),
  143. /* Note that obj may be NULL */
  144. TP_STRUCT__entry(
  145. __field(struct cachefiles_object *, obj )
  146. __field(struct dentry *, de )
  147. __field(enum fscache_why_object_killed, why )
  148. ),
  149. TP_fast_assign(
  150. __entry->obj = obj;
  151. __entry->de = de;
  152. __entry->why = why;
  153. ),
  154. TP_printk("o=%p d=%p w=%s",
  155. __entry->obj, __entry->de,
  156. __print_symbolic(__entry->why, cachefiles_obj_kill_traces))
  157. );
  158. TRACE_EVENT(cachefiles_rename,
  159. TP_PROTO(struct cachefiles_object *obj,
  160. struct dentry *de,
  161. struct dentry *to,
  162. enum fscache_why_object_killed why),
  163. TP_ARGS(obj, de, to, why),
  164. /* Note that obj may be NULL */
  165. TP_STRUCT__entry(
  166. __field(struct cachefiles_object *, obj )
  167. __field(struct dentry *, de )
  168. __field(struct dentry *, to )
  169. __field(enum fscache_why_object_killed, why )
  170. ),
  171. TP_fast_assign(
  172. __entry->obj = obj;
  173. __entry->de = de;
  174. __entry->to = to;
  175. __entry->why = why;
  176. ),
  177. TP_printk("o=%p d=%p t=%p w=%s",
  178. __entry->obj, __entry->de, __entry->to,
  179. __print_symbolic(__entry->why, cachefiles_obj_kill_traces))
  180. );
  181. TRACE_EVENT(cachefiles_mark_active,
  182. TP_PROTO(struct cachefiles_object *obj,
  183. struct dentry *de),
  184. TP_ARGS(obj, de),
  185. /* Note that obj may be NULL */
  186. TP_STRUCT__entry(
  187. __field(struct cachefiles_object *, obj )
  188. __field(struct dentry *, de )
  189. ),
  190. TP_fast_assign(
  191. __entry->obj = obj;
  192. __entry->de = de;
  193. ),
  194. TP_printk("o=%p d=%p",
  195. __entry->obj, __entry->de)
  196. );
  197. TRACE_EVENT(cachefiles_wait_active,
  198. TP_PROTO(struct cachefiles_object *obj,
  199. struct dentry *de,
  200. struct cachefiles_object *xobj),
  201. TP_ARGS(obj, de, xobj),
  202. /* Note that obj may be NULL */
  203. TP_STRUCT__entry(
  204. __field(struct cachefiles_object *, obj )
  205. __field(struct dentry *, de )
  206. __field(struct cachefiles_object *, xobj )
  207. __field(u16, flags )
  208. __field(u16, fsc_flags )
  209. ),
  210. TP_fast_assign(
  211. __entry->obj = obj;
  212. __entry->de = de;
  213. __entry->xobj = xobj;
  214. __entry->flags = xobj->flags;
  215. __entry->fsc_flags = xobj->fscache.flags;
  216. ),
  217. TP_printk("o=%p d=%p wo=%p wf=%x wff=%x",
  218. __entry->obj, __entry->de, __entry->xobj,
  219. __entry->flags, __entry->fsc_flags)
  220. );
  221. TRACE_EVENT(cachefiles_mark_inactive,
  222. TP_PROTO(struct cachefiles_object *obj,
  223. struct dentry *de,
  224. struct inode *inode),
  225. TP_ARGS(obj, de, inode),
  226. /* Note that obj may be NULL */
  227. TP_STRUCT__entry(
  228. __field(struct cachefiles_object *, obj )
  229. __field(struct dentry *, de )
  230. __field(struct inode *, inode )
  231. ),
  232. TP_fast_assign(
  233. __entry->obj = obj;
  234. __entry->de = de;
  235. __entry->inode = inode;
  236. ),
  237. TP_printk("o=%p d=%p i=%p",
  238. __entry->obj, __entry->de, __entry->inode)
  239. );
  240. TRACE_EVENT(cachefiles_mark_buried,
  241. TP_PROTO(struct cachefiles_object *obj,
  242. struct dentry *de,
  243. enum fscache_why_object_killed why),
  244. TP_ARGS(obj, de, why),
  245. /* Note that obj may be NULL */
  246. TP_STRUCT__entry(
  247. __field(struct cachefiles_object *, obj )
  248. __field(struct dentry *, de )
  249. __field(enum fscache_why_object_killed, why )
  250. ),
  251. TP_fast_assign(
  252. __entry->obj = obj;
  253. __entry->de = de;
  254. __entry->why = why;
  255. ),
  256. TP_printk("o=%p d=%p w=%s",
  257. __entry->obj, __entry->de,
  258. __print_symbolic(__entry->why, cachefiles_obj_kill_traces))
  259. );
  260. #endif /* _TRACE_CACHEFILES_H */
  261. /* This part must be outside protection */
  262. #include <trace/define_trace.h>