[Bug 240687] jail cpuset masks cannot be expanded

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Thu Sep 19 14:56:09 UTC 2019


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240687

            Bug ID: 240687
           Summary: jail cpuset masks cannot be expanded
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs at FreeBSD.org
          Reporter: jhb at FreeBSD.org

Suppose one creates a simple jail:

jail -c name=foo command=/bin/sh

It will inherit the default cpuset from the parent jail.  You can use cpuset -j
to shrink this set:

% cpuset -g -j 1
jail 1 mask: 0, 1, 2, 3, 4, 5, 6, 7

% cpuset -g -j 1 -r
jail 1 mask: 0, 1, 2, 3, 4, 5, 6, 7

% cpuset -j 1 -l 0-3

% cpuset -g -j 1
jail 1 mask: 0, 1, 2, 3

However, once you've shrunk the set, you can never expand it.  The reason is
that the jail set is its own root, so the check against the 'root' mask in
cpuset_modify() fails with EINVAL.  I think this is perhaps not the intended
behavior.  I think that when setting the cpuset of a jail you want to apply the
check against the parent jail's mask, not the jail's own mask.

In particular, this prevents using cpuset -j to dynamically manage the CPUs
available to jails.  The alternative is to leave the jails unrestricted and
manage the processes in the jail (or create dedicated, named cpusets for each
jail and manage those) which is not as convenient for tools operating at the
abstraction level of a jail.

One possibility might be to have cpuset_getroot() always skip over the passed
in set to its parent at least once before checking for the ROOT flag (or fix
callers to pass set->cs_parent instead of set), but I haven't looked at what
other implications that might have.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list