Re: [PATCH] kernfs: support kernfs notify in memory recliam context

From: Tejun Heo
Date: Tue Nov 14 2023 - 14:06:35 EST


Hello,

On Tue, Nov 14, 2023 at 10:59:47AM -0800, Junxiao Bi wrote:
> kernfs notify is used in write path of md (md_write_start) to wake up
> userspace daemon, like "mdmon" for updating md superblock of imsm raid,
> md write will wait for that update done before issuing the write, if this

How is forward progress guarnateed for that userspace daemon? This sounds
like a really fragile setup.

> write is used for memory reclaim, the system may hung due to kernel notify
> can't be executed, that's because kernel notify is executed by "system_wq"
> which doesn't have a rescuer thread and kworker thread may not be created
> due to memory pressure, then userspace daemon can't be woke up and md write
> will hung.
>
> According Tejun, this can't be fixed by add RECLAIM to "system_wq" because
> that workqueue is shared and someone else might occupy that rescuer thread,
> to fix this from md side, have to replace kernfs notify with other way to
> communite with userspace daemon, that will break userspace interface,
> so use a separated workqueue for kernefs notify to allow it be used in
> memory reclaim context.

I'm not necessarily against the change but please go into a bit more details
on how and why it's structured this way and add a comment explaining
explaining who's depending on kernfs notify for reclaim forward progress.

Thanks.

--
tejun