diff options
author | David Howells <dhowells@redhat.com> | 2023-10-19 15:59:03 +0300 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2023-12-24 18:22:54 +0300 |
commit | 1e5d8493254db9b28d4dce4fed87e56d9a2fefa5 (patch) | |
tree | c71eb5dae008ff932f61ac13d3071c3353ba858c /fs/afs/addr_list.c | |
parent | aa453becce5d1ae1b94b7fc22f47d7b05d22b14e (diff) | |
download | linux-1e5d8493254db9b28d4dce4fed87e56d9a2fefa5.tar.xz |
afs: Add a tracepoint for struct afs_addr_list
Add a tracepoint to track the lifetime of the afs_addr_list struct.
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
Diffstat (limited to 'fs/afs/addr_list.c')
-rw-r--r-- | fs/afs/addr_list.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/fs/afs/addr_list.c b/fs/afs/addr_list.c index a1f3c995e328..41ef0c879239 100644 --- a/fs/afs/addr_list.c +++ b/fs/afs/addr_list.c @@ -20,17 +20,39 @@ static void afs_free_addrlist(struct rcu_head *rcu) for (i = 0; i < alist->nr_addrs; i++) rxrpc_kernel_put_peer(alist->addrs[i].peer); + trace_afs_alist(alist->debug_id, refcount_read(&alist->usage), afs_alist_trace_free); + kfree(alist); } /* * Release an address list. */ -void afs_put_addrlist(struct afs_addr_list *alist) +void afs_put_addrlist(struct afs_addr_list *alist, enum afs_alist_trace reason) { - if (alist && refcount_dec_and_test(&alist->usage)) + unsigned int debug_id; + bool dead; + int r; + + if (!alist) + return; + debug_id = alist->debug_id; + dead = __refcount_dec_and_test(&alist->usage, &r); + trace_afs_alist(debug_id, r - 1, reason); + if (dead) call_rcu(&alist->rcu, afs_free_addrlist); } +struct afs_addr_list *afs_get_addrlist(struct afs_addr_list *alist, enum afs_alist_trace reason) +{ + int r; + + if (alist) { + __refcount_inc(&alist->usage, &r); + trace_afs_alist(alist->debug_id, r + 1, reason); + } + return alist; +} + /* * Allocate an address list. */ @@ -38,6 +60,7 @@ struct afs_addr_list *afs_alloc_addrlist(unsigned int nr, u16 service_id) { struct afs_addr_list *alist; unsigned int i; + static atomic_t debug_id; _enter("%u,%u", nr, service_id); @@ -50,9 +73,11 @@ struct afs_addr_list *afs_alloc_addrlist(unsigned int nr, u16 service_id) refcount_set(&alist->usage, 1); alist->max_addrs = nr; + alist->debug_id = atomic_inc_return(&debug_id); for (i = 0; i < nr; i++) alist->addrs[i].service_id = service_id; + trace_afs_alist(alist->debug_id, 1, afs_alist_trace_alloc); return alist; } @@ -217,7 +242,7 @@ bad_address: problem, p - text, (int)len, (int)len, text); ret = -EINVAL; error: - afs_put_addrlist(alist); + afs_put_addrlist(alist, afs_alist_trace_put_parse_error); error_vl: afs_put_vlserverlist(net, vllist); return ERR_PTR(ret); @@ -403,7 +428,7 @@ void afs_end_cursor(struct afs_addr_cursor *ac) ac->index != alist->preferred && test_bit(ac->alist->preferred, &ac->tried)) WRITE_ONCE(alist->preferred, ac->index); - afs_put_addrlist(alist); + afs_put_addrlist(alist, afs_alist_trace_put_end_cursor); ac->alist = NULL; } } |