mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] freezer,sched: Report TASK_FROZEN tasks as TASK_UNINTERRUPTIBLE
@ 2023-10-23 13:57 Liangliang Li
  2023-10-23 16:15 ` Steven Rostedt
  2023-10-24 14:39 ` Peter Zijlstra
  0 siblings, 2 replies; 3+ messages in thread
From: Liangliang Li @ 2023-10-23 13:57 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Daniel Bristot de Oliveira, Valentin Schneider, linux-kernel
  Cc: opensource.kernel, Liangliang Li

TASK_FROZEN is not in TASK_REPORT, thus a frozen task will appear as
state == 0, IOW TASK_RUNNING.

Fix this by make TASK_FROZEN appear as TASK_UNINTERRUPTIBLE, thus we
dont need to imply a new state to userspace tools.

Signed-off-by: Liangliang Li <liliangliang@vivo.com>
---
 include/linux/sched.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 292c31697248..0cfe2ba4fc6f 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1690,6 +1690,10 @@ static inline unsigned int __task_state_index(unsigned int tsk_state,
 	if (tsk_state & TASK_RTLOCK_WAIT)
 		state = TASK_UNINTERRUPTIBLE;
 
+	/* Frozen tasks should appear as "D (disk sleep)' in userspace. */
+	if (tsk_state & TASK_FROZEN)
+		state = TASK_UNINTERRUPTIBLE;
+
 	return fls(state);
 }
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] freezer,sched: Report TASK_FROZEN tasks as TASK_UNINTERRUPTIBLE
  2023-10-23 13:57 [PATCH] freezer,sched: Report TASK_FROZEN tasks as TASK_UNINTERRUPTIBLE Liangliang Li
@ 2023-10-23 16:15 ` Steven Rostedt
  2023-10-24 14:39 ` Peter Zijlstra
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2023-10-23 16:15 UTC (permalink / raw)
  To: Liangliang Li
  Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Ben Segall, Mel Gorman,
	Daniel Bristot de Oliveira, Valentin Schneider, linux-kernel,
	opensource.kernel

On Mon, 23 Oct 2023 21:57:35 +0800
Liangliang Li <liliangliang@vivo.com> wrote:

> TASK_FROZEN is not in TASK_REPORT, thus a frozen task will appear as
> state == 0, IOW TASK_RUNNING.
> 
> Fix this by make TASK_FROZEN appear as TASK_UNINTERRUPTIBLE, thus we
> dont need to imply a new state to userspace tools.
> 

I'm not so sure I agree with this. If anything, it should be reported as
something other than RUNNING or TASK_UNINTERRUPTIBLE, (yes a new state).

The reason I state that, is that tasks may not be the one that sets its
state to FROZEN. A TASK_UNINTERRUPTIBLE is a task that purposely took
itself off the runqueue and is waiting for a response. A FROZEN task did
not necessarily take itself off the run queue, as something else did. It's
more like 'T' than 'D'.

I don't find 'D' any more useful that 'R' for a frozen task. In fact, I
find it even more deceiving.

If you see a task in 'D' that's not running, you will likely look to see
what its blocked on. If it's not blocked on anything, that will be very
confusing. If you see 'R' not running, you can then at least go look to see
why it's not running.

-- Steve


> Signed-off-by: Liangliang Li <liliangliang@vivo.com>
> ---
>  include/linux/sched.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 292c31697248..0cfe2ba4fc6f 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1690,6 +1690,10 @@ static inline unsigned int __task_state_index(unsigned int tsk_state,
>  	if (tsk_state & TASK_RTLOCK_WAIT)
>  		state = TASK_UNINTERRUPTIBLE;
>  
> +	/* Frozen tasks should appear as "D (disk sleep)' in userspace. */
> +	if (tsk_state & TASK_FROZEN)
> +		state = TASK_UNINTERRUPTIBLE;
> +
>  	return fls(state);
>  }
>  


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] freezer,sched: Report TASK_FROZEN tasks as TASK_UNINTERRUPTIBLE
  2023-10-23 13:57 [PATCH] freezer,sched: Report TASK_FROZEN tasks as TASK_UNINTERRUPTIBLE Liangliang Li
  2023-10-23 16:15 ` Steven Rostedt
@ 2023-10-24 14:39 ` Peter Zijlstra
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2023-10-24 14:39 UTC (permalink / raw)
  To: Liangliang Li
  Cc: Ingo Molnar, Juri Lelli, Vincent Guittot, Dietmar Eggemann,
	Steven Rostedt, Ben Segall, Mel Gorman,
	Daniel Bristot de Oliveira, Valentin Schneider, linux-kernel,
	opensource.kernel

On Mon, Oct 23, 2023 at 09:57:35PM +0800, Liangliang Li wrote:
> TASK_FROZEN is not in TASK_REPORT, thus a frozen task will appear as
> state == 0, IOW TASK_RUNNING.
> 
> Fix this by make TASK_FROZEN appear as TASK_UNINTERRUPTIBLE, thus we
> dont need to imply a new state to userspace tools.

Who or what is seeing this and caring about the result?

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-24 14:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-23 13:57 [PATCH] freezer,sched: Report TASK_FROZEN tasks as TASK_UNINTERRUPTIBLE Liangliang Li
2023-10-23 16:15 ` Steven Rostedt
2023-10-24 14:39 ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®