[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210323180442.GC29219@redhat.com>
Date: Tue, 23 Mar 2021 19:04:42 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: LKML <linux-kernel@...r.kernel.org>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>,
Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Matt Fleming <matt@...eblueprint.co.uk>,
"Eric W. Biederman" <ebiederm@...ssion.com>
Subject: Re: [patch V4 2/2] signal: Allow tasks to cache one sigqueue struct
On 03/22, Thomas Gleixner wrote:
>
> +static void sigqueue_cache_or_free(struct sigqueue *q, bool cache)
> +{
> + /*
> + * Cache one sigqueue per task. This pairs with the consumer side
> + * in __sigqueue_alloc() and needs READ/WRITE_ONCE() to prevent the
> + * compiler from store tearing and to tell KCSAN that the data race
> + * is intentional when run without holding current->sighand->siglock,
> + * which is fine as current obviously cannot run __sigqueue_free()
> + * concurrently.
> + */
> + if (cache && !READ_ONCE(current->sigqueue_cache))
> + WRITE_ONCE(current->sigqueue_cache, q);
> + else
> + kmem_cache_free(sigqueue_cachep, q);
> +}
> +
> +void exit_task_sigqueue_cache(struct task_struct *tsk)
> +{
> + /* Race free because @tsk is mopped up */
> + struct sigqueue *q = tsk->sigqueue_cache;
> +
> + if (q) {
> + tsk->sigqueue_cache = NULL;
> + /* If task is self reaping, don't cache it back */
> + sigqueue_cache_or_free(q, tsk != current);
^^^^^^^^^^^^^^
Still not right or I am totally confused.
tsk != current can be true if an exiting (and autoreaping) sub-thread
releases its group leader.
IOW. Suppose a process has 2 threads, its parent ignores SIGCHLD.
The group leader L exits. Then its sub-thread T exits too and calls
release_task(T). In this case the tsk != current is false.
But after that T calls release_task(L) and L != T is true.
I'd suggest to free tsk->sigqueue_cache in __exit_signal() unconditionally and
remove the "bool cache" argument from sigqueue_cache_or_free().
Oleg.
Powered by blists - more mailing lists