Page MenuHomeFreeBSD

libutil: Move cpuset(1) domainset parsing code into libutil
ClosedPublic

Authored by bnovkov on Sep 8 2024, 5:58 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Oct 23, 10:29 PM
Unknown Object (File)
Mon, Oct 20, 6:56 AM
Unknown Object (File)
Fri, Oct 10, 11:01 PM
Unknown Object (File)
Thu, Oct 2, 5:48 AM
Unknown Object (File)
Sep 18 2025, 5:12 PM
Unknown Object (File)
Sep 17 2025, 7:12 AM
Unknown Object (File)
Sep 15 2025, 4:24 AM
Unknown Object (File)
Sep 13 2025, 9:33 PM
Subscribers

Details

Summary

cpuset(1) implements a domainset(9) policy parser that is used to translate a <policy>:<domain_list> string into a domainset_t mask and a valid domainset policy. This patch moves the domainset parsing code into a new cpuset.c function - domainset_parselist.

The existing cpuset.c code was refactored into a generalized list parsing function which is now used to parse both CPU sets and domain sets. This is the same approach used in cpuset(1).

Test Plan

All cpuset.c test cases pass without errors.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bcr added a subscriber: bcr.

OK for the man page part of the change.

Did you intend to remove some code from cpuset(1) in this diff?

lib/libutil/cpuset.3
29

The libutil Makefile should be updated to make domainset_parselist.3 a hardlink to cpuset.3.

40

Presumably cpu-list above is also a typo.

63
69
71
86
108

Maybe Xr numa 4 as well.

lib/libutil/cpuset.c
47
133
150

Extra newline.

lib/libutil/libutil.h
216–222

The rename is just to make the error code more general? I suggest leaving the old name there as well to preserve source compatibility, otherwise I'm sure a bunch of out-of-tree code will need to be tweaked. Then, you don't need to touch cpuset_test.c.

Address @markj 's comments:

  • Include missing cpuset(1) part of the diff
  • Fix manpages issues

Did you intend to remove some code from cpuset(1) in this diff?

That was indeed the intention, but I managed to drop that part of the diff somehow.
Fixed, thanks!

lib/libutil/libutil.h
216–222

Yeah, I think my intention was to make the symbol name a bit more fitting, but I hadn't considered that out-of-tree stuff might have to be tweaked at the time, thanks!

lib/libutil/cpuset.3
28–29
28–29

While here, would you fix this? Nd should be one line and is not supposed to have cross-references.

95–102
109

110m107 (with punctuation adjusted)

Looks ok to me with the man page nits fixed.

lib/libutil/cpuset.3
109

I don't know what this comment means, but the SEE ALSO section should be sorted by section number (i.e., numa 4 before cpuset 9), with no period at the end.

lib/libutil/libutil.h
216–222

To be clear, I think making the error name more general is a good idea, I'd just keep the old name as well:

#define CPUSET_PARSE_OUT_OF_RANGE        -3
#define CPUSET_PARSE_INVALID_CPU            CPUSET_PARSE_OUT_OF_RANGE /* backwards compat */
This revision is now accepted and ready to land.Jun 25 2025, 8:09 PM
This revision was automatically updated to reflect the committed changes.
bnovkov marked an inline comment as done.

Looks ok to me with the man page nits fixed.

I've fixed the nits before pushing, thanks!