diff --git a/doc/man/man1/srun.1 b/doc/man/man1/srun.1 index 11a101c69c20e40d31068d88087f2bc9282b4a9f..cc6b3337883d23c0ffe87cacc4d3b30b237d9582 100644 --- a/doc/man/man1/srun.1 +++ b/doc/man/man1/srun.1 @@ -1,6 +1,6 @@ \." $Id$ .\" -.TH SRUN "1" "March 2003" "srun 0.1" "slurm components" +.TH SRUN "1" "May 2003" "srun 0.1" "slurm components" .SH "NAME" srun \- run parallel jobs .SH SYNOPSIS @@ -88,6 +88,11 @@ will not allocate more than one process per cpu. By specifying per cpu. However no more than \fBMAX_TASKS_PER_NODE\fR tasks are permitted to execute per node. .TP +\fB\-P\fR, \fB\-\-priority\fR=\fIprio\fR +Specify the priority at which the job should execute. This may +only be used to set the priority of a job to zero (which places +the job in a held state) unless the request is issued by user root. +.TP \fB\-T\fR, \fB\-\-threads\fR=\fInthreads\fR Request that .B srun diff --git a/src/slurmctld/job_mgr.c b/src/slurmctld/job_mgr.c index 896f5e5df0effd181f37a54046a8f1a21741d0ff..791a4e8cfad3a6ee313f2a9938d178cd9bfa20f9 100644 --- a/src/slurmctld/job_mgr.c +++ b/src/slurmctld/job_mgr.c @@ -1973,7 +1973,8 @@ static int _validate_job_desc(job_desc_msg_t * job_desc_msg, int allocate, _purge_job_record(job_desc_msg->job_id); } - if (submit_uid != 0) /* only root can set job priority */ + if ((submit_uid != 0) && /* only root can set job priority */ + (job_desc_msg->priority != 0)) job_desc_msg->priority = NO_VAL; if (job_desc_msg->num_procs == NO_VAL) diff --git a/src/slurmctld/job_scheduler.c b/src/slurmctld/job_scheduler.c index 9de3d73e1e97581eb5284c70dc44ea3c67bd61b4..5e0e0f4811fa03ee830854dc0224b13bf67ada3b 100644 --- a/src/slurmctld/job_scheduler.c +++ b/src/slurmctld/job_scheduler.c @@ -130,6 +130,8 @@ int schedule(void) failed_parts = NULL; for (i = 0; i < job_queue_size; i++) { job_ptr = job_queue[i].job_ptr; + if (job_ptr->priority == 0) /* held */ + continue; for (j = 0; j < failed_part_cnt; j++) { if (failed_parts[j] == job_ptr->part_ptr) break; diff --git a/src/srun/allocate.c b/src/srun/allocate.c index ab1c15b7f27fa465cab96c4d0c39ca96065ef1ae..fa5c9b35fc07a1c89837641cc354d794ab66da05 100644 --- a/src/srun/allocate.c +++ b/src/srun/allocate.c @@ -235,6 +235,8 @@ job_desc_msg_create(void) j->num_tasks = opt.nprocs; j->user_id = opt.uid; + if (opt.priority > -1) + j->priority = opt.priority; if (opt.max_nodes) j->max_nodes = opt.max_nodes; if (opt.mincpus > -1) diff --git a/src/srun/opt.c b/src/srun/opt.c index 861df461663f8dfe7d50309438e9ce78f1fd5f34..b77b86ad1cdf8f5c6165666bcf56b3810047e085 100644 --- a/src/srun/opt.c +++ b/src/srun/opt.c @@ -101,6 +101,7 @@ #define OPT_THREADS 0x18 #define OPT_WAIT 0x19 #define OPT_OVERCOMMIT 0x1a +#define OPT_PRIORITY 0x1b /* constraint type options */ #define OPT_MINCPUS 0x50 @@ -182,6 +183,9 @@ struct poptOption runTable[] = { {"partition", 'p', POPT_ARG_STRING, &opt.partition, OPT_PARTITION, "partition requested", "partition"}, + {"priority", 'P', POPT_ARG_INT, &opt.priority, OPT_PRIORITY, + "job priority requested", + "priority"}, {"time", 't', POPT_ARG_INT, &opt.time_limit, OPT_TIME, "time limit", "minutes"}, @@ -577,9 +581,10 @@ static void _opt_default() opt.slurmd_debug = LOG_LEVEL_QUIET; /* constraint default (-1 is no constraint) */ - opt.mincpus = -1; - opt.realmem = -1; - opt.tmpdisk = -1; + opt.priority = -1; + opt.mincpus = -1; + opt.realmem = -1; + opt.tmpdisk = -1; opt.constraints = NULL; opt.contiguous = false; diff --git a/src/srun/opt.h b/src/srun/opt.h index f400cf3ed89a135cde6bcc8862a16f902a95d1ef..179e48b8c20574c7a68a75ca945c028e7e7f12af 100644 --- a/src/srun/opt.h +++ b/src/srun/opt.h @@ -107,6 +107,7 @@ typedef struct srun_options { bool nodes_set; /* true if nodes explicitly set */ int time_limit; /* --time, -t */ char *partition; /* --partition=n, -p n */ + int priority; /* --priority=n, -P n */ enum distribution_t distribution; /* --distribution=, -m dist */ char *job_name; /* --job-name=, -J name */ diff --git a/src/srun/srun.c b/src/srun/srun.c index 2715726ba18f6957c373c5672739240d4618b160..b3a39fe609629512f85451b7aa6f678010ba4cb1 100644 --- a/src/srun/srun.c +++ b/src/srun/srun.c @@ -318,6 +318,8 @@ _run_batch_job(void) job.partition = opt.partition; + if (opt.priority > -1) + job.priority = opt.priority; if (opt.mincpus > -1) job.min_procs = opt.mincpus; if (opt.realmem > -1)