Re: [PATCH 1/2] completion: move blk_wait_io to kernel/sched/completion.c

From: Peter Zijlstra
Date: Mon Apr 22 2024 - 07:00:17 EST


On Wed, Apr 17, 2024 at 09:57:04PM -0700, Christoph Hellwig wrote:
> On Wed, Apr 17, 2024 at 08:00:22PM +0200, Mikulas Patocka wrote:
> > > > +EXPORT_SYMBOL(wait_for_completion_long_io);
> > >
> > > Urgh, why is it a sane thing to circumvent the hang check timer?
> >
> > The block layer already does it - the bios can have arbitrary size, so
> > waiting for them takes arbitrary time.
>
> And as mentioned the last few times around, I think we want a task
> state to say that task can sleep long or even forever and not propagate
> this hack even further.

A bit like TASK_NOLOAD (which is used to make TASK_IDLE work), but
different I suppose.

TASK_NOHUNG would be trivial to add ofc. But is it worth it?

Anyway, as per the other email, anything like this needs to come with a
big fat warning. You get to keep the pieces etc..

---
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 3c2abbc587b4..83b25327c233 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -112,7 +112,8 @@ struct user_event_mm;
#define TASK_FREEZABLE 0x00002000
#define __TASK_FREEZABLE_UNSAFE (0x00004000 * IS_ENABLED(CONFIG_LOCKDEP))
#define TASK_FROZEN 0x00008000
-#define TASK_STATE_MAX 0x00010000
+#define TASK_NOHUNG 0x00010000
+#define TASK_STATE_MAX 0x00020000

#define TASK_ANY (TASK_STATE_MAX-1)

diff --git a/kernel/hung_task.c b/kernel/hung_task.c
index b2fc2727d654..126fac835e5e 100644
--- a/kernel/hung_task.c
+++ b/kernel/hung_task.c
@@ -210,7 +210,8 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout)
state = READ_ONCE(t->__state);
if ((state & TASK_UNINTERRUPTIBLE) &&
!(state & TASK_WAKEKILL) &&
- !(state & TASK_NOLOAD))
+ !(state & TASK_NOLOAD) &&
+ !(state & TASK_NOHUNG))
check_hung_task(t, timeout);
}
unlock: