Page MenuHomeFreeBSD

Add sched_getaffinity.3 to document sched_getaffinity and sched_setaffinity
AbandonedPublic

Authored by felix.the.red_gmail.com on Jun 30 2025, 8:27 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Oct 16, 5:04 AM
Unknown Object (File)
Sun, Oct 12, 5:32 PM
Unknown Object (File)
Thu, Oct 9, 7:49 PM
Unknown Object (File)
Tue, Sep 23, 6:24 PM
Unknown Object (File)
Sep 14 2025, 9:19 AM
Unknown Object (File)
Sep 10 2025, 10:48 PM
Unknown Object (File)
Sep 3 2025, 9:02 PM
Unknown Object (File)
Aug 12 2025, 10:37 PM

Details

Reviewers
None
Group Reviewers
manpages
Summary

The sched_getaffinity(3) and sched_setaffinity(3) functions added in FreeBSD 13.1 lack a manual page.
This revision creates a manual page to document those functions.

The original PR mentions sched_getcpu and sched_getaffinity.
A manual page exists for the first one, sched_getcpu(3).

PR:265249

Test Plan

mandoc -Tlint
Read lib/libc/gen/sched_getaffinity.c and lib/libc/gen/sched_setaffinity.c.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

  • English and markup both look good to me at a glance, but I can't attest to consistency with source code
  • I think you also need to add to MLINKS in the appropriate Makefile so "man sched_setaffinity" will work
lib/libsys/sched_getaffinity.3
2

There's a blank comment before this line also

12

Nd is lowercase

kib added inline comments.
lib/libsys/sched_getaffinity.3
51

This is confusing, I do not understand what are you trying to say there.

The pid parameter might be actual pid, or it might be tid. If it is pid, some random thread in the target process is selected, and its cpuset is returned. If it is tid, the specified thread' cpuset is returned.

lib/libsys/sched_getaffinity.3
51

And I am wrong about pid. If pid is specified, the masks of all threads in the process are OR-ed for the result. It is not a mask of single random thread.

lib/libsys/sched_getaffinity.3
13

Section 3 manuals need a Lb macro

Clarify the use of sched_getaffinity, sched_setaffinity,
the value of the pid parameter and how it differs
between the functions, and their return values.
Add an entry in Makefile.sys to include the manual page
in the build.

lib/libsys/sched_getaffinity.3
13

.Sh LIBRARY is deprecated, please put .Lb in the SYNOPSIS

lib/libsys/Makefile.sys
494–495

(Or something, typing this on my phone while driving)

felix.the.red_gmail.com marked 3 inline comments as done.

sched_getaffinity.3: Move library section.
Makefile.sys: Add MLINKS

Updated to address clarity and formatting.

Why the man page added to libsys? It must go into libc/gen.

lib/libsys/sched_getaffinity.3
21

I do not think that this .Pp is needed. We do not do this in other multi-function man pages.

32

I suggest to move this sentence somewhere near the end of DESCRIPTION.
It is a useful info to know, but not the first thing a reader interested in the function needs to see.

45

No, this is again not right.
If pid > 0 and pid < PID_MAX, then the description is correct.
Otherwise pid is really tid and then the mask of the named thread is returned.

56

No, it is either pid or tid, as above.

59

No, if pid is pid, the mask is applied to all threads of the target process.
If pid is tid, the mask is applied to the specified thread.

I will move everything to libc and fix issues in a separate commit.

I will move everything to libc and fix issues in a separate commit.

  1. Please do not do this in the future, it makes us loose the state, participants, and difficult to follow the history. You can always fix the review. If you have any questions about git or Phabricator, just ask, I'd be honored to help. Everything I know I learned from other people in this project.
  1. Since you did, please comment linking that review to this one, and this review to that one, and add everyone who was in this discussion.

Edit: but don't feel bad about it everyone does it. When I first started I ended up closing and starting a new review four times!