From: Valentin Schneider <valentin.schneider@arm.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: linux-kernel@vger.kernel.org,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
"Abhijeet Dharmapurikar" <adharmap@quicinc.com>,
"Dietmar Eggemann" <dietmar.eggemann@arm.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Ingo Molnar" <mingo@kernel.org>,
"Vincent Guittot" <vincent.guittot@linaro.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Juri Lelli" <juri.lelli@redhat.com>,
"Daniel Bristot de Oliveira" <bristot@redhat.com>,
"Kees Cook" <keescook@chromium.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Alexey Gladkov" <legion@kernel.org>,
"Kenta.Tada@sony.com" <Kenta.Tada@sony.com>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Ed Tsai" <ed.tsai@mediatek.com>,
linux-api@vger.kernel.org
Subject: Re: [PATCH v2 2/2] sched/tracing: Add TASK_RTLOCK_WAIT to TASK_REPORT
Date: Tue, 18 Jan 2022 17:29:21 +0000 [thread overview]
Message-ID: <878rvd6jgu.mognet@arm.com> (raw)
In-Reply-To: <878rve89cc.fsf@email.froward.int.ebiederm.org>
On 17/01/22 13:12, Eric W. Biederman wrote:
> Valentin Schneider <valentin.schneider@arm.com> writes:
>> --- a/fs/proc/array.c
>> +++ b/fs/proc/array.c
>> @@ -128,9 +128,10 @@ static const char * const task_state_array[] = {
>> "X (dead)", /* 0x10 */
>> "Z (zombie)", /* 0x20 */
>> "P (parked)", /* 0x40 */
>> + "L (rt-locked)", /* 0x80 */
>>
>> /* states beyond TASK_REPORT: */
>> - "I (idle)", /* 0x80 */
>> + "I (idle)", /* 0x100 */
>> };
>
> I think this is at least possibly an ABI break. I have a vague memory
> that userspace is not ready being reported new task states. Which is
> why we encode some of our states the way we do.
>
> Maybe it was just someone being very conservative.
>
> Still if you are going to add new states to userspace and risk breaking
> them can you do some basic analysis and report what ps and similar
> programs do.
>
> Simply changing userspace without even mentioning that you are changing
> the userspace output of proc looks dangerous indeed.
>
Yeah, you're right.
> Looking in the history commit 74e37200de8e ("proc: cleanup/simplify
> get_task_state/task_state_array") seems to best document the concern
> that userspace does not know how to handle new states.
>
Thanks for the sha1 and for digging around. Now, I read
74e37200de8e ("proc: cleanup/simplify get_task_state/task_state_array")
as "get_task_state() isn't clear vs what value is actually exposed to
userspace" rather than "get_task_state() could expose things userspace
doesn't know what to do with".
> The fact we have had a parked state for quite a few years despite that
> concern seems to argue it is possible to extend the states. Or perhaps
> it just argues that parked states are rare enough it does not matter.
>
> It is definitely the case that the ps manpage documents the possible
> states and as such they could be a part of anyone's shell scripts.
>
06eb61844d84 ("sched/debug: Add explicit TASK_IDLE printing") for instance
seems to suggest extending the states OK, but you're right that this then
requires updating ps' manpage.
Alternatively, TASK_RTLOCK_WAIT could be masqueraded as
TASK_(UN)INTERRUPTIBLE when reported to userspace - it is actually somewhat
similar, unlike TASK_IDLE vs TASK_UNINTERRUPTIBLE for instance. The
handling in get_task_state() will be fugly, but it might be preferable over
exposing a detail userspace might not need to be made aware of?
> From the ps man page:
>> Here are the different values that the s, stat and state output
>> specifiers (header "STAT" or "S") will display to describe the
>> state of a process:
>>
>> D uninterruptible sleep (usually IO)
>> I Idle kernel thread
>> R running or runnable (on run queue)
>> S interruptible sleep (waiting for an event to complete)
>> T stopped by job control signal
>> t stopped by debugger during the tracing
>> W paging (not valid since the 2.6.xx kernel)
>> X dead (should never be seen)
>> Z defunct ("zombie") process, terminated but not reaped by its parent
>>
>
> So it looks like a change that adds to the number of states in the
> kernel should update the ps man page as well.
>
> Eric
next prev parent reply other threads:[~2022-01-18 17:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-17 16:46 [PATCH v2 0/2] sched/tracing: sched_switch prev_state reported as TASK_RUNNING when it's not Valentin Schneider
2022-01-17 16:46 ` [PATCH v2 1/2] sched/tracing: Don't re-read p->state when emitting sched_switch event Valentin Schneider
2022-01-17 16:46 ` [PATCH v2 2/2] sched/tracing: Add TASK_RTLOCK_WAIT to TASK_REPORT Valentin Schneider
2022-01-17 19:12 ` Eric W. Biederman
2022-01-18 17:29 ` Valentin Schneider [this message]
2022-01-18 18:10 ` Eric W. Biederman
2022-01-19 18:38 ` Valentin Schneider
2022-01-19 19:13 ` Eric W. Biederman
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=878rvd6jgu.mognet@arm.com \
--to=valentin.schneider@arm.com \
--cc=Kenta.Tada@sony.com \
--cc=adharmap@quicinc.com \
--cc=akpm@linux-foundation.org \
--cc=bigeasy@linutronix.de \
--cc=bristot@redhat.com \
--cc=dietmar.eggemann@arm.com \
--cc=ebiederm@xmission.com \
--cc=ed.tsai@mediatek.com \
--cc=juri.lelli@redhat.com \
--cc=keescook@chromium.org \
--cc=legion@kernel.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rdunlap@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=u.kleine-koenig@pengutronix.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.