diff --git a/Makefile.inc b/Makefile.inc index 5668e6385..6d206281c 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 d4f35f57c..bb41bf0e8 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 997b40cfd..7300f07aa 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 85ac540fb..9486a8a33 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)