Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 31 May 2019 15:20:12 +0100
From: David Howells <>
To: Peter Zijlstra <>
Cc:, Jann Horn <>,
    Greg KH <>,
    Al Viro <>,,
    linux-fsdevel <>,
    Linux API <>,,,
    linux-security-module <>,
    kernel list <>,
    Kees Cook <>,
    Kernel Hardening <>
Subject: Re: [PATCH 1/7] General notification queue with user mmap()'able ring buffer

Peter Zijlstra <> 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,

		ASSERTCMP(n, >=, 0);
		if (n == 0) {
			ASSERT(call->type->name != NULL);

			if (call->rxcall) {
				rxrpc_kernel_end_call(net->socket, call->rxcall);
				call->rxcall = NULL;
			if (call->type->destructor)

			afs_put_server(call->net, call->server);
			afs_put_cb_interest(call->net, call->cbi);

			trace_afs_call(call, afs_call_trace_free, 0, o,

			o = atomic_dec_return(&net->nr_outstanding_calls);
			if (o == 0)

You can see the kfree(call) in there.
Peter Zijlstra <> 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.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.