/*  Return true if the preemptor can preempt the preemptee, otherwise false */
static bool _job_prio_preemptable(struct job_record *preemptor,
				  struct job_record *preemptee)
{
	uint32_t job_prio1, job_prio2;
	int rc;

	if (CHECK_FOR_PREEMPTOR_OVERALLOC) {
		rc = _overalloc_test(preemptor, preemptee);
		if (rc > 0)
			return true;
		else if (rc < 0)
			return false;
	}

	job_prio1 = preemptor->priority;
	job_prio2 = preemptee->priority;

	if (job_prio1 > job_prio2) {
		if (slurm_get_debug_flags() & DEBUG_FLAG_PRIO) {
    			info("%s: Priority of JobId %u > JobId %u (%u > %u)",
			     plugin_type, preemptor->job_id, preemptee->job_id,
			     job_prio1, job_prio2);
		}
		return true;	/* Preemptor can preempt */
	} else {
		if (slurm_get_debug_flags() & DEBUG_FLAG_PRIO) {
    			info("%s: Priority of JobId %u <= JobId %u (%u <= %u)",
			     plugin_type, preemptor->job_id, preemptee->job_id,
			     job_prio1, job_prio2);
		}
		return false;	/* Preemptor can not preempt */
	}
}
/* Return true of the cummulative run time of job1 is greater than job 2 */
static bool _is_job_runtime_greater(struct job_record *job_ptr1,
				    struct job_record *job_ptr2)
{
	time_t runtime_job1, runtime_job2;
	double timediff_job1_job2 = 0.0;

	runtime_job1 = _get_job_runtime(job_ptr1);
	runtime_job2 = _get_job_runtime(job_ptr2);
	timediff_job1_job2 = difftime(runtime_job1, runtime_job2);

	if (timediff_job1_job2 > 0) {
		if (slurm_get_debug_flags() & DEBUG_FLAG_PRIO) {
			info("%s: Runtime of JobId %u > JobId %u (%u > %u)",
			     plugin_type, job_ptr1->job_id, job_ptr2->job_id,
			     (uint32_t) runtime_job1, (uint32_t) runtime_job2);
		}
		return true;
	} else {
		if (slurm_get_debug_flags() & DEBUG_FLAG_PRIO) {
			info("%s: Runtime of JobId %u <= JobId %u (%u <= %u)",
			     plugin_type, job_ptr1->job_id, job_ptr2->job_id,
			     (uint32_t) runtime_job1, (uint32_t) runtime_job2);
		}
		return false;
	}
}
示例#3
0
文件: sicp.c 项目: rohgarg/slurm
extern void *_sicp_agent(void *args)
{
    static time_t last_sicp_time = 0;
    time_t now;
    double wait_time;

    while (!sicp_stop) {
        _my_sleep(1);
        if (sicp_stop)
            break;

        now = time(NULL);
        wait_time = difftime(now, last_sicp_time);
        if (wait_time < sicp_interval)
            continue;
        last_sicp_time = now;

        _load_sicp_other_cluster();

        pthread_mutex_lock(&sicp_lock);
        list_delete_all(sicp_job_list, &_list_find_sicp_old, "");
        if (slurm_get_debug_flags() & DEBUG_FLAG_SICP)
            _log_sicp_recs();
        pthread_mutex_unlock(&sicp_lock);

        _dump_sicp_state();	/* Has own locking */
    }
    return NULL;
}
示例#4
0
extern void msg_aggr_sender_init(char *host, uint16_t port, uint64_t window,
				 uint64_t max_msg_cnt)
{
	if (msg_collection.running || (max_msg_cnt <= 1))
		return;

	memset(&msg_collection, 0, sizeof(msg_collection_type_t));

	slurm_mutex_init(&msg_collection.aggr_mutex);
	slurm_mutex_init(&msg_collection.mutex);

	slurm_mutex_lock(&msg_collection.mutex);
	slurm_mutex_lock(&msg_collection.aggr_mutex);
	slurm_cond_init(&msg_collection.cond, NULL);
	slurm_set_addr(&msg_collection.node_addr, port, host);
	msg_collection.window = window;
	msg_collection.max_msg_cnt = max_msg_cnt;
	msg_collection.msg_aggr_list = list_create(_msg_aggr_free);
	msg_collection.msg_list = list_create(slurm_free_comp_msg_list);
	msg_collection.max_msgs = false;
	msg_collection.debug_flags = slurm_get_debug_flags();
	slurm_mutex_unlock(&msg_collection.aggr_mutex);
	slurm_mutex_unlock(&msg_collection.mutex);

	slurm_thread_create(&msg_collection.thread_id,
			    &_msg_aggregation_sender, NULL);
}
示例#5
0
static void _load_config(void)
{
    char *sched_params, *tmp_ptr;

    sched_params = slurm_get_sched_params();
    debug_flags  = slurm_get_debug_flags();

    if (sched_params && (tmp_ptr=strstr(sched_params, "interval=")))
        backfill_interval = atoi(tmp_ptr + 9);
    if (backfill_interval < 1) {
        fatal("Invalid backfill scheduler interval: %d",
              backfill_interval);
    }

    if (sched_params && (tmp_ptr=strstr(sched_params, "bf_window=")))
        backfill_window = atoi(tmp_ptr + 10) * 60;  /* mins to secs */
    if (backfill_window < 1) {
        fatal("Invalid backfill scheduler window: %d",
              backfill_window);
    }
    if (sched_params && (tmp_ptr=strstr(sched_params, "max_job_bf=")))
        max_backfill_job_cnt = atoi(tmp_ptr + 11);
    if (max_backfill_job_cnt < 1) {
        fatal("Invalid backfill scheduler max_job_bf: %d",
              max_backfill_job_cnt);
    }
    xfree(sched_params);
}
示例#6
0
extern int acct_gather_energy_p_set_data(enum acct_energy_type data_type,
					 void *data)
{
	int rc = SLURM_SUCCESS;
	int *delta = (int *)data;

	xassert(_run_in_daemon());

	switch (data_type) {
	case ENERGY_DATA_RECONFIG:
		debug_flags = slurm_get_debug_flags();
		break;
	case ENERGY_DATA_PROFILE:
		slurm_mutex_lock(&ipmi_mutex);
		_get_joules_task(*delta);
		_ipmi_send_profile();
		slurm_mutex_unlock(&ipmi_mutex);
		break;
	default:
		error("acct_gather_energy_p_set_data: unknown enum %d",
		      data_type);
		rc = SLURM_ERROR;
		break;
	}
	return rc;
}
示例#7
0
/*
 * init() is called when the plugin is loaded, before any other functions
 * are called.  Put global initialization here.
 */
extern int init ( void )
{
	verbose("%s loaded", plugin_name);
	debug_flags = slurm_get_debug_flags();

	return SLURM_SUCCESS;
}
示例#8
0
文件: msg.c 项目: IFCA/slurm
/*****************************************************************************\
 * Read a message (request) from specified file descriptor
 *
 * RET - The message which must be xfreed or
 *       NULL on error
\*****************************************************************************/
static char *	_recv_msg(slurm_fd_t new_fd)
{
	char header[10];
	unsigned long size;
	char *buf;

	if (_read_bytes((int) new_fd, header, 9) != 9) {
		err_code = -240;
		err_msg = "failed to read message header";
		error("wiki: failed to read message header %m");
		return NULL;
	}

	if (sscanf(header, "%lu", &size) != 1) {
		err_code = -244;
		err_msg = "malformed message header";
		error("wiki: malformed message header (%s)", header);
		return NULL;
	}

	buf = xmalloc(size + 1);	/* need '\0' on end to print */
	if (_read_bytes((int) new_fd, buf, size) != size) {
		err_code = -246;
		err_msg = "unable to read all message data";
		error("wiki: unable to read data message");
		xfree(buf);
		return NULL;
	}

	if (slurm_get_debug_flags() & DEBUG_FLAG_WIKI)
		info("wiki msg recv:%s", buf);

	return buf;
}
示例#9
0
static void _internal_setup(void)
{
	if (slurm_get_debug_flags() & DEBUG_FLAG_PRIO)
		priority_debug = 1;
	else
		priority_debug = 0;

	favor_small = slurm_get_priority_favor_small();

	max_age = slurm_get_priority_max_age();
	weight_age = slurm_get_priority_weight_age();
	weight_fs = slurm_get_priority_weight_fairshare();
	weight_js = slurm_get_priority_weight_job_size();
	weight_part = slurm_get_priority_weight_partition();
	weight_qos = slurm_get_priority_weight_qos();
	flags = slurmctld_conf.priority_flags;

	if (priority_debug) {
		info("priority: Max Age is %u", max_age);
		info("priority: Weight Age is %u", weight_age);
		info("priority: Weight Fairshare is %u", weight_fs);
		info("priority: Weight JobSize is %u", weight_js);
		info("priority: Weight Part is %u", weight_part);
		info("priority: Weight QOS is %u", weight_qos);
		info("priority: Flags is %u", flags);
	}
}
示例#10
0
文件: common_jag.c 项目: npe9/slurm
extern void jag_common_init(long in_hertz)
{
	uint32_t profile_opt;

	debug_flags = slurm_get_debug_flags();

	acct_gather_profile_g_get(ACCT_GATHER_PROFILE_RUNNING,
				  &profile_opt);
	/* If we are profiling energy it will be checked at a
	   different rate, so just grab the last one.
	*/
	if (profile_opt & ACCT_GATHER_PROFILE_ENERGY)
		energy_profile = ENERGY_DATA_NODE_ENERGY;

	if (in_hertz) {
		hertz = in_hertz;
	} else {
		hertz = sysconf(_SC_CLK_TCK);

		if (hertz < 1) {
			error ("_get_process_data: unable to get clock rate");
			hertz = 100;	/* default on many systems */
		}
	}

	my_pagesize = getpagesize() / 1024;
}
示例#11
0
/*
 * reset debug flag (slurmd)
 */
extern void
cpu_freq_reconfig(void)
{
	/* reset local static variables */
	cpu_freq_govs = 0;
	debug_flags = slurm_get_debug_flags();
}
示例#12
0
int init (void)
{
	char *avail_mcdram_str, *avail_numa_str;
	char *default_mcdram_str, *default_numa_str;
	int rc;

	rc = knl_conf_read(&avail_mcdram, &avail_numa,
			   &default_mcdram, &default_numa);

	if (slurm_get_debug_flags() & DEBUG_FLAG_KNL) {
		avail_mcdram_str = knl_mcdram_str(avail_mcdram);
		avail_numa_str = knl_numa_str(avail_numa);
		default_mcdram_str = knl_mcdram_str(default_mcdram);
		default_numa_str = knl_numa_str(default_numa);
		info("AvailMCDRAM=%s DefaultMCDRAM=%s",
		     avail_mcdram_str, default_mcdram_str);
		info("AvailNUMA=%s DefaultNUMA=%s",
		     avail_numa_str, default_numa_str);
		xfree(avail_mcdram_str);
		xfree(avail_numa_str);
		xfree(default_mcdram_str);
		xfree(default_numa_str);
	}

	return rc;
}
示例#13
0
文件: gang.c 项目: Xarthisius/slurm
/* Initialize data structures and start the gang scheduling thread */
extern int gs_init(void)
{
	if (timeslicer_thread_id)
		return SLURM_SUCCESS;

	/* initialize global variables */
	if (gs_debug_flags & DEBUG_FLAG_GANG)
		info("gang: entering gs_init");
	timeslicer_seconds = slurmctld_conf.sched_time_slice;
	gs_debug_flags = slurm_get_debug_flags();
	gs_fast_schedule = slurm_get_fast_schedule();
	gr_type = _get_gr_type();
	preempt_job_list = list_create(_preempt_job_list_del);

	/* load the physical resource count data */
	_load_phys_res_cnt();

	pthread_mutex_lock(&data_mutex);
	_build_parts();
	/* load any currently running jobs */
	_scan_slurm_job_list();
	pthread_mutex_unlock(&data_mutex);

	/* spawn the timeslicer thread */
	_spawn_timeslicer_thread();
	if (gs_debug_flags & DEBUG_FLAG_GANG)
		info("gang: leaving gs_init");
	return SLURM_SUCCESS;
}
/*
 * init() is called when the plugin is loaded, before any other functions
 *	are called.  Put global initialization here.
 */
extern int init (void)
{
	debug("%s loaded.", plugin_name);

#ifdef HAVE_NATIVE_CRAY
	int rc;
	struct stat st;

	debug_flags = slurm_get_debug_flags();

	// Create the run directory
	errno = 0;
	rc = mkdir(TASK_CRAY_RUN_DIR, 0755);
	if (rc == -1 &&	errno != EEXIST) {
		CRAY_ERR("Couldn't create %s: %m", TASK_CRAY_RUN_DIR);
		return SLURM_ERROR;
	}

	// Determine whether to track app status with LLI
	rc = stat(LLI_SPOOL_DIR, &st);
	if (rc == -1) {
		debug("stat %s failed, disabling exit status tracking: %m",
			LLI_SPOOL_DIR);
		track_status = 0;
	} else {
		track_status = 1;
	}
#endif

	return SLURM_SUCCESS;
}
/* This _get_nb_cpus function is greatly inspired from the Job_Size calculation
 * in job_manager.c, but reused here to find out the requested resources. As
 * stated in the comment of the Job_Size calculation, the first scheduling run
 * may not have the actual total_cpus so we start by using the amount requested.
 * Then the actual required cpus will be filled in. This function estimates
 * the future value of total_cpus if it is not set.
 */
static int _get_nb_cpus(struct job_record *job_ptr)
{
	uint32_t cpu_cnt = 0;
	uint32_t min_nodes = 0;
	uint32_t max_nodes = 0;
	uint32_t req_nodes = 0;
	uint32_t cpus_per_node;

	cpus_per_node = (uint32_t) job_ptr->part_ptr->total_cpus /
			job_ptr->part_ptr->total_nodes;
	min_nodes = MAX(job_ptr->details->min_nodes,
			job_ptr->part_ptr->min_nodes);

	if (job_ptr->details->max_nodes == 0) {
		max_nodes = job_ptr->part_ptr->max_nodes;
	} else {
		max_nodes = MIN(job_ptr->details->max_nodes,
				job_ptr->part_ptr->max_nodes);
	}
	max_nodes = MIN(max_nodes, 500000);	/* prevent overflows */

	if (!job_ptr->limit_set_max_nodes && job_ptr->details->max_nodes)
		req_nodes = max_nodes;
	else
		req_nodes = min_nodes;


	if (job_ptr->total_cpus) {
		/* This indicates that nodes have been allocated already, but
		 * the job might have been requeued afterward. */
		cpu_cnt = job_ptr->total_cpus;
		if (slurm_get_debug_flags() & DEBUG_FLAG_PRIO) {
			info("%s: JobId=%u (%s) total_cpus=%u",
			     plugin_type, job_ptr->job_id, job_ptr->name,
			     cpu_cnt);
		}
	} else {
		cpu_cnt = req_nodes * cpus_per_node;
		if (slurm_get_debug_flags() & DEBUG_FLAG_PRIO) {
			info("%s: JobId=%u (%s) req_cpus=%u",
			     plugin_type, job_ptr->job_id, job_ptr->name,
			     cpu_cnt);
		}
	}

	return cpu_cnt;
}
示例#16
0
/* Read file to data variable */
static uint32_t _read_file(const char *file, char **data)
{
	uint32_t data_size = 0;
	int data_allocated, data_read, fd, fsize = 0;
	struct stat f_stat;

	fd = open(file, O_RDONLY);
	if (fd < 0) {
		if (slurm_get_debug_flags() & DEBUG_FLAG_ESEARCH)
			info("%s: Could not open state file %s", plugin_type,
			     file);
		return data_size;
	}
	if (fstat(fd, &f_stat)) {
		if (slurm_get_debug_flags() & DEBUG_FLAG_ESEARCH)
			info("%s: Could not stat state file %s", plugin_type,
			     file);
		close(fd);
		return data_size;
	}

	fsize = f_stat.st_size;
	data_allocated = BUF_SIZE;
	*data = xmalloc(data_allocated);
	while (1) {
		data_read = read(fd, &(*data)[data_size], BUF_SIZE);
		if (data_read < 0) {
			if (errno == EINTR)
				continue;
			else {
				error("%s: Read error on %s: %m", plugin_type,
				      file);
				break;
			}
		} else if (data_read == 0)	/* EOF */
			break;
		data_size += data_read;
		data_allocated += data_read;
		*data = xrealloc(*data, data_allocated);
	}
	close(fd);
	if (data_size != fsize) {
		error("%s: Could not read entire jobcomp state file %s (%d of"
		      " %d)", plugin_type, file, data_size, fsize);
	}
	return data_size;
}
示例#17
0
文件: backfill.c 项目: gyliu513/slurm
static void _load_config(void)
{
	char *sched_params, *tmp_ptr;

	sched_params = slurm_get_sched_params();
	debug_flags  = slurm_get_debug_flags();

	if (sched_params && (tmp_ptr=strstr(sched_params, "bf_interval=")))
		backfill_interval = atoi(tmp_ptr + 12);
	if (backfill_interval < 1) {
		fatal("Invalid backfill scheduler bf_interval: %d",
		      backfill_interval);
	}

	if (sched_params && (tmp_ptr=strstr(sched_params, "bf_window=")))
		backfill_window = atoi(tmp_ptr + 10) * 60;  /* mins to secs */
	if (backfill_window < 1) {
		fatal("Invalid backfill scheduler window: %d",
		      backfill_window);
	}
	if (sched_params && (tmp_ptr=strstr(sched_params, "max_job_bf=")))
		max_backfill_job_cnt = atoi(tmp_ptr + 11);
	if (max_backfill_job_cnt < 1) {
		fatal("Invalid backfill scheduler max_job_bf: %d",
		      max_backfill_job_cnt);
	}
	/* "bf_res=" is vestigial from version 2.3 and can be removed later.
	 * Only "bf_resolution=" is documented. */
	if (sched_params && (tmp_ptr=strstr(sched_params, "bf_res=")))
		backfill_resolution = atoi(tmp_ptr + 7);
	if (sched_params && (tmp_ptr=strstr(sched_params, "bf_resolution=")))
		backfill_resolution = atoi(tmp_ptr + 14);
	if (backfill_resolution < 1) {
		fatal("Invalid backfill scheduler resolution: %d",
		      backfill_resolution);
	}

	if (sched_params && (tmp_ptr=strstr(sched_params, "bf_max_job_part=")))
		max_backfill_job_per_part = atoi(tmp_ptr + 16);
	if (max_backfill_job_per_part < 0) {
		fatal("Invalid backfill scheduler bf_max_job_part: %d",
		      max_backfill_job_per_part);
	}

	if (sched_params && (tmp_ptr=strstr(sched_params, "bf_max_job_user="******"Invalid backfill scheduler bf_max_job_user: %d",
		      max_backfill_job_per_user);
	}

	/* bf_continue makes backfill continue where it was if interrupted
	 */
	if (sched_params && (strstr(sched_params, "bf_continue"))) {
		backfill_continue = true;
	}

	xfree(sched_params);
}
示例#18
0
/*
 * init() is called when the plugin is loaded, before any other functions
 * are called.  Put global initialization here.
 */
extern int init ( void )
{
	if (slurmctld_conf.select_type_param & CR_OTHER_CONS_RES)
		plugin_id = 108;
	debug_flags = slurm_get_debug_flags();
	verbose("%s loaded", plugin_name);
	return SLURM_SUCCESS;
}
示例#19
0
/* log_set_debug_flags()
 * Set or reset the debug flags based on the configuration
 * file or the scontrol command.
 */
void log_set_debug_flags(void)
{
	uint64_t debug_flags = slurm_get_debug_flags();

	slurm_mutex_lock(&log_lock);
	log->debug_flags = debug_flags;
	slurm_mutex_unlock(&log_lock);
}
示例#20
0
/*
 * build_all_frontend_info - get a array of slurm_conf_frontend_t structures
 *	from the slurm.conf reader, build table, and set values
 * is_slurmd_context: set to true if run from slurmd
 * RET 0 if no error, error code otherwise
 */
extern int build_all_frontend_info (bool is_slurmd_context)
{
	slurm_conf_frontend_t **ptr_array;
#ifdef HAVE_FRONT_END
	slurm_conf_frontend_t *fe_single, *fe_line;
	int i, count, max_rc = SLURM_SUCCESS;
	bool front_end_debug;

	if (slurm_get_debug_flags() & DEBUG_FLAG_FRONT_END)
		front_end_debug = true;
	else
		front_end_debug = false;
	count = slurm_conf_frontend_array(&ptr_array);
	if (count == 0)
		fatal("No FrontendName information available!");

	for (i = 0; i < count; i++) {
		hostlist_t hl_name, hl_addr;
		char *fe_name, *fe_addr;

		fe_line = ptr_array[i];
		hl_name = hostlist_create(fe_line->frontends);
		if (hl_name == NULL)
			fatal("Invalid FrontendName:%s", fe_line->frontends);
		hl_addr = hostlist_create(fe_line->addresses);
		if (hl_addr == NULL)
			fatal("Invalid FrontendAddr:%s", fe_line->addresses);
		if (hostlist_count(hl_name) != hostlist_count(hl_addr)) {
			fatal("Inconsistent node count between "
			      "FrontendName(%s) and FrontendAddr(%s)",
			      fe_line->frontends, fe_line->addresses);
		}
		while ((fe_name = hostlist_shift(hl_name))) {
			fe_addr = hostlist_shift(hl_addr);
			fe_single = xmalloc(sizeof(slurm_conf_frontend_t));
			if (list_append(front_end_list, fe_single) == NULL)
				fatal("list_append: malloc failure");
			fe_single->frontends = xstrdup(fe_name);
			fe_single->addresses = xstrdup(fe_addr);
			free(fe_name);
			free(fe_addr);
			fe_single->port = fe_line->port;
			if (fe_line->reason && fe_line->reason[0])
				fe_single->reason = xstrdup(fe_line->reason);
			fe_single->node_state = fe_line->node_state;
			if (front_end_debug && !is_slurmd_context)
				_dump_front_end(fe_single);
		}
		hostlist_destroy(hl_addr);
		hostlist_destroy(hl_name);
	}
	return max_rc;
#else
	if (slurm_conf_frontend_array(&ptr_array) != 0)
		fatal("FrontendName information configured!");
	return SLURM_SUCCESS;
#endif
}
示例#21
0
文件: slurm_route.c 项目: c02y/slurm
/*
 * route_g_reconfigure - reset during reconfigure
 *
 * RET: SLURM_SUCCESS - int
 */
extern int route_g_reconfigure(void)
{
	if (route_init(NULL) != SLURM_SUCCESS)
		return SLURM_ERROR;
	debug_flags = slurm_get_debug_flags();
	tree_width = slurm_get_tree_width();

	return (*(ops.reconfigure))();
}
示例#22
0
/*
 * init() is called when the plugin is loaded, before any other functions
 * are called.  Put global initialization here.
 */
extern int init(void)
{
	debug_flags = slurm_get_debug_flags();
	/* put anything that requires the .conf being read in
	   acct_gather_energy_p_conf_parse
	*/

	return SLURM_SUCCESS;
}
示例#23
0
/*
 * init() is called when the plugin is loaded, before any other functions
 * are called.  Put global initialization here.
 */
extern int init(void)
{
	if (!_run_in_daemon())
		return SLURM_SUCCESS;

	debug_flags = slurm_get_debug_flags();

	return SLURM_SUCCESS;
}
示例#24
0
int main(int argc, char *argv[])
{
	log_options_t log_opts = LOG_OPTS_INITIALIZER;
	hostlist_t hl = NULL;
	char *node_name;
	pthread_attr_t attr_work;
	pthread_t thread_work = 0;

	xstrfmtcat(prog_name, "%s[%u]", argv[0], (uint32_t) getpid());
	_read_config();
	log_opts.stderr_level = LOG_LEVEL_QUIET;
	log_opts.syslog_level = LOG_LEVEL_QUIET;
	if (slurm_get_debug_flags() && DEBUG_FLAG_NODE_FEATURES)
		log_opts.logfile_level += 3;
	(void) log_init(argv[0], log_opts, LOG_DAEMON, log_file);

	if ((hl = hostlist_create(argv[1])) == NULL) {
		error("%s: Invalid hostlist (%s)", prog_name, argv[1]);
		exit(2);
	}
	while ((node_name = hostlist_pop(hl))) {
		slurm_mutex_lock(&thread_cnt_mutex);
		while (1) {
			if (thread_cnt <= MAX_THREADS) {
				thread_cnt++;
				break;
			} else {	/* wait for state change and retry */
				pthread_cond_wait(&thread_cnt_cond,
						  &thread_cnt_mutex);
			}
		}
		slurm_mutex_unlock(&thread_cnt_mutex);

		slurm_attr_init(&attr_work);
		(void) pthread_attr_setdetachstate
			(&attr_work, PTHREAD_CREATE_DETACHED);
		if (pthread_create(&thread_work, &attr_work, _node_update,
				   (void *) node_name)) {
			_node_update((void *) node_name);
		}
		slurm_attr_destroy(&attr_work);
	}

	/* Wait for work threads to complete */
	slurm_mutex_lock(&thread_cnt_mutex);
	while (1) {
		if (thread_cnt == 0)
			break;
		else	/* wait for state change and retry */
			pthread_cond_wait(&thread_cnt_cond, &thread_cnt_mutex);
	}
	slurm_mutex_unlock(&thread_cnt_mutex);
	hostlist_destroy(hl);

	exit(0);
}
示例#25
0
文件: switch_cray.c 项目: HDOD/slurm
/*
 * init() is called when the plugin is loaded, before any other functions
 * are called.  Put global initialization here.
 */
int init(void)
{
	debug("%s loaded.", plugin_name);
	debug_flags = slurm_get_debug_flags();

#if defined(HAVE_NATIVE_CRAY) || defined(HAVE_CRAY_NETWORK)
	start_lease_extender();
#endif
	return SLURM_SUCCESS;
}
示例#26
0
/*
 * init() is called when the plugin is loaded, before any other functions
 *	are called.  Put global initialization here.
 */
extern int init(void)
{
	debug_flags = slurm_get_debug_flags();
	if (debug_flags & DEBUG_FLAG_JOB_CONT)
		info("%s loaded", plugin_name);
	else
		debug("%s loaded", plugin_name);

	return SLURM_SUCCESS;
}
示例#27
0
/*
 * init() is called when the plugin is loaded, before any other functions
 * are called.  Put global initialization here.
 */
extern int init(void)
{
	/* read ext_sensors configuration */
	if (_ext_sensors_read_conf())
		return SLURM_ERROR;

	debug_flags = slurm_get_debug_flags();
	verbose("%s loaded", plugin_name);
	return SLURM_SUCCESS;
}
示例#28
0
/* For each running job, return power allocation/use information in a List
 * containing elements of type power_by_job_t.
 * NOTE: Job data structure must be locked on function entry
 * NOTE: Call list_delete() to free return value
 * NOTE: This function is currently unused. */
extern List get_job_power(List job_list,
			  struct node_record *node_record_table_ptr)
{
	struct node_record *node_ptr;
	struct job_record *job_ptr;
	ListIterator job_iterator;
	power_by_job_t *power_ptr;
	char jobid_buf[64] = "";
	int i, i_first, i_last;
	uint64_t debug_flag = slurm_get_debug_flags();
	List job_power_list = list_create(_job_power_del);
	time_t now = time(NULL);

	job_iterator = list_iterator_create(job_list);
	while ((job_ptr = (struct job_record *) list_next(job_iterator))) {
		if (!IS_JOB_RUNNING(job_ptr))
			continue;
		power_ptr = xmalloc(sizeof(power_by_job_t));
		power_ptr->job_id = job_ptr->job_id;
		power_ptr->start_time = job_ptr->start_time;
		list_append(job_power_list, power_ptr);
		if (!job_ptr->node_bitmap) {
			error("%s: %s node_bitmap is NULL", __func__,
			      jobid2fmt(job_ptr, jobid_buf, sizeof(jobid_buf)));
			continue;
		}
		i_first = bit_ffs(job_ptr->node_bitmap);
		if (i_first < 0)
			continue;
		i_last = bit_fls(job_ptr->node_bitmap);
		for (i = i_first; i <= i_last; i++) {
			if (!bit_test(job_ptr->node_bitmap, i))
				continue;
			node_ptr = node_record_table_ptr + i;
			if (node_ptr->power) {
				power_ptr->alloc_watts +=
					node_ptr->power->cap_watts;
			}
			if (node_ptr->energy) {
				power_ptr->used_watts +=
					node_ptr->energy->current_watts;
			}
		}
		if (debug_flag & DEBUG_FLAG_POWER) {
			info("%s: %s Age=%ld(sec) AllocWatts=%u UsedWatts=%u",
			     __func__,
			     jobid2fmt(job_ptr, jobid_buf, sizeof(jobid_buf)),
			     (long int) difftime(now, power_ptr->start_time),
			     power_ptr->alloc_watts, power_ptr->used_watts);
		}
	}
	list_iterator_destroy(job_iterator);

	return job_power_list;
}
示例#29
0
/* Load jobcomp data from save state file */
static int _load_pending_jobs(void)
{
	int i, rc = SLURM_SUCCESS;
	char *saved_data = NULL, *state_file = NULL, *job_data = NULL;
	uint32_t data_size, job_cnt = 0, tmp32 = 0;
	Buf buffer;
	struct job_node *jnode;

	state_file = slurm_get_state_save_location();
	if (state_file == NULL) {
		error("%s: Could not retrieve StateSaveLocation from conf",
		      plugin_type);
		return SLURM_ERROR;
	}

	if (state_file[strlen(state_file) - 1] != '/')
		xstrcat(state_file, "/");
	xstrcat(state_file, save_state_file);

	slurm_mutex_lock(&save_lock);
	data_size = _read_file(state_file, &saved_data);
	if ((data_size <= 0) || (saved_data == NULL)) {
		slurm_mutex_unlock(&save_lock);
		xfree(saved_data);
		xfree(state_file);
		return rc;
	}
	slurm_mutex_unlock(&save_lock);

	buffer = create_buf(saved_data, data_size);
	safe_unpack32(&job_cnt, buffer);
	for (i = 0; i < job_cnt; i++) {
		safe_unpackstr_xmalloc(&job_data, &tmp32, buffer);
		jnode = xmalloc(sizeof(struct job_node));
		jnode->serialized_job = job_data;
		list_enqueue(jobslist, jnode);
	}
	if (job_cnt > 0) {
		if (slurm_get_debug_flags() & DEBUG_FLAG_ESEARCH)
			info("%s: Loaded %u jobs from state file", plugin_type,
			     job_cnt);
	}
	free_buf(buffer);
	xfree(state_file);

	return rc;

unpack_error:
	error("%s: Error unpacking file %s", plugin_type, state_file);
	free_buf(buffer);
	xfree(state_file);
	return SLURM_ERROR;
}
示例#30
0
/*
 * init() is called when the plugin is loaded, before any other functions
 * are called.  Put global initialization here.
 */
extern int init ( void )
{
	/* We must call the api here since we call this from other
	 * things other than the slurmctld.
	 */
	uint16_t select_type_param = slurm_get_select_type_param();
	if (select_type_param & CR_OTHER_CONS_RES)
		plugin_id = 108;
	debug_flags = slurm_get_debug_flags();
	verbose("%s loaded", plugin_name);
	return SLURM_SUCCESS;
}