public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
To: Jens Axboe <axboe@kernel.dk>, Ming Lei <ming.lei@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Dan Schatzberg <schatzberg.dan@gmail.com>,
	Jan Kara <jack@suse.cz>, Christoph Hellwig <hch@lst.de>
Cc: linux-block <linux-block@vger.kernel.org>
Subject: [PATCH] loop: add WQ_MEM_RECLAIM flag to per device workqueue
Date: Thu, 17 Mar 2022 23:08:04 +0900	[thread overview]
Message-ID: <e0a0bc94-e6de-b0e5-ee46-a76cd1570ea6@I-love.SAKURA.ne.jp> (raw)

Commit b5dd2f6047ca1080 ("block: loop: improve performance via blk-mq")
started using a global WQ_MEM_RECLAIM workqueue.

+       loop_wq = alloc_workqueue("kloopd",
+                       WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_UNBOUND, 0);

Commit f4aa4c7bbac6c4af ("block: loop: convert to per-device workqueue")
started using per device WQ_MEM_RECLAIM workqueue.

-       loop_wq = alloc_workqueue("kloopd",
-                       WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_UNBOUND, 0);
+       lo->wq = alloc_workqueue("kloopd%d",
+                       WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_UNBOUND, 0,
+                       lo->lo_number);

Commit 4d4e41aef9429872 ("block: loop: avoiding too many pending per work
I/O") adjusted max_active parameter.

-                       WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_UNBOUND, 0,
+                       WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_UNBOUND, 16,

Commit e03a3d7a94e2485b ("block: loop: use kthread_work") started using
per device kthread.

-       lo->wq = alloc_workqueue("kloopd%d",
-                       WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_UNBOUND, 16,
-                       lo->lo_number);
+       lo->worker_task = kthread_run(kthread_worker_fn,
+                       &lo->worker, "loop%d", lo->lo_number);

Commit 87579e9b7d8dc36e ("loop: use worker per cgroup instead of kworker")
again started using per device workqueue

-       lo->worker_task = kthread_run(loop_kthread_worker_fn,
-                       &lo->worker, "loop%d", lo->lo_number);
+       lo->workqueue = alloc_workqueue("loop%d",
+                                       WQ_UNBOUND | WQ_FREEZABLE,
+                                       0,
+                                       lo->lo_number);

but forgot to restore WQ_MEM_RECLAIM flag.

We should reserve one "struct task_struct" to each loop device in order
to guarantee that I/O request for writeback operation can make forward
progress even under memory pressure. I don't know why WQ_FREEZABLE flag
was added, but let's add WQ_MEM_RECLAIM flag like commit f4aa4c7bbac6c4af
("block: loop: convert to per-device workqueue") describes.

Fixes: 87579e9b7d8dc36e ("loop: use worker per cgroup instead of kworker")
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
 drivers/block/loop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 19fe19eaa50e..60dfebcedd95 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1013,7 +1013,7 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
 		lo->lo_flags |= LO_FLAGS_READ_ONLY;
 
 	lo->workqueue = alloc_workqueue("loop%d",
-					WQ_UNBOUND | WQ_FREEZABLE,
+					WQ_MEM_RECLAIM | WQ_UNBOUND | WQ_FREEZABLE,
 					0,
 					lo->lo_number);
 	if (!lo->workqueue) {
-- 
2.32.0


             reply	other threads:[~2022-03-17 14:08 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-17 14:08 Tetsuo Handa [this message]
2022-03-17 14:38 ` [PATCH] loop: add WQ_MEM_RECLAIM flag to per device workqueue Dan Schatzberg
2022-03-18 12:05   ` Tetsuo Handa
2022-03-18 17:15     ` Tejun Heo
2022-03-19  2:02       ` Tetsuo Handa
2022-03-21 16:55         ` Tejun Heo
2022-03-21 22:53           ` Tetsuo Handa
2022-03-21 23:04             ` Tejun Heo
2022-03-21 23:17               ` Tetsuo Handa
2022-03-21 23:27                 ` Tejun Heo
2022-03-22  0:09                   ` Tetsuo Handa
2022-03-22 16:52                     ` Tejun Heo
2022-03-22 22:00                       ` Dave Chinner
2022-03-22 22:02                         ` Tejun Heo
2022-03-22 22:05                           ` Tetsuo Handa
2022-03-22 22:19                             ` Tejun Heo
2022-03-22 22:59                               ` Dave Chinner
2022-03-22 23:32                                 ` Tetsuo Handa
2022-03-22 23:50                                   ` Dave Chinner
2022-03-23  0:09                                 ` Tejun Heo

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=e0a0bc94-e6de-b0e5-ee46-a76cd1570ea6@I-love.SAKURA.ne.jp \
    --to=penguin-kernel@i-love.sakura.ne.jp \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=schatzberg.dan@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox