[PATCH 1/7] General notification queue with user mmap()'able ring buffer
David Howells
dhowells at redhat.com
Fri May 31 14:20:12 UTC 2019
Peter Zijlstra <peterz at infradead.org> wrote:
> Is it not the responsibility of the task that affects the 1->0
> transition to actually free the memory?
>
> That is, I'm expecting the '...' in both cases above the include the
> actual freeing of the object. If this is not the case, then @usage is
> not a reference count.
Yes. The '...' does the freeing. It seemed unnecessary to include the code
ellipsised there since it's not the point of the discussion, but if you want
the full function:
void afs_put_call(struct afs_call *call)
{
struct afs_net *net = call->net;
int n = atomic_dec_return(&call->usage);
int o = atomic_read(&net->nr_outstanding_calls);
trace_afs_call(call, afs_call_trace_put, n + 1, o,
__builtin_return_address(0));
ASSERTCMP(n, >=, 0);
if (n == 0) {
ASSERT(!work_pending(&call->async_work));
ASSERT(call->type->name != NULL);
if (call->rxcall) {
rxrpc_kernel_end_call(net->socket, call->rxcall);
call->rxcall = NULL;
}
if (call->type->destructor)
call->type->destructor(call);
afs_put_server(call->net, call->server);
afs_put_cb_interest(call->net, call->cbi);
afs_put_addrlist(call->alist);
kfree(call->request);
trace_afs_call(call, afs_call_trace_free, 0, o,
__builtin_return_address(0));
kfree(call);
o = atomic_dec_return(&net->nr_outstanding_calls);
if (o == 0)
wake_up_var(&net->nr_outstanding_calls);
}
}
You can see the kfree(call) in there.
Peter Zijlstra <peterz at infradead.org> wrote:
> (and it has already been established that refcount_t doesn't work for
> usage count scenarios)
?
Does that mean struct kref doesn't either?
> Aside from that, is the problem that refcount_dec_and_test() returns a
> boolean (true - last put, false - not last) instead of the refcount
> value? This does indeed make it hard to print the exact count value for
> the event.
That is the problem, yes - well, one of them: refcount_inc() doesn't either.
David
More information about the Linux-security-module-archive
mailing list