diff --git a/src/plugins/sched/backfill/backfill.c b/src/plugins/sched/backfill/backfill.c index ec1fa9061ffb46b74781cbdc2a0c80547e27f66f..49215b16f9c1aa4a433fa86a9fabc5eee0df1cd9 100644 --- a/src/plugins/sched/backfill/backfill.c +++ b/src/plugins/sched/backfill/backfill.c @@ -64,6 +64,7 @@ #include "src/common/slurm_protocol_api.h" #include "src/common/xmalloc.h" #include "src/common/xstring.h" +#include "src/slurmctld/job_scheduler.h" #include "src/slurmctld/locks.h" #include "src/slurmctld/slurmctld.h" diff --git a/src/plugins/sched/wiki/job_modify.c b/src/plugins/sched/wiki/job_modify.c index 35486df25611c6ac45b854a20dd5bb1471fd47d0..19953c2eff65e9166c9e075b3fb91d7129100a16 100644 --- a/src/plugins/sched/wiki/job_modify.c +++ b/src/plugins/sched/wiki/job_modify.c @@ -37,6 +37,7 @@ #include "./msg.h" #include <strings.h> +#include "src/slurmctld/job_scheduler.h" #include "src/slurmctld/locks.h" #include "src/slurmctld/slurmctld.h" diff --git a/src/plugins/sched/wiki/start_job.c b/src/plugins/sched/wiki/start_job.c index f7cdd46d189ad8b080c780beb3ac794e7a9ca0ee..015fdf4256a3184860f263ba0b3cc9325921f7d5 100644 --- a/src/plugins/sched/wiki/start_job.c +++ b/src/plugins/sched/wiki/start_job.c @@ -39,6 +39,7 @@ #include "src/common/node_select.h" #include "src/common/slurm_protocol_defs.h" #include "src/common/xstring.h" +#include "src/slurmctld/job_scheduler.h" #include "src/slurmctld/locks.h" #include "src/slurmctld/slurmctld.h" #include "src/slurmctld/state_save.h" diff --git a/src/plugins/sched/wiki2/job_modify.c b/src/plugins/sched/wiki2/job_modify.c index 25e1b1aaf862ab78f8560283f8a0fff39ee498a7..a29a6012efc4c7484e2db1ca3f425756940f4e2a 100644 --- a/src/plugins/sched/wiki2/job_modify.c +++ b/src/plugins/sched/wiki2/job_modify.c @@ -37,6 +37,7 @@ #include "./msg.h" #include <strings.h> +#include "src/slurmctld/job_scheduler.h" #include "src/slurmctld/locks.h" #include "src/slurmctld/slurmctld.h" diff --git a/src/plugins/sched/wiki2/start_job.c b/src/plugins/sched/wiki2/start_job.c index b28c7f196f85d800ec9f891ad6a862f1d5e9d53e..97a4156b71e0843dc03bd2adabdfb9cf78ddcb1e 100644 --- a/src/plugins/sched/wiki2/start_job.c +++ b/src/plugins/sched/wiki2/start_job.c @@ -39,6 +39,7 @@ #include "src/common/node_select.h" #include "src/common/slurm_protocol_defs.h" #include "src/common/xstring.h" +#include "src/slurmctld/job_scheduler.h" #include "src/slurmctld/locks.h" #include "src/slurmctld/slurmctld.h" #include "src/slurmctld/state_save.h" diff --git a/src/slurmctld/Makefile.am b/src/slurmctld/Makefile.am index 5852f1e58ea7af94af56011527746e519f28f766..39181b917e79f8bda58e36db13a1f0b974ded8be 100644 --- a/src/slurmctld/Makefile.am +++ b/src/slurmctld/Makefile.am @@ -20,10 +20,12 @@ slurmctld_SOURCES = \ controller.c \ job_mgr.c \ job_scheduler.c \ + job_scheduler.h \ locks.c \ locks.h \ node_mgr.c \ - node_scheduler.c node_scheduler.h \ + node_scheduler.c \ + node_scheduler.h \ partition_mgr.c \ ping_nodes.c \ ping_nodes.h \ diff --git a/src/slurmctld/Makefile.in b/src/slurmctld/Makefile.in index 3d73446210f9a7545640f56875f85a722900d30d..363c513e1dfeaf522f4319c498d69bbfea2ad350 100644 --- a/src/slurmctld/Makefile.in +++ b/src/slurmctld/Makefile.in @@ -278,10 +278,12 @@ slurmctld_SOURCES = \ controller.c \ job_mgr.c \ job_scheduler.c \ + job_scheduler.h \ locks.c \ locks.h \ node_mgr.c \ - node_scheduler.c node_scheduler.h \ + node_scheduler.c \ + node_scheduler.h \ partition_mgr.c \ ping_nodes.c \ ping_nodes.h \ diff --git a/src/slurmctld/agent.c b/src/slurmctld/agent.c index e98a488dd7f0b29c8fc1f831cf76f17a6d38abcf..e8bf2fa39f19e040032e5bb237a33971ee3a91bd 100644 --- a/src/slurmctld/agent.c +++ b/src/slurmctld/agent.c @@ -89,6 +89,7 @@ #include "src/common/uid.h" #include "src/common/forward.h" #include "src/slurmctld/agent.h" +#include "src/slurmctld/job_scheduler.h" #include "src/slurmctld/locks.h" #include "src/slurmctld/ping_nodes.h" #include "src/slurmctld/slurmctld.h" diff --git a/src/slurmctld/agent.h b/src/slurmctld/agent.h index 1ccb6277bd90a6d44443e0556428b681078aedd0..c03b47c15e2ec80f5ccf3789790a68a8194f2196 100644 --- a/src/slurmctld/agent.h +++ b/src/slurmctld/agent.h @@ -42,7 +42,6 @@ #ifndef _AGENT_H #define _AGENT_H -#include "src/slurmctld/agent.h" #include "src/slurmctld/slurmctld.h" #define AGENT_IS_THREAD 1 /* set if agent itself a thread of diff --git a/src/slurmctld/controller.c b/src/slurmctld/controller.c index 16b8d2a4bb3c311d6a02cae00bfe1f394550ab88..93ab07c7c1dfcd01b2d4848b9568e3cd28f59e2b 100644 --- a/src/slurmctld/controller.c +++ b/src/slurmctld/controller.c @@ -79,6 +79,7 @@ #include "src/common/xstring.h" #include "src/slurmctld/agent.h" +#include "src/slurmctld/job_scheduler.h" #include "src/slurmctld/locks.h" #include "src/slurmctld/ping_nodes.h" #include "src/slurmctld/proc_req.h" diff --git a/src/slurmctld/job_mgr.c b/src/slurmctld/job_mgr.c index e9b8abd4e7a7f05980756bb4724d8010355dd608..890c0190f7744b7c2e389bbf9d4297ab47e91a28 100644 --- a/src/slurmctld/job_mgr.c +++ b/src/slurmctld/job_mgr.c @@ -69,6 +69,7 @@ #include "src/common/slurm_protocol_pack.h" #include "src/slurmctld/agent.h" +#include "src/slurmctld/job_scheduler.h" #include "src/slurmctld/locks.h" #include "src/slurmctld/node_scheduler.h" #include "src/slurmctld/proc_req.h" diff --git a/src/slurmctld/job_scheduler.c b/src/slurmctld/job_scheduler.c index 72e5b1e109217f28d8012af78d18cf4eb942478e..9cdf7fd6a1a9bf47b7c25f197a1f71f3b3a37fea 100644 --- a/src/slurmctld/job_scheduler.c +++ b/src/slurmctld/job_scheduler.c @@ -53,6 +53,7 @@ #include "src/common/xstring.h" #include "src/slurmctld/agent.h" +#include "src/slurmctld/job_scheduler.h" #include "src/slurmctld/locks.h" #include "src/slurmctld/node_scheduler.h" #include "src/slurmctld/slurmctld.h" @@ -61,27 +62,17 @@ #define _DEBUG 0 #define MAX_RETRIES 10 -struct job_queue { - struct job_record *job_ptr; - uint32_t job_priority; - uint16_t part_priority; -}; - -static int _build_job_queue(struct job_queue **job_queue); static void _depend_list_del(void *dep_ptr); static void _launch_job(struct job_record *job_ptr); -static void _sort_job_queue(struct job_queue *job_queue, - int job_queue_size); static char **_xduparray(uint16_t size, char ** array); /* - * _build_job_queue - build (non-priority ordered) list of pending jobs + * build_job_queue - build (non-priority ordered) list of pending jobs * OUT job_queue - pointer to job queue * RET number of entries in job_queue - * global: job_list - global list of job records * NOTE: the buffer at *job_queue must be xfreed by the caller */ -static int _build_job_queue(struct job_queue **job_queue) +extern int build_job_queue(struct job_queue **job_queue) { ListIterator job_iterator; struct job_record *job_ptr = NULL; @@ -189,14 +180,12 @@ extern void set_job_elig_time(void) * pending jobs for each partition will be scheduled in priority * order until a request fails * RET count of jobs scheduled - * global: job_list - global list of job records - * last_job_update - time of last update to job table * Note: We re-build the queue every time. Jobs can not only be added * or removed from the queue, but have their priority or partition * changed with the update_job RPC. In general nodes will be in priority * order (by submit time), so the sorting should be pretty fast. */ -int schedule(void) +extern int schedule(void) { struct job_queue *job_queue; int i, j, error_code, failed_part_cnt, job_queue_size, job_cnt = 0; @@ -232,12 +221,12 @@ int schedule(void) return SLURM_SUCCESS; } debug("Running job scheduler"); - job_queue_size = _build_job_queue(&job_queue); + job_queue_size = build_job_queue(&job_queue); if (job_queue_size == 0) { unlock_slurmctld(job_write_lock); return SLURM_SUCCESS; } - _sort_job_queue(job_queue, job_queue_size); + sort_job_queue(job_queue, job_queue_size); failed_part_cnt = 0; failed_parts = NULL; @@ -324,11 +313,11 @@ int schedule(void) /* - * _sort_job_queue - sort job_queue in decending priority order + * sort_job_queue - sort job_queue in decending priority order * IN job_queue_size - count of elements in the job queue * IN/OUT job_queue - pointer to sorted job queue */ -static void _sort_job_queue(struct job_queue *job_queue, int job_queue_size) +extern void sort_job_queue(struct job_queue *job_queue, int job_queue_size) { int i, j, top_prio_inx; struct job_record *tmp_job_ptr; diff --git a/src/slurmctld/job_scheduler.h b/src/slurmctld/job_scheduler.h new file mode 100644 index 0000000000000000000000000000000000000000..70268735c4cce3dbd21d647923bb4d953c6b9b71 --- /dev/null +++ b/src/slurmctld/job_scheduler.h @@ -0,0 +1,129 @@ +/*****************************************************************************\ + * job_scheduler.h - data structures and function definitions for scheduling + * of pending jobs in priority order + ***************************************************************************** + * Copyright (C) 2002-2006 The Regents of the University of California. + * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). + * Written by Morris Jette <jette@llnl.gov>, et. al. + * Derived from dsh written by Jim Garlick <garlick1@llnl.gov> + * UCRL-CODE-226842. + * + * This file is part of SLURM, a resource management program. + * For details, see <http://www.llnl.gov/linux/slurm/>. + * + * SLURM is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * In addition, as a special exception, the copyright holders give permission + * to link the code of portions of this program with the OpenSSL library under + * certain conditions as described in each individual source file, and + * distribute linked combinations including the two. You must obey the GNU + * General Public License in all respects for all of the code used other than + * OpenSSL. If you modify file(s) with this exception, you may extend this + * exception to your version of the file(s), but you are not obligated to do + * so. If you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files in + * the program, then also delete it here. + * + * SLURM is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along + * with SLURM; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +\*****************************************************************************/ + +#ifndef _JOB_SCHEDULER_H +#define _JOB_SCHEDULER_H + +#include "src/slurmctld/slurmctld.h" + +struct job_queue { + struct job_record *job_ptr; + uint32_t job_priority; + uint16_t part_priority; +}; + +/* + * build_job_queue - build (non-priority ordered) list of pending jobs + * OUT job_queue - pointer to job queue + * RET number of entries in job_queue + * NOTE: the buffer at *job_queue must be xfreed by the caller + */ +extern int build_job_queue(struct job_queue **job_queue); + +/* + * job_is_completing - Determine if jobs are in the process of completing. + * RET - True of any job is in the process of completing + * NOTE: This function can reduce resource fragmentation, which is a + * critical issue on Elan interconnect based systems. + */ + +extern bool job_is_completing(void); + +/* Determine if a pending job will run using only the specified nodes + * (in job_desc_msg->req_nodes), build response message and return + * SLURM_SUCCESS on success. Otherwise return an error code. Caller + * must free response message */ +extern int job_start_data(job_desc_msg_t *job_desc_msg, + will_run_response_msg_t **resp); + +/* + * make_batch_job_cred - add a job credential to the batch_job_launch_msg + * IN/OUT launch_msg_ptr - batch_job_launch_msg in which job_id, step_id, + * uid and nodes have already been set + * RET 0 or error code + */ +extern int make_batch_job_cred(batch_job_launch_msg_t *launch_msg_ptr); + +/* Print a job's dependency information based upon job_ptr->depend_list */ +extern void print_job_dependency(struct job_record *job_ptr); + +/* + * schedule - attempt to schedule all pending jobs + * pending jobs for each partition will be scheduled in priority + * order until a request fails + * RET count of jobs scheduled + * Note: We re-build the queue every time. Jobs can not only be added + * or removed from the queue, but have their priority or partition + * changed with the update_job RPC. In general nodes will be in priority + * order (by submit time), so the sorting should be pretty fast. + */ +extern int schedule(void); + +/* + * set_job_elig_time - set the eligible time for pending jobs once their + * dependencies are lifted (in job->details->begin_time) + */ +extern void set_job_elig_time(void); + +/* + * sort_job_queue - sort job_queue in decending priority order + * IN job_queue_size - count of elements in the job queue + * IN/OUT job_queue - pointer to sorted job queue + */ +extern void sort_job_queue(struct job_queue *job_queue, int job_queue_size); + +/* + * Determine if a job's dependencies are met + * RET: 0 = no dependencies + * 1 = dependencies remain + * 2 = failure (job completion code not per dependency), delete the job + */ +extern int test_job_dependency(struct job_record *job_ptr); + +/* + * Parse a job dependency string and use it to establish a "depend_spec" + * list of dependencies. We accept both old format (a single job ID) and + * new format (e.g. "afterok:123:124,after:128"). + * IN job_ptr - job record to have dependency and depend_list updated + * IN new_depend - new dependency description + * RET returns an error code from slurm_errno.h + */ +extern int update_job_dependency(struct job_record *job_ptr, char *new_depend); + +#endif /* !_JOB_SCHEDULER_H */ diff --git a/src/slurmctld/node_scheduler.c b/src/slurmctld/node_scheduler.c index b51fdea162be11ba14ab917369e45440426b687b..6c06d4d896df22add634d67cd198d4ec699d3ba3 100644 --- a/src/slurmctld/node_scheduler.c +++ b/src/slurmctld/node_scheduler.c @@ -1161,7 +1161,7 @@ extern int job_req_node_filter(struct job_record *job_ptr, multi_core_data_t *mc_ptr; struct node_record *node_ptr; struct config_record *config_ptr; - bitstr_t *feature_bitmap; + bitstr_t *feature_bitmap = NULL; if (detail_ptr == NULL) { error("job_req_node_filter: job %u has no details", diff --git a/src/slurmctld/proc_req.c b/src/slurmctld/proc_req.c index a469e75460ee1f59df1c7db593b242bc4cb7e008..aa23dd722a8fc5af11f3c783fcb8ab98bb5a423b 100644 --- a/src/slurmctld/proc_req.c +++ b/src/slurmctld/proc_req.c @@ -71,6 +71,7 @@ #include "src/common/forward.h" #include "src/slurmctld/agent.h" +#include "src/slurmctld/job_scheduler.h" #include "src/slurmctld/locks.h" #include "src/slurmctld/proc_req.h" #include "src/slurmctld/read_config.h" diff --git a/src/slurmctld/read_config.c b/src/slurmctld/read_config.c index 346b62925eb0da74123fbba52db9a605861617ea..8a8d3956ab1eaa6c63f6af15629a5b2cc499980f 100644 --- a/src/slurmctld/read_config.c +++ b/src/slurmctld/read_config.c @@ -68,6 +68,7 @@ #include "src/common/slurm_jobacct_storage.h" #include "src/common/slurm_rlimits_info.h" +#include "src/slurmctld/job_scheduler.h" #include "src/slurmctld/locks.h" #include "src/slurmctld/node_scheduler.h" #include "src/slurmctld/proc_req.h" diff --git a/src/slurmctld/slurmctld.h b/src/slurmctld/slurmctld.h index 76783be10a2f013dd30b6ef5bf34a9b32d98df13..672273bbf226f0a161c8e219e27822f2fd4ef053 100644 --- a/src/slurmctld/slurmctld.h +++ b/src/slurmctld/slurmctld.h @@ -789,14 +789,6 @@ extern int job_end_time(job_alloc_info_msg_t *time_req_msg, /* job_fini - free all memory associated with job records */ extern void job_fini (void); -/* - * job_is_completing - Determine if jobs are in the process of completing. - * RET - True of any job is in the process of completing - * NOTE: This function can reduce resource fragmentation, which is a - * critical issue on Elan interconnect based systems. - */ -extern bool job_is_completing(void); - /* * job_fail - terminate a job due to initiation failure * IN job_id - id of the job to be killed @@ -951,13 +943,6 @@ extern int job_step_signal(uint32_t job_id, uint32_t step_id, */ extern void job_time_limit (void); -/* Determine if a pending job will run using only the specified nodes - * (in job_desc_msg->req_nodes), build response message and return - * SLURM_SUCCESS on success. Otherwise return an error code. Caller - * must free response message */ -extern int job_start_data(job_desc_msg_t *job_desc_msg, - will_run_response_msg_t **resp); - /* * kill_job_by_part_name - Given a partition name, deallocate resource for * its jobs and kill them @@ -1041,14 +1026,6 @@ extern int load_all_part_state ( void ); */ extern int load_step_state(struct job_record *job_ptr, Buf buffer); -/* - * make_batch_job_cred - add a job credential to the batch_job_launch_msg - * IN/OUT launch_msg_ptr - batch_job_launch_msg in which job_id, step_id, - * uid and nodes have already been set - * RET 0 or error code - */ -extern int make_batch_job_cred(batch_job_launch_msg_t *launch_msg_ptr); - /* make_node_alloc - flag specified node as allocated to a job * IN node_ptr - pointer to node being allocated * IN job_ptr - pointer to job that is starting @@ -1204,9 +1181,6 @@ extern void part_filter_set(uid_t uid); /* part_fini - free all memory associated with partition records */ void part_fini (void); -/* Print a job's dependency information based upon job_ptr->depend_list */ -extern void print_job_dependency(struct job_record *job_ptr); - /* * purge_old_job - purge old job records. * the jobs must have completed at least MIN_JOB_AGE minutes ago @@ -1261,26 +1235,6 @@ extern void run_backup(void); /* save_all_state - save entire slurmctld state for later recovery */ extern void save_all_state(void); -/* - * schedule - attempt to schedule all pending jobs - * pending jobs for each partition will be scheduled in priority - * order until a request fails - * RET count of jobs scheduled - * global: job_list - global list of job records - * last_job_update - time of last update to job table - * Note: We re-build the queue every time. Jobs can not only be added - * or removed from the queue, but have their priority or partition - * changed with the update_job RPC. In general nodes will be in priority - * order (by submit time), so the sorting should be pretty fast. - */ -extern int schedule (void); - -/* - * set_job_elig_time - set the eligible time for pending jobs once their - * dependencies are lifted (in job->details->begin_time) - */ -extern void set_job_elig_time(void); - /* * set_node_down - make the specified node's state DOWN if possible * (not in a DRAIN state), kill jobs as needed @@ -1391,14 +1345,6 @@ extern void suspend_job_step(struct job_record *job_ptr); */ extern int sync_job_files(void); -/* - * Determine if a job's dependencies are met - * RET: 0 = no dependencies - * 1 = dependencies remain - * 2 = failure (job completion code not per dependency), delete the job - */ -extern int test_job_dependency(struct job_record *job_ptr); - /* * update_job - update a job's parameters per the supplied specifications * IN job_specs - a job's specification @@ -1409,16 +1355,6 @@ extern int test_job_dependency(struct job_record *job_ptr); */ extern int update_job (job_desc_msg_t * job_specs, uid_t uid); -/* - * Parse a job dependency string and use it to establish a "depend_spec" - * list of dependencies. We accept both old format (a single job ID) and - * new format (e.g. "afterok:123:124,after:128"). - * IN job_ptr - job record to have dependency and depend_list updated - * IN new_depend - new dependency description - * RET returns an error code from slurm_errno.h - */ -extern int update_job_dependency(struct job_record *job_ptr, char *new_depend); - /* Reset nodes_completing field for all jobs */ extern void update_job_nodes_completing(void);