Commit 2908f5e1 authored by David Howells's avatar David Howells

fscache: Add a cookie debug ID and use that in traces

Add a cookie debug ID and use that in traces and in procfiles rather than
displaying the (hashed) pointer to the cookie.  This is easier to correlate
and we don't lose anything when interpreting oops output since that shows
unhashed addresses and registers that aren't comparable to the hashed
values.

Changes:

ver #2:
 - Fix the fscache_op tracepoint to handle a NULL cookie pointer.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Reviewed-by: default avatarJeff Layton <jlayton@redhat.com>
cc: linux-cachefs@redhat.com
Link: https://lore.kernel.org/r/158861210988.340223.11688464116498247790.stgit@warthog.procyon.org.uk/ # rfc
Link: https://lore.kernel.org/r/159465769844.1376105.14119502774019865432.stgit@warthog.procyon.org.uk/
Link: https://lore.kernel.org/r/160588459097.3465195.1273313637721852165.stgit@warthog.procyon.org.uk/ # rfc
Link: https://lore.kernel.org/r/162431193544.2908479.17556704572948300790.stgit@warthog.procyon.org.uk/
parent 18598195
...@@ -29,21 +29,29 @@ static int fscache_attach_object(struct fscache_cookie *cookie, ...@@ -29,21 +29,29 @@ static int fscache_attach_object(struct fscache_cookie *cookie,
static void fscache_print_cookie(struct fscache_cookie *cookie, char prefix) static void fscache_print_cookie(struct fscache_cookie *cookie, char prefix)
{ {
struct hlist_node *object; struct fscache_object *object;
struct hlist_node *o;
const u8 *k; const u8 *k;
unsigned loop; unsigned loop;
pr_err("%c-cookie c=%p [p=%p fl=%lx nc=%u na=%u]\n", pr_err("%c-cookie c=%08x [p=%08x fl=%lx nc=%u na=%u]\n",
prefix, cookie, cookie->parent, cookie->flags, prefix,
cookie->debug_id,
cookie->parent ? cookie->parent->debug_id : 0,
cookie->flags,
atomic_read(&cookie->n_children), atomic_read(&cookie->n_children),
atomic_read(&cookie->n_active)); atomic_read(&cookie->n_active));
pr_err("%c-cookie d=%p n=%p\n", pr_err("%c-cookie d=%p{%s} n=%p\n",
prefix, cookie->def, cookie->netfs_data); prefix,
cookie->def,
cookie->def ? cookie->def->name : "?",
cookie->netfs_data);
object = READ_ONCE(cookie->backing_objects.first); o = READ_ONCE(cookie->backing_objects.first);
if (object) if (o) {
pr_err("%c-cookie o=%p\n", object = hlist_entry(o, struct fscache_object, cookie_link);
prefix, hlist_entry(object, struct fscache_object, cookie_link)); pr_err("%c-cookie o=%u\n", prefix, object->debug_id);
}
pr_err("%c-key=[%u] '", prefix, cookie->key_len); pr_err("%c-key=[%u] '", prefix, cookie->key_len);
k = (cookie->key_len <= sizeof(cookie->inline_key)) ? k = (cookie->key_len <= sizeof(cookie->inline_key)) ?
...@@ -129,6 +137,8 @@ static long fscache_compare_cookie(const struct fscache_cookie *a, ...@@ -129,6 +137,8 @@ static long fscache_compare_cookie(const struct fscache_cookie *a,
return memcmp(ka, kb, a->key_len); return memcmp(ka, kb, a->key_len);
} }
static atomic_t fscache_cookie_debug_id = ATOMIC_INIT(1);
/* /*
* Allocate a cookie. * Allocate a cookie.
*/ */
...@@ -163,6 +173,7 @@ struct fscache_cookie *fscache_alloc_cookie( ...@@ -163,6 +173,7 @@ struct fscache_cookie *fscache_alloc_cookie(
atomic_set(&cookie->usage, 1); atomic_set(&cookie->usage, 1);
atomic_set(&cookie->n_children, 0); atomic_set(&cookie->n_children, 0);
cookie->debug_id = atomic_inc_return(&fscache_cookie_debug_id);
/* We keep the active count elevated until relinquishment to prevent an /* We keep the active count elevated until relinquishment to prevent an
* attempt to wake up every time the object operations queue quiesces. * attempt to wake up every time the object operations queue quiesces.
......
...@@ -45,6 +45,7 @@ static struct fscache_cookie_def fscache_fsdef_index_def = { ...@@ -45,6 +45,7 @@ static struct fscache_cookie_def fscache_fsdef_index_def = {
}; };
struct fscache_cookie fscache_fsdef_index = { struct fscache_cookie fscache_fsdef_index = {
.debug_id = 1,
.usage = ATOMIC_INIT(1), .usage = ATOMIC_INIT(1),
.n_active = ATOMIC_INIT(1), .n_active = ATOMIC_INIT(1),
.lock = __SPIN_LOCK_UNLOCKED(fscache_fsdef_index.lock), .lock = __SPIN_LOCK_UNLOCKED(fscache_fsdef_index.lock),
......
...@@ -170,7 +170,7 @@ static int fscache_objlist_show(struct seq_file *m, void *v) ...@@ -170,7 +170,7 @@ static int fscache_objlist_show(struct seq_file *m, void *v)
if ((unsigned long) v == 1) { if ((unsigned long) v == 1) {
seq_puts(m, "OBJECT PARENT STAT CHLDN OPS OOP IPR EX READS" seq_puts(m, "OBJECT PARENT STAT CHLDN OPS OOP IPR EX READS"
" EM EV FL S" " EM EV FL S"
" | NETFS_COOKIE_DEF TY FL NETFS_DATA"); " | COOKIE NETFS_COOKIE_DEF TY FL NETFS_DATA");
if (config & (FSCACHE_OBJLIST_CONFIG_KEY | if (config & (FSCACHE_OBJLIST_CONFIG_KEY |
FSCACHE_OBJLIST_CONFIG_AUX)) FSCACHE_OBJLIST_CONFIG_AUX))
seq_puts(m, " "); seq_puts(m, " ");
...@@ -189,7 +189,7 @@ static int fscache_objlist_show(struct seq_file *m, void *v) ...@@ -189,7 +189,7 @@ static int fscache_objlist_show(struct seq_file *m, void *v)
if ((unsigned long) v == 2) { if ((unsigned long) v == 2) {
seq_puts(m, "======== ======== ==== ===== === === === == =====" seq_puts(m, "======== ======== ==== ===== === === === == ====="
" == == == =" " == == == ="
" | ================ == == ================"); " | ======== ================ == === ================");
if (config & (FSCACHE_OBJLIST_CONFIG_KEY | if (config & (FSCACHE_OBJLIST_CONFIG_KEY |
FSCACHE_OBJLIST_CONFIG_AUX)) FSCACHE_OBJLIST_CONFIG_AUX))
seq_puts(m, " ================"); seq_puts(m, " ================");
...@@ -231,9 +231,9 @@ static int fscache_objlist_show(struct seq_file *m, void *v) ...@@ -231,9 +231,9 @@ static int fscache_objlist_show(struct seq_file *m, void *v)
} }
seq_printf(m, seq_printf(m,
"%8x %8x %s %5u %3u %3u %3u %2u %5u %2lx %2lx %2lx %1x | ", "%08x %08x %s %5u %3u %3u %3u %2u %5u %2lx %2lx %2lx %1x | ",
obj->debug_id, obj->debug_id,
obj->parent ? obj->parent->debug_id : -1, obj->parent ? obj->parent->debug_id : UINT_MAX,
obj->state->short_name, obj->state->short_name,
obj->n_children, obj->n_children,
obj->n_ops, obj->n_ops,
...@@ -246,7 +246,7 @@ static int fscache_objlist_show(struct seq_file *m, void *v) ...@@ -246,7 +246,7 @@ static int fscache_objlist_show(struct seq_file *m, void *v)
obj->flags, obj->flags,
work_busy(&obj->work)); work_busy(&obj->work));
if (fscache_use_cookie(obj)) { if (obj->cookie) {
uint16_t keylen = 0, auxlen = 0; uint16_t keylen = 0, auxlen = 0;
switch (cookie->type) { switch (cookie->type) {
...@@ -263,7 +263,8 @@ static int fscache_objlist_show(struct seq_file *m, void *v) ...@@ -263,7 +263,8 @@ static int fscache_objlist_show(struct seq_file *m, void *v)
break; break;
} }
seq_printf(m, "%-16s %s %2lx %16p", seq_printf(m, "%08x %-16s %s %3lx %16p",
cookie->debug_id,
cookie->def->name, cookie->def->name,
type, type,
cookie->flags, cookie->flags,
...@@ -292,7 +293,6 @@ static int fscache_objlist_show(struct seq_file *m, void *v) ...@@ -292,7 +293,6 @@ static int fscache_objlist_show(struct seq_file *m, void *v)
} }
seq_puts(m, "\n"); seq_puts(m, "\n");
fscache_unuse_cookie(obj);
} else { } else {
seq_puts(m, "<no_netfs>\n"); seq_puts(m, "<no_netfs>\n");
} }
......
...@@ -126,6 +126,7 @@ struct fscache_cookie { ...@@ -126,6 +126,7 @@ struct fscache_cookie {
atomic_t usage; /* number of users of this cookie */ atomic_t usage; /* number of users of this cookie */
atomic_t n_children; /* number of children of this cookie */ atomic_t n_children; /* number of children of this cookie */
atomic_t n_active; /* number of active users of netfs ptrs */ atomic_t n_active; /* number of active users of netfs ptrs */
unsigned int debug_id;
spinlock_t lock; spinlock_t lock;
spinlock_t stores_lock; /* lock on page store tree */ spinlock_t stores_lock; /* lock on page store tree */
struct hlist_head backing_objects; /* object(s) backing this file/index */ struct hlist_head backing_objects; /* object(s) backing this file/index */
......
...@@ -78,20 +78,20 @@ TRACE_EVENT(cachefiles_ref, ...@@ -78,20 +78,20 @@ TRACE_EVENT(cachefiles_ref,
/* Note that obj may be NULL */ /* Note that obj may be NULL */
TP_STRUCT__entry( TP_STRUCT__entry(
__field(struct cachefiles_object *, obj ) __field(unsigned int, obj )
__field(struct fscache_cookie *, cookie ) __field(unsigned int, cookie )
__field(enum cachefiles_obj_ref_trace, why ) __field(enum cachefiles_obj_ref_trace, why )
__field(int, usage ) __field(int, usage )
), ),
TP_fast_assign( TP_fast_assign(
__entry->obj = obj; __entry->obj = obj->fscache.debug_id;
__entry->cookie = cookie; __entry->cookie = cookie->debug_id;
__entry->usage = usage; __entry->usage = usage;
__entry->why = why; __entry->why = why;
), ),
TP_printk("c=%p o=%p u=%d %s", TP_printk("c=%08x o=%08x u=%d %s",
__entry->cookie, __entry->obj, __entry->usage, __entry->cookie, __entry->obj, __entry->usage,
__print_symbolic(__entry->why, cachefiles_obj_ref_traces)) __print_symbolic(__entry->why, cachefiles_obj_ref_traces))
); );
...@@ -104,18 +104,18 @@ TRACE_EVENT(cachefiles_lookup, ...@@ -104,18 +104,18 @@ TRACE_EVENT(cachefiles_lookup,
TP_ARGS(obj, de, inode), TP_ARGS(obj, de, inode),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(struct cachefiles_object *, obj ) __field(unsigned int, obj )
__field(struct dentry *, de ) __field(struct dentry *, de )
__field(struct inode *, inode ) __field(struct inode *, inode )
), ),
TP_fast_assign( TP_fast_assign(
__entry->obj = obj; __entry->obj = obj->fscache.debug_id;
__entry->de = de; __entry->de = de;
__entry->inode = inode; __entry->inode = inode;
), ),
TP_printk("o=%p d=%p i=%p", TP_printk("o=%08x d=%p i=%p",
__entry->obj, __entry->de, __entry->inode) __entry->obj, __entry->de, __entry->inode)
); );
...@@ -126,18 +126,18 @@ TRACE_EVENT(cachefiles_mkdir, ...@@ -126,18 +126,18 @@ TRACE_EVENT(cachefiles_mkdir,
TP_ARGS(obj, de, ret), TP_ARGS(obj, de, ret),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(struct cachefiles_object *, obj ) __field(unsigned int, obj )
__field(struct dentry *, de ) __field(struct dentry *, de )
__field(int, ret ) __field(int, ret )
), ),
TP_fast_assign( TP_fast_assign(
__entry->obj = obj; __entry->obj = obj->fscache.debug_id;
__entry->de = de; __entry->de = de;
__entry->ret = ret; __entry->ret = ret;
), ),
TP_printk("o=%p d=%p r=%u", TP_printk("o=%08x d=%p r=%u",
__entry->obj, __entry->de, __entry->ret) __entry->obj, __entry->de, __entry->ret)
); );
...@@ -148,18 +148,18 @@ TRACE_EVENT(cachefiles_create, ...@@ -148,18 +148,18 @@ TRACE_EVENT(cachefiles_create,
TP_ARGS(obj, de, ret), TP_ARGS(obj, de, ret),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(struct cachefiles_object *, obj ) __field(unsigned int, obj )
__field(struct dentry *, de ) __field(struct dentry *, de )
__field(int, ret ) __field(int, ret )
), ),
TP_fast_assign( TP_fast_assign(
__entry->obj = obj; __entry->obj = obj->fscache.debug_id;
__entry->de = de; __entry->de = de;
__entry->ret = ret; __entry->ret = ret;
), ),
TP_printk("o=%p d=%p r=%u", TP_printk("o=%08x d=%p r=%u",
__entry->obj, __entry->de, __entry->ret) __entry->obj, __entry->de, __entry->ret)
); );
...@@ -172,18 +172,18 @@ TRACE_EVENT(cachefiles_unlink, ...@@ -172,18 +172,18 @@ TRACE_EVENT(cachefiles_unlink,
/* Note that obj may be NULL */ /* Note that obj may be NULL */
TP_STRUCT__entry( TP_STRUCT__entry(
__field(struct cachefiles_object *, obj ) __field(unsigned int, obj )
__field(struct dentry *, de ) __field(struct dentry *, de )
__field(enum fscache_why_object_killed, why ) __field(enum fscache_why_object_killed, why )
), ),
TP_fast_assign( TP_fast_assign(
__entry->obj = obj; __entry->obj = obj->fscache.debug_id;
__entry->de = de; __entry->de = de;
__entry->why = why; __entry->why = why;
), ),
TP_printk("o=%p d=%p w=%s", TP_printk("o=%08x d=%p w=%s",
__entry->obj, __entry->de, __entry->obj, __entry->de,
__print_symbolic(__entry->why, cachefiles_obj_kill_traces)) __print_symbolic(__entry->why, cachefiles_obj_kill_traces))
); );
...@@ -198,20 +198,20 @@ TRACE_EVENT(cachefiles_rename, ...@@ -198,20 +198,20 @@ TRACE_EVENT(cachefiles_rename,
/* Note that obj may be NULL */ /* Note that obj may be NULL */
TP_STRUCT__entry( TP_STRUCT__entry(
__field(struct cachefiles_object *, obj ) __field(unsigned int, obj )
__field(struct dentry *, de ) __field(struct dentry *, de )
__field(struct dentry *, to ) __field(struct dentry *, to )
__field(enum fscache_why_object_killed, why ) __field(enum fscache_why_object_killed, why )
), ),
TP_fast_assign( TP_fast_assign(
__entry->obj = obj; __entry->obj = obj->fscache.debug_id;
__entry->de = de; __entry->de = de;
__entry->to = to; __entry->to = to;
__entry->why = why; __entry->why = why;
), ),
TP_printk("o=%p d=%p t=%p w=%s", TP_printk("o=%08x d=%p t=%p w=%s",
__entry->obj, __entry->de, __entry->to, __entry->obj, __entry->de, __entry->to,
__print_symbolic(__entry->why, cachefiles_obj_kill_traces)) __print_symbolic(__entry->why, cachefiles_obj_kill_traces))
); );
...@@ -224,16 +224,16 @@ TRACE_EVENT(cachefiles_mark_active, ...@@ -224,16 +224,16 @@ TRACE_EVENT(cachefiles_mark_active,
/* Note that obj may be NULL */ /* Note that obj may be NULL */
TP_STRUCT__entry( TP_STRUCT__entry(
__field(struct cachefiles_object *, obj ) __field(unsigned int, obj )
__field(struct dentry *, de ) __field(struct dentry *, de )
), ),
TP_fast_assign( TP_fast_assign(
__entry->obj = obj; __entry->obj = obj->fscache.debug_id;
__entry->de = de; __entry->de = de;
), ),
TP_printk("o=%p d=%p", TP_printk("o=%08x d=%p",
__entry->obj, __entry->de) __entry->obj, __entry->de)
); );
...@@ -246,22 +246,22 @@ TRACE_EVENT(cachefiles_wait_active, ...@@ -246,22 +246,22 @@ TRACE_EVENT(cachefiles_wait_active,
/* Note that obj may be NULL */ /* Note that obj may be NULL */
TP_STRUCT__entry( TP_STRUCT__entry(
__field(struct cachefiles_object *, obj ) __field(unsigned int, obj )
__field(unsigned int, xobj )
__field(struct dentry *, de ) __field(struct dentry *, de )
__field(struct cachefiles_object *, xobj )
__field(u16, flags ) __field(u16, flags )
__field(u16, fsc_flags ) __field(u16, fsc_flags )
), ),
TP_fast_assign( TP_fast_assign(
__entry->obj = obj; __entry->obj = obj->fscache.debug_id;
__entry->de = de; __entry->de = de;
__entry->xobj = xobj; __entry->xobj = xobj->fscache.debug_id;
__entry->flags = xobj->flags; __entry->flags = xobj->flags;
__entry->fsc_flags = xobj->fscache.flags; __entry->fsc_flags = xobj->fscache.flags;
), ),
TP_printk("o=%p d=%p wo=%p wf=%x wff=%x", TP_printk("o=%08x d=%p wo=%08x wf=%x wff=%x",
__entry->obj, __entry->de, __entry->xobj, __entry->obj, __entry->de, __entry->xobj,
__entry->flags, __entry->fsc_flags) __entry->flags, __entry->fsc_flags)
); );
...@@ -275,18 +275,18 @@ TRACE_EVENT(cachefiles_mark_inactive, ...@@ -275,18 +275,18 @@ TRACE_EVENT(cachefiles_mark_inactive,
/* Note that obj may be NULL */ /* Note that obj may be NULL */
TP_STRUCT__entry( TP_STRUCT__entry(
__field(struct cachefiles_object *, obj ) __field(unsigned int, obj )
__field(struct dentry *, de ) __field(struct dentry *, de )
__field(struct inode *, inode ) __field(struct inode *, inode )
), ),
TP_fast_assign( TP_fast_assign(
__entry->obj = obj; __entry->obj = obj->fscache.debug_id;
__entry->de = de; __entry->de = de;
__entry->inode = inode; __entry->inode = inode;
), ),
TP_printk("o=%p d=%p i=%p", TP_printk("o=%08x d=%p i=%p",
__entry->obj, __entry->de, __entry->inode) __entry->obj, __entry->de, __entry->inode)
); );
...@@ -299,18 +299,18 @@ TRACE_EVENT(cachefiles_mark_buried, ...@@ -299,18 +299,18 @@ TRACE_EVENT(cachefiles_mark_buried,
/* Note that obj may be NULL */ /* Note that obj may be NULL */
TP_STRUCT__entry( TP_STRUCT__entry(
__field(struct cachefiles_object *, obj ) __field(unsigned int, obj )
__field(struct dentry *, de ) __field(struct dentry *, de )
__field(enum fscache_why_object_killed, why ) __field(enum fscache_why_object_killed, why )
), ),
TP_fast_assign( TP_fast_assign(
__entry->obj = obj; __entry->obj = obj->fscache.debug_id;
__entry->de = de; __entry->de = de;
__entry->why = why; __entry->why = why;
), ),
TP_printk("o=%p d=%p w=%s", TP_printk("o=%08x d=%p w=%s",
__entry->obj, __entry->de, __entry->obj, __entry->de,
__print_symbolic(__entry->why, cachefiles_obj_kill_traces)) __print_symbolic(__entry->why, cachefiles_obj_kill_traces))
); );
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment