diff --git a/NEWS b/NEWS index 86ce77a67338782b8f4e2a7bad55970fc3f7eee2..9b4dfe666effb5357b74ef3009d0386feb2212e4 100644 --- a/NEWS +++ b/NEWS @@ -24,8 +24,8 @@ documents those changes that are of interest to users and admins. partitions. -- Added sacctmgr list events which will list events that have happened on clusters in accounting. - -- Add support for slurmctld and slurmd option of "-n <value>" to reset the - daemon's nice value. + -- Add support in slurmctld, slurmd ans slurmdbd for option of "-n <value>" to + reset the daemon's nice value. -- Permit a running job to shrink in size using a command of "scontrol update JobId=# NumNodes=#" or "scontrol update JobId=# NodeList=<names>". Subsequent job steps must diff --git a/doc/man/man8/slurmdbd.8 b/doc/man/man8/slurmdbd.8 index df8725ada3c26895940aa39544c5102fde3b1279..9e881e7fb10a163ea06cde305a9e12639d59e88f 100644 --- a/doc/man/man8/slurmdbd.8 +++ b/doc/man/man8/slurmdbd.8 @@ -1,4 +1,4 @@ -.TH slurmdbd "8" "February 2008" "slurmdbd 2.0" "Slurm components" +.TH slurmdbd "8" "March 2010" "slurmdbd 2.2" "Slurm components" .SH "NAME" slurmdbd \- Slurm Database Daemon. @@ -17,6 +17,9 @@ Debug mode. Execute \fBslurmdbd\fR in the foreground with logging to stdout. \fB\-h\fR Help; print a brief summary of command options. .TP +\fB\-n <value>\fR +Set the daemon's nice value to the specified value, typically a negative number. +.TP \fB\-v\fR Verbose operation. Multiple \fB\-v\fR's increase verbosity. .TP diff --git a/src/slurmctld/controller.c b/src/slurmctld/controller.c index 8c079d3ad52bc0a8fb5b01cc2407b5c386b033c7..511ced7dcc8bcc6f2e7f953041c82d3fdf76a1c4 100644 --- a/src/slurmctld/controller.c +++ b/src/slurmctld/controller.c @@ -1518,8 +1518,11 @@ static void _parse_commandline(int argc, char *argv[]) break; case 'n': new_nice = strtol(optarg, &tmp_char, 10); - if (tmp_char[0] != '\0') - new_nice = NO_VAL; + if (tmp_char[0] != '\0') { + error("Invalid option for -n option (nice " + "value), ignored"); + new_nice = 0; + } break; case 'r': recover = 1; @@ -1565,6 +1568,8 @@ static void _usage(char *prog_name) "\tPrint this help message.\n"); fprintf(stderr, " -L logfile " "\tLog messages to the specified file.\n"); + fprintf(stderr, " -n value " + "\tRun the daemon at the specified nice value.\n"); #if (DEFAULT_RECOVER == 0) fprintf(stderr, " -r " "\tRecover state from last checkpoint.\n"); @@ -1691,10 +1696,8 @@ static void _update_nice(void) int cur_nice; id_t pid; - if (new_nice == NO_VAL) { - error("Invalid option for -n option (nice value), ignored"); + if (new_nice == 0) /* No change */ return; - } pid = getpid(); cur_nice = getpriority(PRIO_PROCESS, pid); diff --git a/src/slurmd/slurmd/slurmd.c b/src/slurmd/slurmd/slurmd.c index 977debbb93752b65342e508afb03417b9363efef..7859c6504e28d20731b8fcd98e7d5c5410c70509 100644 --- a/src/slurmd/slurmd/slurmd.c +++ b/src/slurmd/slurmd/slurmd.c @@ -1060,8 +1060,11 @@ _process_cmdline(int ac, char **av) break; case 'n': conf->nice = strtol(optarg, &tmp_char, 10); - if (tmp_char[0] != '\0') - conf->nice = NO_VAL; + if (tmp_char[0] != '\0') { + error("Invalid option for -n option (nice " + "value), ignored"); + conf->nice = 0; + } break; case 'N': conf->node_name = xstrdup(optarg); @@ -1420,6 +1423,7 @@ Usage: %s [OPTIONS]\n\ -h Print this help message.\n\ -f config Read configuration from the specified file.\n\ -L logfile Log messages to the file `logfile'.\n\ + -n value Run the daemon at the specified nice value.\n\ -v Verbose mode. Multiple -v's increase verbosity.\n\ -V Print version information and exit.\n", conf->prog); return; @@ -1516,10 +1520,8 @@ static void _update_nice(void) int cur_nice; id_t pid; - if (conf->nice == NO_VAL) { - error("Invalid option for -n option (nice value), ignored"); + if (conf->nice == 0) /* No change */ return; - } pid = getpid(); cur_nice = getpriority(PRIO_PROCESS, pid); diff --git a/src/slurmdbd/slurmdbd.c b/src/slurmdbd/slurmdbd.c index 7259870e894a21810c4b1bdc00945a4b3e49710a..0d76cd042bdc02a1aa6b14fb9c6a85ed7ef1aef8 100644 --- a/src/slurmdbd/slurmdbd.c +++ b/src/slurmdbd/slurmdbd.c @@ -78,6 +78,7 @@ static int debug_level = 0; /* incremented for -v on command line */ static int foreground = 0; /* run process as a daemon */ static log_options_t log_opts = /* Log to stderr & syslog */ LOG_OPTS_INITIALIZER; +static int new_nice = 0; static pthread_t rpc_handler_thread; /* thread ID for RPC hander */ static pthread_t signal_handler_thread; /* thread ID for signal hander */ static pthread_t rollup_handler_thread; /* thread ID for rollup hander */ @@ -96,6 +97,7 @@ static void _rollup_handler_cancel(); static void *_rollup_handler(void *no_data); static void *_signal_handler(void *no_data); static void _update_logging(void); +static void _update_nice(void); static void _usage(char *prog_name); /* main - slurmctld main function, start various threads and process RPCs */ @@ -112,6 +114,7 @@ int main(int argc, char *argv[]) exit(1); _parse_commandline(argc, argv); _update_logging(); + _update_nice(); if (slurm_auth_init(NULL) != SLURM_SUCCESS) { fatal("Unable to initialize %s authentication plugin", @@ -291,9 +294,10 @@ static void _init_config(void) static void _parse_commandline(int argc, char *argv[]) { int c = 0; + char *tmp_char; opterr = 0; - while ((c = getopt(argc, argv, "DhvV")) != -1) + while ((c = getopt(argc, argv, "Dhn:vV")) != -1) switch (c) { case 'D': foreground = 1; @@ -302,6 +306,14 @@ static void _parse_commandline(int argc, char *argv[]) _usage(argv[0]); exit(0); break; + case 'n': + new_nice = strtol(optarg, &tmp_char, 10); + if (tmp_char[0] != '\0') { + error("Invalid option for -n option (nice " + "value), ignored"); + new_nice = 0; + } + break; case 'v': debug_level++; break; @@ -324,6 +336,8 @@ static void _usage(char *prog_name) "Run daemon in foreground.\n"); fprintf(stderr, " -h \t" "Print this help message.\n"); + fprintf(stderr, " -n value \t" + "Run the daemon at the specified nice value.\n"); fprintf(stderr, " -v \t" "Verbose mode. Multiple -v's increase verbosity.\n"); fprintf(stderr, " -V \t" @@ -355,6 +369,23 @@ static void _update_logging(void) log_alter(log_opts, SYSLOG_FACILITY_DAEMON, slurmdbd_conf->log_file); } +/* Reset slurmd nice value */ +static void _update_nice(void) +{ + int cur_nice; + id_t pid; + + if (new_nice == 0) /* No change */ + return; + + pid = getpid(); + cur_nice = getpriority(PRIO_PROCESS, pid); + if (cur_nice == new_nice) + return; + if (setpriority(PRIO_PROCESS, pid, new_nice)) + error("Unable to reset nice value to %d: %m", new_nice); +} + /* Kill the currently running slurmdbd */ static void _kill_old_slurmdbd(void) {