All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Daniel Bristot de Oliveira <bristot@redhat.com>,
	Matt Fleming <matt@codeblueprint.co.uk>,
	"Eric W. Biederman" <ebiederm@xmission.com>
Subject: Re: [patch V2 3/3] signal: Allow tasks to cache one sigqueue struct
Date: Sat, 13 Mar 2021 17:49:36 +0100	[thread overview]
Message-ID: <20210313164935.GA2362@redhat.com> (raw)
In-Reply-To: <871rck2hze.fsf@nanos.tec.linutronix.de>

On 03/12, Thomas Gleixner wrote:
>
> On Fri, Mar 12 2021 at 20:26, Thomas Gleixner wrote:
> > On Fri, Mar 12 2021 at 17:11, Oleg Nesterov wrote:
> >> On 03/11, Thomas Gleixner wrote:
> >>>
> >>> @@ -456,7 +460,12 @@ static void __sigqueue_free(struct sigqu
> >>>  		return;
> >>>  	if (atomic_dec_and_test(&q->user->sigpending))
> >>>  		free_uid(q->user);
> >>> -	kmem_cache_free(sigqueue_cachep, q);
> >>> +
> >>> +	/* Cache one sigqueue per task */
> >>> +	if (!current->sigqueue_cache)
> >>> +		current->sigqueue_cache = q;
> >>> +	else
> >>> +		kmem_cache_free(sigqueue_cachep, q);
> >>>  }
> >>
> >> This doesn't look right, note that __exit_signal() does
> >> flush_sigqueue(&sig->shared_pending) at the end, after exit_task_sighand()
> >> was already called.
> >>
> >> I'd suggest to not add the new exit_task_sighand() helper and simply free
> >> current->sigqueue_cache at the end of __exit_signal().
> >
> > Ooops. Thanks for spotting this!
>
> Hrm.
>
> The task which is released is obviously not current, so even if there
> are still sigqueues in shared_pending then they wont end up in the
> released tasks sigqueue_cache. They can only ever end up in
> current->sigqueue_cache.

The task which is released can be "current" if this task autoreaps.
For example, if its parent ignores SIGCHLD. In this case exit_notify()
does release_task(current).

> But that brings my memory back why I had cmpxchg() in the original
> version. This code runs without current->sighand->siglock held.

Yes, I was wrong too. This code runs without exiting_task->sighand->siglock
and this is fine in that it can not race with send_signal(exiting_task),
but somehow I missed the fact that it always populates current->sigqueue_cache,
not exiting_task->sigqueue_cache.

Oleg.


  parent reply	other threads:[~2021-03-13 16:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-11 13:20 [patch V2 0/3] signals: Allow caching one sigqueue object per task Thomas Gleixner
2021-03-11 13:20 ` [patch V2 1/3] signal: Provide and use exit_task_sighand() Thomas Gleixner
2021-03-11 13:20 ` [patch V2 2/3] signal: Hand SIGQUEUE_PREALLOC flag to __sigqueue_alloc() Thomas Gleixner
2021-03-11 13:20 ` [patch V2 3/3] signal: Allow tasks to cache one sigqueue struct Thomas Gleixner
2021-03-12 11:35   ` Sebastian Andrzej Siewior
2021-03-12 16:18     ` Oleg Nesterov
2021-03-12 19:25       ` Thomas Gleixner
2021-03-12 16:11   ` Oleg Nesterov
2021-03-12 19:26     ` Thomas Gleixner
2021-03-12 21:13       ` Thomas Gleixner
2021-03-13 11:17         ` [patch V3 " Thomas Gleixner
2021-03-13 16:49         ` Oleg Nesterov [this message]
2021-03-16 12:36           ` [patch V2 " Thomas Gleixner
2021-03-11 21:13 ` [patch V2 0/3] signals: Allow caching one sigqueue object per task Eric W. Biederman
2021-03-12 20:02   ` Thomas Gleixner

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=20210313164935.GA2362@redhat.com \
    --to=oleg@redhat.com \
    --cc=bigeasy@linutronix.de \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=ebiederm@xmission.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt@codeblueprint.co.uk \
    --cc=mgorman@suse.de \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=vincent.guittot@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.