Skip to contentSkip to conversation

make multipathd scheduling configurable

PATCH In review Benjamin Marzinski 2 participants 4 messages Mar 2, 2024 – Mar 4, 2024

Subsystems (2)
lore
Share & tools
lore

Benjamin Marzinski

author maintainer
#0 lore raw

v2 cover make multipathd scheduling configurable

This patchset is based on discussions at:
https://github.com/opensvc/multipath-tools/issues/82

The first patch fixes a condlog logging level, and the second patch makes it possible to turn off realtime scheduling or adjust the priority at compile time. After we do some testing with multipathd not using a realtime policy, I think we can probably change the defaults

Changes from v1 (suggested by Martin Wilck):
02: make scheduling configurable at compile time, instead of by a config
option.

Benjamin Marzinski (2):
multipathd: use condlog level for setscheduler error message
multipathd: make multipathd scheduling configurable

 Makefile.inc        | 6 ++++++
 README.md           | 3 +++
 multipathd/Makefile | 3 +++
 multipathd/main.c   | 7 ++++---
 4 files changed, 16 insertions(+), 3 deletions(-)
Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH v2 1/2 multipathd: use condlog level for setscheduler error message

condlog uses its own log levels, so LOG_WARNING makes no sense. It actually translates to a message sent at the LOG_DEBUG level.

---
 multipathd/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
multipathd/main.c +1 -1
index 6193e691..85ac540f 100644
@@ -3178,7 +3178,7 @@ setscheduler (void)
 	res = sched_setscheduler (0, SCHED_RR, &sched_param);
 
 	if (res == -1)
-		condlog(LOG_WARNING, "Could not set SCHED_RR at priority 99");
+		condlog(2, "Could not set SCHED_RR at priority 99");
 	return;
 }
 
Signature · 1 line
2.43.0
author maintainer
#2 lore raw

PATCH v2 2/2 multipathd: make multipathd scheduling configurable

In reply to Benjamin Marzinski

Currently multipathd always tries to run as a realtime process with a priority of 99. This is excessive. As a first step towards fixing this, make it possible at compile time to lower the priority or keep multipathd from making itself a realtime process.

---
 Makefile.inc        | 6 ++++++
 README.md           | 3 +++
 multipathd/Makefile | 3 +++
 multipathd/main.c   | 5 +++--
 4 files changed, 15 insertions(+), 2 deletions(-)
Makefile.inc +6 -0
index 5668e638..6d206281 100644
@@ -18,6 +18,12 @@ READLINE :=
 # SCSI_DH_MODULES_PRELOAD := scsi_dh_alua scsi_dh_rdac
 SCSI_DH_MODULES_PRELOAD :=
 
+# Multipathd scheduling priority. Set value from 1 to 99 to make multipathd
+# change its scheduling policy to SCHED_RR and its priority to the specified
+# value. set to 0 to stop multipathd from changing the scheduling policy and
+# priority it was started with.
+SCHED_RT_PRIO := 99
+
 EXTRAVERSION := $(shell rev=$$(git rev-parse --short=7 HEAD 2>/dev/null); echo $${rev:+-g$$rev})
 
 # PKG_CONFIG must be read from the environment to enable compilation
README.md +3 -0
index d4f35f57..bb41bf0e 100644
@@ -98,6 +98,9 @@ The following variables can be passed to the `make` command line:
     By default, command line editing is disabled.
     Note that using libreadline may
     [make binary indistributable due to license incompatibility](https://github.com/opensvc/multipath-tools/issues/36).
+ * `SCHED_RT_PRIO={0-99}`: for values {1-99} set the realtime priority
+    multipathd will attempt to run with. for value 0, disable multipathd
+    changing itself to a realtime process.
  * `ENABLE_LIBDMMP=0`: disable building libdmmp
  * `ENABLE_DMEVENTS_POLL=0`: disable support for the device-mapper event
    polling API. For use with pre-5.0 kernels that don't support dmevent polling
multipathd/Makefile +3 -0
index 997b40cf..7300f07a 100644
@@ -57,6 +57,9 @@ $(CLI):  $(CLI_OBJS)
 cli_handlers.o:	cli_handlers.c
 	$(Q)$(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused-parameter -c -o $@ $<
 
+main.o:	main.c
+	$(Q)$(CC) $(CPPFLAGS) -DSCHED_RT_PRIO=$(SCHED_RT_PRIO) $(CFLAGS) -c -o $@ $<
+
 install:
 	$(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir)
 	$(Q)$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)
multipathd/main.c +3 -2
index 85ac540f..9486a8a3 100644
@@ -3172,7 +3172,7 @@ setscheduler (void)
 {
 	int res;
 	static struct sched_param sched_param = {
-		.sched_priority = 99
+		.sched_priority = SCHED_RT_PRIO
 	};
 
 	res = sched_setscheduler (0, SCHED_RR, &sched_param);
@@ -3471,7 +3471,8 @@ child (__attribute__((unused)) void *param)
 	if (!vecs)
 		goto failed;
 
-	setscheduler();
+	if (SCHED_RT_PRIO)
+		setscheduler();
 	set_oom_adj();
 #ifdef FPIN_EVENT_HANDLER
 	if (conf->marginal_pathgroups == MARGINAL_PATHGROUP_FPIN)
Signature · 1 line
2.43.0
Reviewed-by on the v2 series
#3 lore raw
In reply to Benjamin Marzinski
Quoted 18 lines · Benjamin Marzinski

This patchset is based on discussions at:
https://github.com/opensvc/multipath-tools/issues/82

The first patch fixes a condlog logging level, and the second patch makes it possible to turn off realtime scheduling or adjust the priority
at compile time. After we do some testing with multipathd not using a realtime policy, I think we can probably change the defaults

Changes from v1 (suggested by Martin Wilck):
02: make scheduling configurable at compile time, instead of by a config
    option.

Benjamin Marzinski (2):
  multipathd: use condlog level for setscheduler error message
  multipathd: make multipathd scheduling configurable

Quoted 6 lines

 Makefile.inc        | 6 ++++++
 README.md           | 3 +++
 multipathd/Makefile | 3 +++
 multipathd/main.c   | 7 ++++---

 4 files changed, 16 insertions(+), 3 deletions(-)

For the set: