History

cachefiles: Implement object lifecycle funcs

Implement allocate, get, see and put functions for the cachefiles_object struct. The members of the struct we're going to need are also added. Additionally, implement a lifecycle tracepoint.

David Howells committed 4 years ago

Commit df98e871 parent 13871ba5 files · +197 −2Browse files

Showing the changes to include (2 of 5 files). Show all

Unified · Split

2 files
  1. include/trace/events/cachefiles.h +58 −0
  2. include/trace/events/fscache.h +4 −0
include/trace/events/cachefiles.h+58−0
@@ -18,6 +18,21 @@ · 17 unmodified lines
1818 #ifndef __CACHEFILES_DECLARE_TRACE_ENUMS_ONCE_ONLY
1919 #define __CACHEFILES_DECLARE_TRACE_ENUMS_ONCE_ONLY
2020
21+enum cachefiles_obj_ref_trace {
22+ cachefiles_obj_get_ioreq,
23+ cachefiles_obj_new,
24+ cachefiles_obj_put_alloc_fail,
25+ cachefiles_obj_put_detach,
26+ cachefiles_obj_put_ioreq,
27+ cachefiles_obj_see_clean_commit,
28+ cachefiles_obj_see_clean_delete,
29+ cachefiles_obj_see_clean_drop_tmp,
30+ cachefiles_obj_see_lookup_cookie,
31+ cachefiles_obj_see_lookup_failed,
32+ cachefiles_obj_see_withdraw_cookie,
33+ cachefiles_obj_see_withdrawal,
34+};
35+
2136 enum fscache_why_object_killed {
2237 FSCACHE_OBJECT_IS_STALE,
2338 FSCACHE_OBJECT_IS_WEIRD,
@@ -66,6 +81,20 @@ enum cachefiles_error_trace { · 42 unmodified lines
6681 EM(FSCACHE_OBJECT_WAS_RETIRED, "was_retired") \
6782 E_(FSCACHE_OBJECT_WAS_CULLED, "was_culled")
6883
84+#define cachefiles_obj_ref_traces \
85+ EM(cachefiles_obj_get_ioreq, "GET ioreq") \
86+ EM(cachefiles_obj_new, "NEW obj") \
87+ EM(cachefiles_obj_put_alloc_fail, "PUT alloc_fail") \
88+ EM(cachefiles_obj_put_detach, "PUT detach") \
89+ EM(cachefiles_obj_put_ioreq, "PUT ioreq") \
90+ EM(cachefiles_obj_see_clean_commit, "SEE clean_commit") \
91+ EM(cachefiles_obj_see_clean_delete, "SEE clean_delete") \
92+ EM(cachefiles_obj_see_clean_drop_tmp, "SEE clean_drop_tmp") \
93+ EM(cachefiles_obj_see_lookup_cookie, "SEE lookup_cookie") \
94+ EM(cachefiles_obj_see_lookup_failed, "SEE lookup_failed") \
95+ EM(cachefiles_obj_see_withdraw_cookie, "SEE withdraw_cookie") \
96+ E_(cachefiles_obj_see_withdrawal, "SEE withdrawal")
97+
6998 #define cachefiles_trunc_traces \
7099 EM(cachefiles_trunc_dio_adjust, "DIOADJ") \
71100 EM(cachefiles_trunc_expand_tmpfile, "EXPTMP") \
@@ -100,6 +129,7 @@ enum cachefiles_error_trace { · 28 unmodified lines
100129 #define E_(a, b) TRACE_DEFINE_ENUM(a);
101130
102131 cachefiles_obj_kill_traces;
132+cachefiles_obj_ref_traces;
103133 cachefiles_trunc_traces;
104134 cachefiles_error_traces;
105135
@@ -113,6 +143,34 @@ cachefiles_error_traces; · 7 unmodified lines
113143 #define E_(a, b) { a, b }
114144
115145
146+TRACE_EVENT(cachefiles_ref,
147+ TP_PROTO(unsigned int object_debug_id,
148+ unsigned int cookie_debug_id,
149+ int usage,
150+ enum cachefiles_obj_ref_trace why),
151+
152+ TP_ARGS(object_debug_id, cookie_debug_id, usage, why),
153+
154+ /* Note that obj may be NULL */
155+ TP_STRUCT__entry(
156+ __field(unsigned int, obj )
157+ __field(unsigned int, cookie )
158+ __field(enum cachefiles_obj_ref_trace, why )
159+ __field(int, usage )
160+ ),
161+
162+ TP_fast_assign(
163+ __entry->obj = object_debug_id;
164+ __entry->cookie = cookie_debug_id;
165+ __entry->usage = usage;
166+ __entry->why = why;
167+ ),
168+
169+ TP_printk("c=%08x o=%08x u=%d %s",
170+ __entry->cookie, __entry->obj, __entry->usage,
171+ __print_symbolic(__entry->why, cachefiles_obj_ref_traces))
172+ );
173+
116174 TRACE_EVENT(cachefiles_lookup,
117175 TP_PROTO(struct cachefiles_object *obj,
118176 struct dentry *de),
include/trace/events/fscache.h+4−0
@@ -49,6 +49,7 @@ enum fscache_volume_trace { · 48 unmodified lines
4949 enum fscache_cookie_trace {
5050 fscache_cookie_collision,
5151 fscache_cookie_discard,
52+ fscache_cookie_get_attach_object,
5253 fscache_cookie_get_end_access,
5354 fscache_cookie_get_hash_collision,
5455 fscache_cookie_get_inval_work,
@@ -57,6 +58,7 @@ enum fscache_cookie_trace { · 2 unmodified lines
5758 fscache_cookie_new_acquire,
5859 fscache_cookie_put_hash_collision,
5960 fscache_cookie_put_lru,
61+ fscache_cookie_put_object,
6062 fscache_cookie_put_over_queued,
6163 fscache_cookie_put_relinquish,
6264 fscache_cookie_put_withdrawn,
@@ -122,6 +124,7 @@ enum fscache_access_trace { · 59 unmodified lines
122124 #define fscache_cookie_traces \
123125 EM(fscache_cookie_collision, "*COLLIDE*") \
124126 EM(fscache_cookie_discard, "DISCARD ") \
127+ EM(fscache_cookie_get_attach_object, "GET attch") \
125128 EM(fscache_cookie_get_hash_collision, "GET hcoll") \
126129 EM(fscache_cookie_get_end_access, "GQ endac") \
127130 EM(fscache_cookie_get_inval_work, "GQ inval") \
@@ -130,6 +133,7 @@ enum fscache_access_trace { · 2 unmodified lines
130133 EM(fscache_cookie_new_acquire, "NEW acq ") \
131134 EM(fscache_cookie_put_hash_collision, "PUT hcoll") \
132135 EM(fscache_cookie_put_lru, "PUT lru ") \
136+ EM(fscache_cookie_put_object, "PUT obj ") \
133137 EM(fscache_cookie_put_over_queued, "PQ overq") \
134138 EM(fscache_cookie_put_relinquish, "PUT relnq") \
135139 EM(fscache_cookie_put_withdrawn, "PUT wthdn") \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t