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 to lower the priority keep multipathd from making itself a realtime process. Signed-off-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx> --- libmultipath/config.c | 1 + libmultipath/config.h | 1 + libmultipath/defaults.h | 1 + libmultipath/dict.c | 23 +++++++++++++++++++++++ multipath/multipath.conf.5.in | 13 +++++++++++++ multipathd/main.c | 9 +++++---- 6 files changed, 44 insertions(+), 4 deletions(-) diff --git a/libmultipath/config.c b/libmultipath/config.c index 83fa7369..636200e2 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -932,6 +932,7 @@ int _init_config (const char *file, struct config *conf) conf->ghost_delay = DEFAULT_GHOST_DELAY; conf->all_tg_pt = DEFAULT_ALL_TG_PT; conf->recheck_wwid = DEFAULT_RECHECK_WWID; + conf->sched_prio = DEFAULT_SCHED_PRIO; /* * preload default hwtable */ diff --git a/libmultipath/config.h b/libmultipath/config.h index 384193ab..2e604557 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -203,6 +203,7 @@ struct config { unsigned int sequence_nr; int recheck_wwid; int auto_resize; + int sched_prio; char * selector; struct _vector uid_attrs; diff --git a/libmultipath/defaults.h b/libmultipath/defaults.h index 64b633f2..bd7a09a3 100644 --- a/libmultipath/defaults.h +++ b/libmultipath/defaults.h @@ -59,6 +59,7 @@ #define DEFAULT_AUTO_RESIZE AUTO_RESIZE_NEVER /* Enable no foreign libraries by default */ #define DEFAULT_ENABLE_FOREIGN "NONE" +#define DEFAULT_SCHED_PRIO 99 #define CHECKINT_UNDEF UINT_MAX #define DEFAULT_CHECKINT 5 diff --git a/libmultipath/dict.c b/libmultipath/dict.c index 5af036b7..11df9540 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -1699,6 +1699,28 @@ print_auto_resize(struct strbuf *buff, long v) declare_def_snprint(auto_resize, print_auto_resize) +static int +def_sched_prio_handler(struct config *conf, vector strvec, const char *file, + int line_nr) +{ + char * buff; + + buff = set_value(strvec); + if (!buff) + return 1; + + if (strcmp(buff, "undef") == 0) + conf->sched_prio = 0; + else + do_set_int(strvec, &conf->sched_prio, 1, 99, file, line_nr, + buff); + + free(buff); + return 0; +} + +declare_def_snprint(sched_prio, print_nonzero) + static int hw_vpd_vendor_handler(struct config *conf, vector strvec, const char *file, int line_nr) @@ -2176,6 +2198,7 @@ init_keywords(vector keywords) install_keyword("max_sectors_kb", &def_max_sectors_kb_handler, &snprint_def_max_sectors_kb); install_keyword("ghost_delay", &def_ghost_delay_handler, &snprint_def_ghost_delay); install_keyword("auto_resize", &def_auto_resize_handler, &snprint_def_auto_resize); + install_keyword("sched_prio", &def_sched_prio_handler, &snprint_def_sched_prio); install_keyword("find_multipaths_timeout", &def_find_multipaths_timeout_handler, &snprint_def_find_multipaths_timeout); diff --git a/multipath/multipath.conf.5.in b/multipath/multipath.conf.5.in index c788c180..9c4b4b45 100644 --- a/multipath/multipath.conf.5.in +++ b/multipath/multipath.conf.5.in @@ -1375,6 +1375,19 @@ The default is: \fBno\fR .RE . . +.TP +.B sched_prio +Sets the real-time scheduling priority for multipathd. If set to \fIundef\fR, +multipathd will not attempt to change the scheduling policy or priority it +was started with. If set from \fI1\fR to \fI99\fR, multipathd will set its +scheduling policy to the SCHED_RR real-time round robin policy and set is +priority to the specified value. +.RS +.TP +The default is: \fB99\fR +.RE +. +. .\" ---------------------------------------------------------------------------- .SH "blacklist and blacklist_exceptions sections" .\" ---------------------------------------------------------------------------- diff --git a/multipathd/main.c b/multipathd/main.c index 85ac540f..ab1e6dc3 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -3168,11 +3168,11 @@ signal_init(void) } static void -setscheduler (void) +setscheduler (int sched_prio) { int res; - static struct sched_param sched_param = { - .sched_priority = 99 + struct sched_param sched_param = { + .sched_priority = sched_prio }; res = sched_setscheduler (0, SCHED_RR, &sched_param); @@ -3471,7 +3471,8 @@ child (__attribute__((unused)) void *param) if (!vecs) goto failed; - setscheduler(); + if (conf->sched_prio) + setscheduler(conf->sched_prio); set_oom_adj(); #ifdef FPIN_EVENT_HANDLER if (conf->marginal_pathgroups == MARGINAL_PATHGROUP_FPIN) -- 2.43.0