Page MenuHomeFreeBSD

Add support for cpuset to jail.conf
Needs ReviewPublic

Authored by swills on Oct 25 2017, 1:25 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 20 2023, 7:54 AM
Unknown Object (File)
Dec 13 2023, 9:06 PM
Unknown Object (File)
Nov 9 2023, 6:01 PM
Unknown Object (File)
Oct 8 2023, 4:58 PM
Unknown Object (File)
Sep 3 2023, 3:48 PM
Unknown Object (File)
May 26 2023, 4:38 PM
Unknown Object (File)
Apr 25 2023, 9:23 AM
Unknown Object (File)
Apr 7 2023, 4:11 PM
Subscribers

Details

Reviewers
jamie
Summary

Adds a setting for jail.conf that allows setting the cpu-list for the jail.

Test Plan

Manual build and run testing.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 12225

Event Timeline

That would be a nice feature. I'm not using it right now but in times of many cores that might come handy.

In D12789#265425, @pi wrote:

That would be a nice feature. I'm not using it right now but in times of many cores that might come handy.

Thanks. Note this is only a convenience. You can do a similar thing now using exec.poststart, but this makes it a lot more obvious and easier.

Now that it's not really part of the exec system (aside from execing a program itself for convenience), exec.cpuset doesn't sound like the best name. I think cpuset.list would be good, or at least something under the cpuset.* umbrella since cpuset.id already exists.

One more thing to make it complete: something in the jail(8) man page. There's a pseudo-parameters section for things that aren't part of the kernel interface, where this would belong.

Execing a binary to get it exec a syscall which is readily available to the C environment is not a useful proposition. I can understand why ifconfigs or mounts are done by calling the binaries, since the whole sequence of calls to get the equivalent of their functionality done is not reasonable to duplicate. ifconfig might be worth reconsidering after libifconfig was added.

But in this case, cpuset_setaffinity() is not hard to use and it is not reasonable to call the binary to do the simple thing.

usr.sbin/jail/command.c
581

Style(9) requires spaces around binary ops.

In D12789#265493, @kib wrote:

Execing a binary to get it exec a syscall which is readily available to the C environment is not a useful proposition. I can understand why ifconfigs or mounts are done by calling the binaries, since the whole sequence of calls to get the equivalent of their functionality done is not reasonable to duplicate. ifconfig might be worth reconsidering after libifconfig was added.

But in this case, cpuset_setaffinity() is not hard to use and it is not reasonable to call the binary to do the simple thing.

It is trivial to call cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_JAIL, j->jid, ..., but it would require essentially duplicating cpuset's parselist, or moving it to a library, to parse the cpuset specification for the mask parameter. I find using exec in C to be an anti-pattern as well but sometimes it can be more practical if performance is not important.

It is trivial to call cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_JAIL, j->jid, ..., but it would require essentially duplicating cpuset's parselist, or moving it to a library, to parse the cpuset specification for the mask parameter. I find using exec in C to be an anti-pattern as well but sometimes it can be more practical if performance is not important.

parselist() is no-brainer, it is 70 lines. I am fine with either copying it or better, moving into libutil. Current patch adds 20 lines to call the binary.