From: Peter Zijlstra <peterz@infradead.org>
To: Qian Cai <cai@lca.pw>
Cc: mingo@redhat.com, will@kernel.org, dbueso@suse.de,
juri.lelli@redhat.com, longman@redhat.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH -next] locking/percpu-rwsem: fix a task_struct refcount
Date: Fri, 27 Mar 2020 10:37:54 +0100 [thread overview]
Message-ID: <20200327093754.GS20713@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20200327031057.10866-1-cai@lca.pw>
On Thu, Mar 26, 2020 at 11:10:57PM -0400, Qian Cai wrote:
> There are some memory leaks due to a missing put_task_struct().
This is an absolutely inadequate changelog. There is no explaning what
the actual race is and why this patch is correct.
> Fixes: 7f26482a872c ("locking/percpu-rwsem: Remove the embedded rwsem")
> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
> kernel/locking/percpu-rwsem.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/locking/percpu-rwsem.c b/kernel/locking/percpu-rwsem.c
> index a008a1ba21a7..6f487e5d923f 100644
> --- a/kernel/locking/percpu-rwsem.c
> +++ b/kernel/locking/percpu-rwsem.c
> @@ -123,8 +123,10 @@ static int percpu_rwsem_wake_function(struct wait_queue_entry *wq_entry,
> struct percpu_rw_semaphore *sem = key;
>
> /* concurrent against percpu_down_write(), can get stolen */
> - if (!__percpu_rwsem_trylock(sem, reader))
> + if (!__percpu_rwsem_trylock(sem, reader)) {
> + put_task_struct(p);
> return 1;
> + }
If the trylock fails, someone else got the lock and we remain on the
waitqueue. It seems like a very bad idea to put the task while it
remains on the waitqueue, no?
>
> list_del_init(&wq_entry->entry);
> smp_store_release(&wq_entry->private, NULL);
> --
> 2.21.0 (Apple Git-122.2)
>
next prev parent reply other threads:[~2020-03-27 9:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-27 3:10 [PATCH -next] locking/percpu-rwsem: fix a task_struct refcount Qian Cai
2020-03-27 9:37 ` Peter Zijlstra [this message]
2020-03-27 10:19 ` Qian Cai
2020-03-27 20:47 ` Memory leaks due to "locking/percpu-rwsem: Remove the embedded rwsem" Qian Cai
2020-03-30 11:18 ` [PATCH -next] locking/percpu-rwsem: fix a task_struct refcount Peter Zijlstra
2020-03-30 13:18 ` Qian Cai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200327093754.GS20713@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=cai@lca.pw \
--cc=dbueso@suse.de \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).