mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-28 21:46:02 -04:00
rxrpc: Add a tracepoint to track rxrpc_peer refcounting
Add a tracepoint to track reference counting on the rxrpc_peer struct. Signed-off-by: David Howells <dhowells@redhat.com>
This commit is contained in:
@@ -386,9 +386,54 @@ struct rxrpc_peer *rxrpc_lookup_peer(struct rxrpc_local *local,
|
||||
}
|
||||
|
||||
/*
|
||||
* Discard a ref on a remote peer record.
|
||||
* Get a ref on a peer record.
|
||||
*/
|
||||
void __rxrpc_put_peer(struct rxrpc_peer *peer)
|
||||
struct rxrpc_peer *rxrpc_get_peer(struct rxrpc_peer *peer)
|
||||
{
|
||||
const void *here = __builtin_return_address(0);
|
||||
int n;
|
||||
|
||||
n = atomic_inc_return(&peer->usage);
|
||||
trace_rxrpc_peer(peer, rxrpc_peer_got, n, here);
|
||||
return peer;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a ref on a peer record unless its usage has already reached 0.
|
||||
*/
|
||||
struct rxrpc_peer *rxrpc_get_peer_maybe(struct rxrpc_peer *peer)
|
||||
{
|
||||
const void *here = __builtin_return_address(0);
|
||||
|
||||
if (peer) {
|
||||
int n = __atomic_add_unless(&peer->usage, 1, 0);
|
||||
if (n > 0)
|
||||
trace_rxrpc_peer(peer, rxrpc_peer_got, n + 1, here);
|
||||
else
|
||||
peer = NULL;
|
||||
}
|
||||
return peer;
|
||||
}
|
||||
|
||||
/*
|
||||
* Queue a peer record. This passes the caller's ref to the workqueue.
|
||||
*/
|
||||
void __rxrpc_queue_peer_error(struct rxrpc_peer *peer)
|
||||
{
|
||||
const void *here = __builtin_return_address(0);
|
||||
int n;
|
||||
|
||||
n = atomic_read(&peer->usage);
|
||||
if (rxrpc_queue_work(&peer->error_distributor))
|
||||
trace_rxrpc_peer(peer, rxrpc_peer_queued_error, n, here);
|
||||
else
|
||||
rxrpc_put_peer(peer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Discard a peer record.
|
||||
*/
|
||||
static void __rxrpc_put_peer(struct rxrpc_peer *peer)
|
||||
{
|
||||
struct rxrpc_net *rxnet = peer->local->rxnet;
|
||||
|
||||
@@ -402,6 +447,22 @@ void __rxrpc_put_peer(struct rxrpc_peer *peer)
|
||||
kfree_rcu(peer, rcu);
|
||||
}
|
||||
|
||||
/*
|
||||
* Drop a ref on a peer record.
|
||||
*/
|
||||
void rxrpc_put_peer(struct rxrpc_peer *peer)
|
||||
{
|
||||
const void *here = __builtin_return_address(0);
|
||||
int n;
|
||||
|
||||
if (peer) {
|
||||
n = atomic_dec_return(&peer->usage);
|
||||
trace_rxrpc_peer(peer, rxrpc_peer_put, n, here);
|
||||
if (n == 0)
|
||||
__rxrpc_put_peer(peer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* rxrpc_kernel_get_peer - Get the peer address of a call
|
||||
* @sock: The socket on which the call is in progress.
|
||||
|
||||
Reference in New Issue
Block a user