[PATCH v2 2/2] multipathd: make multipathd scheduling configurable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Signed-off-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx>
---
 Makefile.inc        | 6 ++++++
 README.md           | 3 +++
 multipathd/Makefile | 3 +++
 multipathd/main.c   | 5 +++--
 4 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/Makefile.inc b/Makefile.inc
index 5668e638..6d206281 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -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
diff --git a/README.md b/README.md
index d4f35f57..bb41bf0e 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/multipathd/Makefile b/multipathd/Makefile
index 997b40cf..7300f07a 100644
--- a/multipathd/Makefile
+++ b/multipathd/Makefile
@@ -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)
diff --git a/multipathd/main.c b/multipathd/main.c
index 85ac540f..9486a8a3 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -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)
-- 
2.43.0





[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux