Page MenuHomeFreeBSD

kern: jail: allow specifying a cpuset.parent at creation time
AcceptedPublic

Authored by kevans on Dec 6 2025, 4:13 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Sep 1, 6:19 PM
Unknown Object (File)
Wed, Aug 26, 1:29 PM
Unknown Object (File)
Fri, Aug 21, 12:05 PM
Unknown Object (File)
Thu, Aug 20, 8:08 PM
Unknown Object (File)
Mon, Aug 17, 3:43 PM
Unknown Object (File)
Sat, Aug 8, 1:11 PM
Unknown Object (File)
Sat, Aug 8, 9:46 AM
Unknown Object (File)
Jul 9 2026, 3:10 PM
Subscribers

Details

Reviewers
olce
markj
bcr
Group Reviewers
Jails
manpages
Summary

This allows for different cpuset topologies than the default scheme,
which creates every jail's cpuset root parented to the jail that created
it. Notably, this would make it easier to do schemes like PR 253724,
where the user depicts creating an init_script so that they can have
prison0 user processes running on a different disjoint set of cores than
on jails that they create.

The init_script is necessary there because any jail will inherit
restrictions placed on the prison, so they have to catch init(8) before
it starts spawning off other processes.

With this change, their init_script could become obsolete if they don't
have scenarios where they still want to allocate some of the cores not
traditionally used by prison0 to processes within. They would instead
modify prison0's cpuset to reflect reality and create new jails that
instead use the root set (0) to derive their new constraints from.

This notably does not prevent the parent jail from administering the
child. In the event that root is attaching to a jail with a disjoint
set, it would hit an EDEADLK and inherit the target's set instead since
it has the privilege to widen its affinity.

Relnotes: yes

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 69096
Build 65979: arc lint + arc unit

Event Timeline

kevans requested review of this revision.Dec 6 2025, 4:13 AM
bcr added a subscriber: bcr.

OK for the manpage part.

This revision is now accepted and ready to land.Sat, Aug 15, 11:50 AM
jamie added inline comments.
sys/kern/kern_jail.c
1849

I'm not seeing cpuset_create_root_from anywhere; is there supposed to be a matching change to kern_cpuset.c?

Considering the line below is the only consumer of cpuset_create_root, and all cpuset_create_root does with its pr parameter is use pr->pr_cpuset, it would make as much sense to change cpuset_create_root as it would to add a variant.

sys/kern/kern_jail.c
1849

Ah, I see it - different revision. Never mind :-P

What's the significance of the parent cpuset being marked CPU_SET_ROOT? This question didn't block my approval, because I really just don't understand the implications. Before, root cpusets had a 1:1 correspondence with jails, and now they don't.