[PATCH v1] writback: remove WQ_MEM_RECLAIM flag in bdi_wq

hy50.seo posted 1 patch 2 months, 2 weeks ago
mm/backing-dev.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH v1] writback: remove WQ_MEM_RECLAIM flag in bdi_wq
Posted by hy50.seo 2 months, 2 weeks ago
if it write with the write back option with f2fs, kernel panic occurs.
Because the write back function uses bdi_wq and WQ_MEM_RECLAIM flag
is included and created.
However, this function calls f2fs_do_quota() of f2fs and finally tries to
perform quota_release_work.
the quota_release_work is performed in the events_unbound workqueue,
but the WQ_MEM_RECLAIM flag is not included.
Therefore, it causes warn_on_panic.

workqueue: WQ_MEM_RECLAIM writeback:wb_workfn is flushing !WQ_MEM_RECLAIM events_unbound:quota_release_workfn
Workqueue: writeback wb_workfn (flush-8:0)
Call trace:
 check_flush_dependency+0x160/0x16c
 __flush_work+0x168/0x738
 flush_delayed_work+0x58/0x70
 dquot_writeback_dquots+0x90/0x4bc
 f2fs_do_quota_sync+0x120/0x284
 f2fs_write_checkpoint+0x58c/0xe18
 f2fs_gc+0x3e8/0xd78
 f2fs_balance_fs+0x204/0x284
 f2fs_write_single_data_page+0x700/0xaf0
 f2fs_write_data_pages+0xe94/0x15bc
 do_writepages+0x170/0x3f8
 __writeback_single_inode+0xa0/0x8c4
 writeback_sb_inodes+0x2ac/0x708
 __writeback_inodes_wb+0xc0/0x118
 wb_writeback+0x1f4/0x664
 wb_workfn+0x62c/0x900
 process_one_work+0x3f8/0x968
 worker_thread+0x610/0x794
 kthread+0x1c4/0x1e4
 ret_from_fork+0x10/0x20

Signed-off-by: hy50.seo <hy50.seo@samsung.com>
---
 mm/backing-dev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 783904d8c5ef..6ef5f23810fc 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -491,8 +491,7 @@ postcore_initcall(bdi_class_init);
 
 static int __init default_bdi_init(void)
 {
-	bdi_wq = alloc_workqueue("writeback", WQ_MEM_RECLAIM | WQ_UNBOUND |
-				 WQ_SYSFS, 0);
+	bdi_wq = alloc_workqueue("writeback", WQ_UNBOUND | WQ_SYSFS, 0);
 	if (!bdi_wq)
 		return -ENOMEM;
 	return 0;
-- 
2.26.0
Re: [PATCH v1] writback: remove WQ_MEM_RECLAIM flag in bdi_wq
Posted by Christoph Hellwig 2 months, 2 weeks ago
On Mon, Jul 21, 2025 at 03:40:24PM +0900, hy50.seo wrote:
> if it write with the write back option with f2fs, kernel panic occurs.
> Because the write back function uses bdi_wq and WQ_MEM_RECLAIM flag
> is included and created.
> However, this function calls f2fs_do_quota() of f2fs and finally tries to
> perform quota_release_work.
> the quota_release_work is performed in the events_unbound workqueue,
> but the WQ_MEM_RECLAIM flag is not included.

And what makes you assume the WQ_MEM_RECLAIM was added just for fun
and can simply be deleted?
RE: [PATCH v1] writback: remove WQ_MEM_RECLAIM flag in bdi_wq
Posted by hoyoung seo 2 months, 2 weeks ago

> -----Original Message-----
> From: Christoph Hellwig <hch@infradead.org>
> Sent: Monday, July 21, 2025 4:14 PM
> To: hy50.seo <hy50.seo@samsung.com>
> Cc: linux-scsi@vger.kernel.org; linux-kernel@vger.kernel.org;
> alim.akhtar@samsung.com; avri.altman@wdc.com; jejb@linux.ibm.com;
> martin.petersen@oracle.com; beanhuo@micron.com; bvanassche@acm.org;
> kwangwon.min@samsung.com; kwmad.kim@samsung.com; cpgs@samsung.com;
> h10.kim@samsung.com; willdeacon@google.com; jaegeuk@google.com;
> chao@kernel.org; linux-fsdevel@vger.kernel.org
> Subject: Re: [PATCH v1] writback: remove WQ_MEM_RECLAIM flag in bdi_wq
> 
> On Mon, Jul 21, 2025 at 03:40:24PM +0900, hy50.seo wrote:
> > if it write with the write back option with f2fs, kernel panic occurs.
> > Because the write back function uses bdi_wq and WQ_MEM_RECLAIM flag is
> > included and created.
> > However, this function calls f2fs_do_quota() of f2fs and finally tries
> > to perform quota_release_work.
> > the quota_release_work is performed in the events_unbound workqueue,
> > but the WQ_MEM_RECLAIM flag is not included.
> 
> And what makes you assume the WQ_MEM_RECLAIM was added just for fun and
> can simply be deleted?

No way..
It's because i just don't know much about this part.
And WQ_MEM_RECLAIM flag is absolutely necessary.
Because it is necessary for stable write back operation when memory is
insufficient. 
is it right?
I'll find another way for fix bug.
Thanks for your reply.
Re: [PATCH v1] writback: remove WQ_MEM_RECLAIM flag in bdi_wq
Posted by 'Christoph Hellwig' 2 months, 2 weeks ago
On Mon, Jul 21, 2025 at 05:37:03PM +0900, hoyoung seo wrote:
> No way..
> It's because i just don't know much about this part.
> And WQ_MEM_RECLAIM flag is absolutely necessary.

As a rule of thumb try to write an explanation why a change is safe.
That usually kicks of a process to think about the implications.