From: Oleg Nesterov <oleg@redhat.com>
To: Wander Lairson Costa <wander@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Andy Lutomirski <luto@kernel.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
"Liam R. Howlett" <Liam.Howlett@Oracle.com>,
Fenghua Yu <fenghua.yu@intel.com>,
Andrei Vagin <avagin@gmail.com>,
open list <linux-kernel@vger.kernel.org>,
Hu Chunyu <chuhu@redhat.com>,
Valentin Schneider <vschneid@redhat.com>,
Paul McKenney <paulmck@kernel.org>
Subject: Re: [PATCH v3] kernel/fork: beware of __put_task_struct calling context
Date: Thu, 2 Feb 2023 19:37:35 +0100 [thread overview]
Message-ID: <20230202183735.GA17563@redhat.com> (raw)
In-Reply-To: <20230201124541.62104-1-wander@redhat.com>
On 02/01, Wander Lairson Costa wrote:
>
> Instead of calling __put_task_struct() directly, we defer it using
> call_rcu(). A more natural approach would use a workqueue, but since
> in PREEMPT_RT, we can't allocate dynamic memory from atomic context,
> the code would become more complex because we would need to put the
> work_struct instance in the task_struct and initialize it when we
> allocate a new task_struct.
I don't think I can ack the changes in PREEMPT_RT but this version LGTM.
just a couple of purely cosmetic nits, feel free to ignore...
> +static void __delayed_put_task_struct(struct rcu_head *rhp)
> +{
> + struct task_struct *task = container_of(rhp, struct task_struct, rcu);
> +
> + ___put_task_struct(task);
> +}
We already have delayed_put_task_struct() which differs very much.
Perhaps something like ___put_task_struct() will look less confusing.
> +void __put_task_struct(struct task_struct *tsk)
> +{
> + if (IS_ENABLED(CONFIG_PREEMPT_RT) && (!preemptible() || !in_task()))
> + /*
> + * under PREEMPT_RT, we can't call put_task_struct
> + * in atomic context because it will indirectly
> + * acquire sleeping locks.
> + */
> + call_rcu(&tsk->rcu, __delayed_put_task_struct);
Perhaps this deserves additional note to explain why is it safe to use tsk->rcu
union. May be this is obvious, but I was confused when I looked at the previous
version ;)
but again, feel free to ignore.
Oleg.
next prev parent reply other threads:[~2023-02-02 18:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-01 12:45 [PATCH v3] kernel/fork: beware of __put_task_struct calling context Wander Lairson Costa
2023-02-02 18:37 ` Oleg Nesterov [this message]
2023-02-02 19:55 ` Wander Lairson Costa
2023-02-02 20:22 ` Oleg Nesterov
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=20230202183735.GA17563@redhat.com \
--to=oleg@redhat.com \
--cc=Liam.Howlett@Oracle.com \
--cc=akpm@linux-foundation.org \
--cc=avagin@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=chuhu@redhat.com \
--cc=ebiederm@xmission.com \
--cc=fenghua.yu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=vschneid@redhat.com \
--cc=wander@redhat.com \
/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.