Skip to content
This repository was archived by the owner on Nov 17, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8b84b17
Increase default num boxes
wil93 Jan 18, 2016
c231b13
Merge pull request #10 from algorithm-ninja/increase_num_boxes
gollux Jan 18, 2016
a3a2c4d
var_len of default environment rules was not initialized
gollux Jan 22, 2016
ab6ec57
Implemented "--silent" mode
gollux Jan 23, 2016
c228c56
Clean up signal handling
gollux Jan 23, 2016
6d7aa39
Call watchdog timer every 100 ms
gollux Jan 24, 2016
8af30e7
Changed default box location to /var/local/lib/isolate/
gollux Jan 24, 2016
4693333
Makefile: Do not use "asciidoc -D" when building man pages
gollux Jan 24, 2016
ce9dad0
Fixed race condition in make_dir()
gollux Jan 24, 2016
6b46017
Add a LICENSE file.
gollux Jan 24, 2016
c8b0eef
Source split to several files
gollux Jan 24, 2016
4d364d5
Compile-time configuration moved to a run-time config file
gollux Jan 24, 2016
cb04630
Update the manual page to reflect recent changes
gollux Jan 24, 2016
450096d
Released as version 1.2
gollux Jan 24, 2016
8fc6594
Man page: Do not refer to a non-existent section
gollux Aug 16, 2016
e7f421b
Makefile: Enable prototype warnings
gollux Aug 16, 2016
9fa5760
cgroups: Fix inheritance of cpusets
gollux Aug 16, 2016
a01a65e
Added per-box configuration of CPU and NUMA node sets
gollux Aug 16, 2016
a2590eb
Added a possibility to choose a parent cgroup
gollux Aug 16, 2016
3bf44c4
Released as version 1.3
gollux Oct 10, 2016
e3c1368
Added f to short_opts
hermanzdosilovic Oct 22, 2016
0ede685
Merge pull request #18 from hermanzdosilovic/file-size
gollux Oct 24, 2016
7f55e36
Cosmetic: Options should be sorted
gollux Oct 24, 2016
424e3a6
Makefile: remove exec permission for config and manpage files
seirl Mar 3, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added per-box configuration of CPU and NUMA node sets
  • Loading branch information
gollux committed Aug 16, 2016
commit a01a65eac6b2da28501aeb7764a457b28300a351
9 changes: 6 additions & 3 deletions cg.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,14 @@ cg_prepare(void)
die("Failed to create control group %s: %m", path);
}

// If cpuset module is enabled, copy allowed cpus and memory nodes from parent group
// If the cpuset module is enabled, set up allowed cpus and memory nodes.
// If per-box configuration exists, use it; otherwise, inherit the settings
// from the parent cgroup.
struct cf_per_box *cf = cf_current_box();
if (cg_read(CG_PARENT | CG_CPUSET, "?cpuset.cpus", buf))
cg_write(CG_CPUSET, "cpuset.cpus", "%s", buf);
cg_write(CG_CPUSET, "cpuset.cpus", "%s", cf->cpus ? cf->cpus : buf);
if (cg_read(CG_PARENT | CG_CPUSET, "?cpuset.mems", buf))
cg_write(CG_CPUSET, "cpuset.mems", "%s", buf);
cg_write(CG_CPUSET, "cpuset.mems", "%s", cf->mems ? cf->mems : buf);
}

void
Expand Down
55 changes: 54 additions & 1 deletion config.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ int cf_first_gid;
int cf_num_boxes;

static int line_number;
static struct cf_per_box *per_box_configs;

static void NONRET
cf_err(char *msg)
Expand All @@ -46,7 +47,8 @@ cf_int(char *val)
return x;
}

void cf_entry(char *key, char *val)
static void
cf_entry_toplevel(char *key, char *val)
{
if (!strcmp(key, "box_root"))
cf_box_root = cf_string(val);
Expand All @@ -62,6 +64,35 @@ void cf_entry(char *key, char *val)
cf_err("Unknown configuration item");
}

static void
cf_entry_compound(char *key, char *subkey, char *val)
{
if (strncmp(key, "box", 3))
cf_err("Unknown configuration section");
int box_id = cf_int(key + 3);
struct cf_per_box *c = cf_per_box(box_id);

if (!strcmp(subkey, "cpus"))
c->cpus = cf_string(val);
else if (!strcmp(subkey, "mems"))
c->mems = cf_string(val);
else
cf_err("Unknown per-box configuration item");
}

static void
cf_entry(char *key, char *val)
{
char *dot = strchr(key, '.');
if (!dot)
cf_entry_toplevel(key, val);
else
{
*dot++ = 0;
cf_entry_compound(key, dot, val);
}
}

static void
cf_check(void)
{
Expand Down Expand Up @@ -109,3 +140,25 @@ cf_parse(void)
fclose(f);
cf_check();
}

struct cf_per_box *
cf_per_box(int box_id)
{
struct cf_per_box *c;

for (c = per_box_configs; c; c = c->next)
if (c->box_id == box_id)
return c;

c = xmalloc(sizeof(*c));
c->next = per_box_configs;
per_box_configs = c;
c->box_id = box_id;
return c;
}

struct cf_per_box *
cf_current_box(void)
{
return cf_per_box(box_id);
}
6 changes: 6 additions & 0 deletions default.cf
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ cg_root = /sys/fs/cgroup
first_uid = 60000
first_gid = 60000
num_boxes = 1000

# Per-box settings of the set of allowed CPUs and NUMA nodes
# (see linux/Documentation/cgroups/cpusets.txt for precise syntax)

#box0.cpus = 4-7
#box0.mems = 1
9 changes: 9 additions & 0 deletions isolate.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,13 @@ extern int cf_first_uid;
extern int cf_first_gid;
extern int cf_num_boxes;

struct cf_per_box {
struct cf_per_box *next;
int box_id;
char *cpus;
char *mems;
};

void cf_parse(void);
struct cf_per_box *cf_per_box(int box_id);
struct cf_per_box *cf_current_box(void);