From: Valentin Schneider <vschneid@redhat.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-kernel@vger.kernel.org,
"Eric W. Biederman" <ebiederm@xmission.com>,
Ben Segall <bsegall@google.com>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>, Mel Gorman <mgorman@suse.de>,
Oleg Nesterov <oleg@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@linutronix.de>,
Vincent Guittot <vincent.guittot@linaro.org>
Subject: Re: [PATCH 2/2] sched: Consider task_struct::saved_state in wait_task_inactive().
Date: Tue, 26 Jul 2022 11:18:20 +0100 [thread overview]
Message-ID: <xhsmhsfmodvo3.mognet@vschneid.remote.csb> (raw)
In-Reply-To: <Yt+G/somh8qcKc/R@linutronix.de>
On 26/07/22 08:17, Sebastian Andrzej Siewior wrote:
> On 2022-07-25 18:47:58 [+0100], Valentin Schneider wrote:
>> > --- a/kernel/sched/core.c
>> > +++ b/kernel/sched/core.c
>> > @@ -3257,6 +3257,40 @@ int migrate_swap(struct task_struct *cur
>> > }
>> > #endif /* CONFIG_NUMA_BALANCING */
>> >
>> > +#ifdef CONFIG_PREEMPT_RT
>>
>> Would something like the below be useful?
>>
>> /*
>> * If p->saved_state is anything else than TASK_RUNNING, then p blocked on an
>> * rtlock *before* voluntarily calling into schedule() after setting its state
>> * to X. For things like ptrace (X=TASK_TRACED), the task could have more work
>> * to do upon acquiring the lock before whoever called wait_task_inactive()
>> * should return. IOW, we have to wait for:
>> *
>> * p.saved_state = TASK_RUNNING
>> * p.__state = X
>> *
>> * which implies the task isn't blocked on an RT lock and got to schedule() by
>> * itself.
>> *
>> * Also see comments in ttwu_state_match().
>> */
>
> This sums up the code. I would s/schedule/schedule_rtlock/ since there
> are two entrypoints.
Right, this any better?
/*
* Consider:
*
* set_special_state(X);
*
* do_things()
* // Somewhere in there is an rtlock that can be contended:
* current_save_and_set_rtlock_wait_state();
* [...]
* schedule_rtlock(); (A)
* [...]
* current_restore_rtlock_saved_state();
*
* schedule(); (B)
*
* If p->saved_state is anything else than TASK_RUNNING, then p blocked on an
* rtlock (A) *before* voluntarily calling into schedule() (B) after setting its
* state to X. For things like ptrace (X=TASK_TRACED), the task could have more
* work to do upon acquiring the lock in do_things() before whoever called
* wait_task_inactive() should return. IOW, we have to wait for:
*
* p.saved_state = TASK_RUNNING
* p.__state = X
*
* which implies the task isn't blocked on an RT lock and got to schedule() (B).
*
* Also see comments in ttwu_state_match().
*/
next prev parent reply other threads:[~2022-07-26 10:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-20 15:44 [PATCH 0/2] signal: Last two bits for PREEMPT_RT Sebastian Andrzej Siewior
2022-07-20 15:44 ` [PATCH 1/2] signal: Don't disable preemption in ptrace_stop() on PREEMPT_RT Sebastian Andrzej Siewior
2022-07-20 15:44 ` [PATCH 2/2] sched: Consider task_struct::saved_state in wait_task_inactive() Sebastian Andrzej Siewior
2022-07-25 17:47 ` Valentin Schneider
2022-07-26 6:17 ` Sebastian Andrzej Siewior
2022-07-26 10:18 ` Valentin Schneider [this message]
2022-07-26 13:16 ` [PATCH 2/2 v2] " Sebastian Andrzej Siewior
2022-07-25 15:46 ` [PATCH 0/2] signal: Last two bits for PREEMPT_RT Sebastian Andrzej Siewior
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=xhsmhsfmodvo3.mognet@vschneid.remote.csb \
--to=vschneid@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=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--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.