mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	fscache: Add a tracepoint for cookie use/unuse
Add a tracepoint to track fscache_use/unuse_cookie(). Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> cc: linux-cachefs@redhat.com Link: https://lore.kernel.org/r/164021588628.640689.12942919367404043608.stgit@warthog.procyon.org.uk/ # v4
This commit is contained in:
		
							parent
							
								
									e0484344c0
								
							
						
					
					
						commit
						e6435f1e02
					
				
					 2 changed files with 69 additions and 4 deletions
				
			
		| 
						 | 
					@ -556,6 +556,7 @@ void __fscache_use_cookie(struct fscache_cookie *cookie, bool will_modify)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	enum fscache_cookie_state state;
 | 
						enum fscache_cookie_state state;
 | 
				
			||||||
	bool queue = false;
 | 
						bool queue = false;
 | 
				
			||||||
 | 
						int n_active;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_enter("c=%08x", cookie->debug_id);
 | 
						_enter("c=%08x", cookie->debug_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -565,7 +566,11 @@ void __fscache_use_cookie(struct fscache_cookie *cookie, bool will_modify)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spin_lock(&cookie->lock);
 | 
						spin_lock(&cookie->lock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	atomic_inc(&cookie->n_active);
 | 
						n_active = atomic_inc_return(&cookie->n_active);
 | 
				
			||||||
 | 
						trace_fscache_active(cookie->debug_id, refcount_read(&cookie->ref),
 | 
				
			||||||
 | 
								     n_active, atomic_read(&cookie->n_accesses),
 | 
				
			||||||
 | 
								     will_modify ?
 | 
				
			||||||
 | 
								     fscache_active_use_modify : fscache_active_use);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
again:
 | 
					again:
 | 
				
			||||||
	state = fscache_cookie_state(cookie);
 | 
						state = fscache_cookie_state(cookie);
 | 
				
			||||||
| 
						 | 
					@ -638,13 +643,29 @@ static void fscache_unuse_cookie_locked(struct fscache_cookie *cookie)
 | 
				
			||||||
void __fscache_unuse_cookie(struct fscache_cookie *cookie,
 | 
					void __fscache_unuse_cookie(struct fscache_cookie *cookie,
 | 
				
			||||||
			    const void *aux_data, const loff_t *object_size)
 | 
								    const void *aux_data, const loff_t *object_size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						unsigned int debug_id = cookie->debug_id;
 | 
				
			||||||
 | 
						unsigned int r = refcount_read(&cookie->ref);
 | 
				
			||||||
 | 
						unsigned int a = atomic_read(&cookie->n_accesses);
 | 
				
			||||||
 | 
						unsigned int c;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (aux_data || object_size)
 | 
						if (aux_data || object_size)
 | 
				
			||||||
		__fscache_update_cookie(cookie, aux_data, object_size);
 | 
							__fscache_update_cookie(cookie, aux_data, object_size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (atomic_dec_and_lock(&cookie->n_active, &cookie->lock)) {
 | 
						/* Subtract 1 from counter unless that drops it to 0 (ie. it was 1) */
 | 
				
			||||||
		fscache_unuse_cookie_locked(cookie);
 | 
						c = atomic_fetch_add_unless(&cookie->n_active, -1, 1);
 | 
				
			||||||
		spin_unlock(&cookie->lock);
 | 
						if (c != 1) {
 | 
				
			||||||
 | 
							trace_fscache_active(debug_id, r, c - 1, a, fscache_active_unuse);
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						spin_lock(&cookie->lock);
 | 
				
			||||||
 | 
						r = refcount_read(&cookie->ref);
 | 
				
			||||||
 | 
						a = atomic_read(&cookie->n_accesses);
 | 
				
			||||||
 | 
						c = atomic_dec_return(&cookie->n_active);
 | 
				
			||||||
 | 
						trace_fscache_active(debug_id, r, c, a, fscache_active_unuse);
 | 
				
			||||||
 | 
						if (c == 0)
 | 
				
			||||||
 | 
							fscache_unuse_cookie_locked(cookie);
 | 
				
			||||||
 | 
						spin_unlock(&cookie->lock);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
EXPORT_SYMBOL(__fscache_unuse_cookie);
 | 
					EXPORT_SYMBOL(__fscache_unuse_cookie);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -71,6 +71,12 @@ enum fscache_cookie_trace {
 | 
				
			||||||
	fscache_cookie_see_work,
 | 
						fscache_cookie_see_work,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enum fscache_active_trace {
 | 
				
			||||||
 | 
						fscache_active_use,
 | 
				
			||||||
 | 
						fscache_active_use_modify,
 | 
				
			||||||
 | 
						fscache_active_unuse,
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum fscache_access_trace {
 | 
					enum fscache_access_trace {
 | 
				
			||||||
	fscache_access_acquire_volume,
 | 
						fscache_access_acquire_volume,
 | 
				
			||||||
	fscache_access_acquire_volume_end,
 | 
						fscache_access_acquire_volume_end,
 | 
				
			||||||
| 
						 | 
					@ -146,6 +152,11 @@ enum fscache_access_trace {
 | 
				
			||||||
	EM(fscache_cookie_see_withdraw,		"-   x-wth")		\
 | 
						EM(fscache_cookie_see_withdraw,		"-   x-wth")		\
 | 
				
			||||||
	E_(fscache_cookie_see_work,		"-   work ")
 | 
						E_(fscache_cookie_see_work,		"-   work ")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define fscache_active_traces		\
 | 
				
			||||||
 | 
						EM(fscache_active_use,			"USE          ")	\
 | 
				
			||||||
 | 
						EM(fscache_active_use_modify,		"USE-m        ")	\
 | 
				
			||||||
 | 
						E_(fscache_active_unuse,		"UNUSE        ")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define fscache_access_traces		\
 | 
					#define fscache_access_traces		\
 | 
				
			||||||
	EM(fscache_access_acquire_volume,	"BEGIN acq_vol")	\
 | 
						EM(fscache_access_acquire_volume,	"BEGIN acq_vol")	\
 | 
				
			||||||
	EM(fscache_access_acquire_volume_end,	"END   acq_vol")	\
 | 
						EM(fscache_access_acquire_volume_end,	"END   acq_vol")	\
 | 
				
			||||||
| 
						 | 
					@ -264,6 +275,39 @@ TRACE_EVENT(fscache_cookie,
 | 
				
			||||||
		      __entry->ref)
 | 
							      __entry->ref)
 | 
				
			||||||
	    );
 | 
						    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TRACE_EVENT(fscache_active,
 | 
				
			||||||
 | 
						    TP_PROTO(unsigned int cookie_debug_id,
 | 
				
			||||||
 | 
							     int ref,
 | 
				
			||||||
 | 
							     int n_active,
 | 
				
			||||||
 | 
							     int n_accesses,
 | 
				
			||||||
 | 
							     enum fscache_active_trace why),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						    TP_ARGS(cookie_debug_id, ref, n_active, n_accesses, why),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						    TP_STRUCT__entry(
 | 
				
			||||||
 | 
							    __field(unsigned int,		cookie		)
 | 
				
			||||||
 | 
							    __field(int,			ref		)
 | 
				
			||||||
 | 
							    __field(int,			n_active	)
 | 
				
			||||||
 | 
							    __field(int,			n_accesses	)
 | 
				
			||||||
 | 
							    __field(enum fscache_active_trace,	why		)
 | 
				
			||||||
 | 
								     ),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						    TP_fast_assign(
 | 
				
			||||||
 | 
							    __entry->cookie	= cookie_debug_id;
 | 
				
			||||||
 | 
							    __entry->ref	= ref;
 | 
				
			||||||
 | 
							    __entry->n_active	= n_active;
 | 
				
			||||||
 | 
							    __entry->n_accesses	= n_accesses;
 | 
				
			||||||
 | 
							    __entry->why	= why;
 | 
				
			||||||
 | 
								   ),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						    TP_printk("c=%08x %s r=%d a=%d c=%d",
 | 
				
			||||||
 | 
							      __entry->cookie,
 | 
				
			||||||
 | 
							      __print_symbolic(__entry->why, fscache_active_traces),
 | 
				
			||||||
 | 
							      __entry->ref,
 | 
				
			||||||
 | 
							      __entry->n_accesses,
 | 
				
			||||||
 | 
							      __entry->n_active)
 | 
				
			||||||
 | 
						    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TRACE_EVENT(fscache_access_cache,
 | 
					TRACE_EVENT(fscache_access_cache,
 | 
				
			||||||
	    TP_PROTO(unsigned int cache_debug_id,
 | 
						    TP_PROTO(unsigned int cache_debug_id,
 | 
				
			||||||
		     int ref,
 | 
							     int ref,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue