From: Valentin Schneider <valentin.schneider@arm.com>
To: paulmck@kernel.org
Cc: frederic@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: Question about a8ea6fc9b089 ("sched: Stop PF_NO_SETAFFINITY from being inherited by various init system threads")
Date: Fri, 11 Jun 2021 15:19:29 +0100 [thread overview]
Message-ID: <87r1h8bi1a.mognet@arm.com> (raw)
In-Reply-To: <20210611135207.GB4397@paulmck-ThinkPad-P17-Gen-1>
On 11/06/21 06:52, Paul E. McKenney wrote:
> On Fri, Jun 11, 2021 at 11:12:29AM +0100, Valentin Schneider wrote:
>>
>> The way I see 570a752b7a9b is that, if a task is pinned to a single CPU but
>> doesn't have PF_NO_SETAFFINITY, then userspace can unpin it. This means it
>> ought to have entered check_preemption_disabled() with preemption disabled
>> - right now it may be pinned, but that can change at any minute, and
>> whatever code it is running needs to cope with that.
>
> Thank you for catching me up on this topic!
>
>> Could you share some details on which tasks you are hitting this with?
>
> Let's start with ref_scale_reader() in kernel/rcu/refscale.c. This
> is for fine-grained in-kernel benchmarking, so it really wants kthreads
> running this function to be pinned.
>
> I took a look at kthread_bind(), but it is not intended to be called by
> the kthread itself. Looking elsewhere in the kernel, it looks like I
> just do this right after invoking set_cpus_allowed_ptr():
>
> current->flags != PF_NO_SETAFFINITY;
>
> Or am I missing a better way to handle this?
Looking at ref_scale_reader(), ISTM the initial configuration (affinity,
niceness) should be done by its parent thread, not by itself. i.e.:
p = kthread_create(ref_scale_reader);
kthread_bind(p, cpu); // Does the pinning + sets PF_NO_SETAFFINITY
set_user_nice(p, MAX_NICE);
wake_up_process(p);
(kthread_create_on_cpu() is also an option)
From what I can see, torture_create_kthread() immediately wakes the
newly-created kthread, we'd need a version that calls kthread_create()
instead of kthread_run() for the above. Would that be an issue?
>
> Thanx, Paul
next prev parent reply other threads:[~2021-06-11 14:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-10 17:04 Question about a8ea6fc9b089 ("sched: Stop PF_NO_SETAFFINITY from being inherited by various init system threads") Paul E. McKenney
2021-06-10 18:28 ` Valentin Schneider
2021-06-10 20:17 ` Paul E. McKenney
2021-06-11 10:12 ` Valentin Schneider
2021-06-11 13:52 ` Paul E. McKenney
2021-06-11 14:19 ` Valentin Schneider [this message]
2021-06-11 17:10 ` Paul E. McKenney
2021-06-11 12:42 ` Frederic Weisbecker
2021-06-11 17:11 ` Paul E. McKenney
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=87r1h8bi1a.mognet@arm.com \
--to=valentin.schneider@arm.com \
--cc=frederic@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@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.