mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Florian Schmaus <flo@geekplace.eu>
To: Kent Overstreet <kent.overstreet@linux.dev>
Cc: Florian Schmaus <flo@geekplace.eu>,
	linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] bcachefs: Set rebalance thread to SCHED_BATCH and nice 19
Date: Thu, 14 Nov 2024 22:06:48 +0100	[thread overview]
Message-ID: <20241114210649.71377-2-flo@geekplace.eu> (raw)
In-Reply-To: <20241114210649.71377-1-flo@geekplace.eu>

Set the rebalance thread's scheduling class to BATCH, which means it
could experience a higher scheduling latency. However, it reduces
preemption events of running threads.

And while the rebalance thread is ually not compute bound, it does
cause a considerable amount of I/O. By increasing its nice level from
0 to 19 we also implicitly reduce the thread's best-effort I/O
scheduling class level from 4 to 7. Therefore, the rebalance thread's
I/O operations will be deprioritized over standard I/O operations.

Signed-off-by: Florian Schmaus <flo@geekplace.eu>
---
 fs/bcachefs/rebalance.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/bcachefs/rebalance.c b/fs/bcachefs/rebalance.c
index 4adc74cd3f70..b26c68007c5a 100644
--- a/fs/bcachefs/rebalance.c
+++ b/fs/bcachefs/rebalance.c
@@ -22,6 +22,7 @@
 
 #include <linux/freezer.h>
 #include <linux/kthread.h>
+#include <linux/sched.h>
 #include <linux/sched/cputime.h>
 
 /* bch_extent_rebalance: */
@@ -662,6 +663,8 @@ int bch2_rebalance_start(struct bch_fs *c)
 	if (ret)
 		return ret;
 
+	sched_set_batch(p, 19);
+
 	get_task_struct(p);
 	rcu_assign_pointer(c->rebalance.thread, p);
 	wake_up_process(p);
-- 
2.45.2


  reply	other threads:[~2024-11-14 21:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-14 21:06 [PATCH 1/2] sched: Provide sched_set_batch() Florian Schmaus
2024-11-14 21:06 ` Florian Schmaus [this message]
2024-11-15  5:43   ` [PATCH 2/2] bcachefs: Set rebalance thread to SCHED_BATCH and nice 19 Kent Overstreet
2024-11-15  8:26     ` Florian Schmaus
2024-11-15 20:42       ` Kent Overstreet
2025-01-14 12:47 [RESEND] Add sched_set_batch() and run bcachefs-rebalance under SCHED_BATCH Florian Schmaus
2025-01-14 12:47 ` [PATCH 2/2] bcachefs: set rebalance thread to SCHED_BATCH and nice 19 Florian Schmaus
2025-01-14 13:29   ` Christian Loehle
2025-01-14 14:40     ` Peter Zijlstra
2025-01-14 15:05       ` Christian Loehle
2025-01-14 15:32       ` Kent Overstreet
2025-01-14 15:19     ` Kent Overstreet
2025-01-14 16:45     ` Florian Schmaus
2025-01-14 14:32   ` Peter Zijlstra
2025-01-14 15:25     ` Kent Overstreet
2025-01-14 16:45       ` Florian Schmaus

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=20241114210649.71377-2-flo@geekplace.eu \
    --to=flo@geekplace.eu \
    --cc=kent.overstreet@linux.dev \
    --cc=linux-bcachefs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®