Example #1
0
extern int task_cgroup_cpuset_init(slurm_cgroup_conf_t *slurm_cgroup_conf)
{
	char release_agent_path[PATH_MAX];

	/* initialize cpuinfo internal data */
	if (xcpuinfo_init() != XCPUINFO_SUCCESS) {
		return SLURM_ERROR;
	}

	/* initialize user/job/jobstep cgroup relative paths */
	user_cgroup_path[0]='\0';
	job_cgroup_path[0]='\0';
	jobstep_cgroup_path[0]='\0';

	/* initialize cpuset cgroup namespace */
	release_agent_path[0]='\0';
	if (snprintf(release_agent_path,PATH_MAX,"%s/release_cpuset",
		      slurm_cgroup_conf->cgroup_release_agent) >= PATH_MAX) {
		error("task/cgroup: unable to build cpuset release agent path");
		goto error;
	}
	if (xcgroup_ns_create(slurm_cgroup_conf, &cpuset_ns, "/cpuset", "",
			       "cpuset",release_agent_path) !=
	     XCGROUP_SUCCESS) {
		error("task/cgroup: unable to create cpuset namespace");
		goto error;
	}

	/* check that cpuset cgroup namespace is available */
	if (! xcgroup_ns_is_available(&cpuset_ns)) {
		if (slurm_cgroup_conf->cgroup_automount) {
			if (xcgroup_ns_mount(&cpuset_ns)) {
				error("task/cgroup: unable to mount cpuset "
				      "namespace");
				goto clean;
			}
			info("task/cgroup: cpuset namespace is now mounted");
		} else {
			error("task/cgroup: cpuset namespace not mounted. "
			      "aborting");
			goto clean;
		}
	}

	return SLURM_SUCCESS;

clean:
	xcgroup_ns_destroy(&cpuset_ns);

error:
	xcpuinfo_fini();
	return SLURM_ERROR;
}
Example #2
0
/*
 * init() is called when the plugin is loaded, before any other functions
 * are called.  Put global initialization here.
 */
extern int init (void)
{
	/* If running on the slurmctld don't do any of this since it
	   isn't needed.
	*/
	if (_run_in_daemon()) {
		jag_common_init(0);

		/* read cgroup configuration */
		if (read_slurm_cgroup_conf(&slurm_cgroup_conf))
			return SLURM_ERROR;

		/* initialize cpuinfo internal data */
		if (xcpuinfo_init() != XCPUINFO_SUCCESS) {
			free_slurm_cgroup_conf(&slurm_cgroup_conf);
			return SLURM_ERROR;
		}

		/* enable cpuacct cgroup subsystem */
		if (jobacct_gather_cgroup_cpuacct_init(&slurm_cgroup_conf) !=
		    SLURM_SUCCESS) {
			xcpuinfo_fini();
			free_slurm_cgroup_conf(&slurm_cgroup_conf);
			return SLURM_ERROR;
		}

		/* enable memory cgroup subsystem */
		if (jobacct_gather_cgroup_memory_init(&slurm_cgroup_conf) !=
		    SLURM_SUCCESS) {
			xcpuinfo_fini();
			free_slurm_cgroup_conf(&slurm_cgroup_conf);
			return SLURM_ERROR;
		}

		/* FIXME: Enable when kernel support ready.
		 *
		 * Enable blkio subsystem.
		 */
		/* if (jobacct_gather_cgroup_blkio_init(&slurm_cgroup_conf) */
		/*     != SLURM_SUCCESS) { */
		/* 	xcpuinfo_fini(); */
		/* 	free_slurm_cgroup_conf(&slurm_cgroup_conf); */
		/* 	return SLURM_ERROR; */
		/* } */
	}

	verbose("%s loaded", plugin_name);
	return SLURM_SUCCESS;
}
Example #3
0
/*
 * convert a range into an other one according to
 * a modus operandi being 0 or 1 for abstract to machine
 * or machine to abstract representation of cores
 */
static int
_ranges_conv(char* lrange,char** prange,int mode)
{
	int fstatus;
	int i;
	uint16_t *amap;
	uint16_t *map;
	uint16_t *map_out;

	/* init internal data if not already done */
	if ( xcpuinfo_init() != XCPUINFO_SUCCESS )
		return XCPUINFO_ERROR;

	if ( mode ) {
		/* machine to abstract conversion */
		amap = block_map_inv;
	}
	else {
		/* abstract to machine conversion */
		amap = block_map;
	}

	/* allocate map for local work */
	map = (uint16_t*) xmalloc(block_map_size*sizeof(uint16_t));
	map_out = (uint16_t*) xmalloc(block_map_size*sizeof(uint16_t));

	/* extract the input map */
	fstatus = _range_to_map(lrange,map,block_map_size,!mode);
	if ( fstatus ) {
		goto exit;
	}

	/* do the conversion (see src/slurmd/slurmd/get_mach_stat.c) */
	for( i = 0 ; i < block_map_size ; i++) {
		if ( map[i] )
			map_out[amap[i]]=1;
	}

	/* build the ouput range */
	fstatus = _map_to_range(map_out,block_map_size,prange);

exit:
	xfree(map);
	xfree(map_out);
	return fstatus;
}
Example #4
0
/*
 * init() is called when the plugin is loaded, before any other functions
 * are called.  Put global initialization here.
 */
extern int init (void)
{
    /* read cgroup configuration */
    if (read_slurm_cgroup_conf(&slurm_cgroup_conf))
        return SLURM_ERROR;

    /* initialize cpuinfo internal data */
    if (xcpuinfo_init() != XCPUINFO_SUCCESS) {
        free_slurm_cgroup_conf(&slurm_cgroup_conf);
        return SLURM_ERROR;
    }

    /* initialize cgroup internal data */
    if (_slurm_cgroup_init() != SLURM_SUCCESS) {
        xcpuinfo_fini();
        free_slurm_cgroup_conf(&slurm_cgroup_conf);
        return SLURM_ERROR;
    }

    return SLURM_SUCCESS;
}
extern int task_cgroup_devices_init(slurm_cgroup_conf_t *slurm_cgroup_conf)
{
	uint16_t cpunum;

	/* initialize cpuinfo internal data */
	if ( xcpuinfo_init() != XCPUINFO_SUCCESS )
		return SLURM_ERROR;

	/* initialize user/job/jobstep cgroup relative paths */
	user_cgroup_path[0] = '\0';
	job_cgroup_path[0] = '\0';
	jobstep_cgroup_path[0] = '\0';
	/* initialize allowed_devices_filename */
	cgroup_allowed_devices_file[0] = '\0';

	if ( get_procs(&cpunum) != 0 ) {
		error("task/cgroup: unable to get a number of CPU");
		goto error;
	}

	(void) gres_plugin_node_config_load(cpunum, conf->node_name, NULL);

	strcpy(cgroup_allowed_devices_file,
	       slurm_cgroup_conf->allowed_devices_file);
	if (xcgroup_ns_create(slurm_cgroup_conf, &devices_ns, "", "devices")
	    != XCGROUP_SUCCESS ) {
		error("task/cgroup: unable to create devices namespace");
		goto error;
	}

	return SLURM_SUCCESS;

error:
	xcgroup_ns_destroy(&devices_ns);
	xcpuinfo_fini();
	return SLURM_ERROR;
}