All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Bradley Morgan <brads@mainlining.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	mm-commits@vger.kernel.org, bsingharora@gmail.com
Subject: Re: [to-be-updated] taskstats-copy-signal-stats-under-siglock-in-taskstats_exit.patch removed from -mm tree
Date: Wed, 7 Oct 2026 20:06:02 +0200	[thread overview]
Message-ID: <asaKCo5lwB3nzWNM@redhat.com> (raw)
In-Reply-To: <A2B94D8E-F026-406E-B346-9200FA081EB0@mainlining.org>

On 10/07, Bradley Morgan wrote:
>
> Changes since V1:
> - spin_lock_irq() instead of spin_lock_irqsave() (Oleg)

I have already reviewed this version... Let me quote
https://lore.kernel.org/all/anMC3eRoRdaST0Se@redhat.com/

	Acked-by: Oleg Nesterov <oleg@redhat.com>

	However. I won't blame your fix, but I am not sure it actually fixes the
	real problem.

	In the scenario above, if thread B takes ->siglock first (before thread A)
	it will report TASKSTATS_TYPE_TGID/AGROUP without accounting thread A.
	Looks "obviously wrong" but I forgot everything about taskstats.

	And OTOH... for_each_thread() in fill_stats_for_tgid() can't rely on the
	tsk->exit_state check, the same thread can be accounted twice.

So perhaps the changelog should mention that this patch doesn't fix all the
related problems? Or may be you can try to make V3 which fixes them all?

> --- a/kernel/taskstats.c
> +++ b/kernel/taskstats.c
> @@ -635,7 +635,10 @@ void taskstats_exit(struct task_struct *tsk, int group_dead)
>  	if (!stats)
>  		goto err;
>
> +	/* This was racy before, copy the stats under siglock. */

Well, this comment looks strange to me. I'd suggest to drop it.

> +	spin_lock_irq(&tsk->sighand->siglock);
>  	memcpy(stats, tsk->signal->stats, sizeof(*stats));
> +	spin_unlock_irq(&tsk->sighand->siglock);
>  	stats->version = TASKSTATS_VERSION;

Oleg.


      parent reply	other threads:[~2026-10-07 18:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-07  1:21 [to-be-updated] taskstats-copy-signal-stats-under-siglock-in-taskstats_exit.patch removed from -mm tree Andrew Morton
2026-10-07  6:39 ` Bradley Morgan
2026-10-07 17:12   ` Andrew Morton
2026-10-07 17:19     ` Bradley Morgan
2026-10-07 17:54       ` Andrew Morton
2026-10-07 18:06       ` Oleg Nesterov [this message]

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=asaKCo5lwB3nzWNM@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=brads@mainlining.org \
    --cc=bsingharora@gmail.com \
    --cc=mm-commits@vger.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 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.