Re: [PATCH] sched_setaffinity.2: sched_getaffinity returns the number of bytes copied

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Brice,

On 5/5/19 12:19 PM, Brice Goglin wrote:
sched_setaffinity.2: sched_getaffinity returns the number of bytes copied

On success, it returns min(len, cpumask_size()) where len is
the output buffer size (see the syscall definition in kernel/sched/core.c).

Signed-off-by: Brice Goglin <Brice.Goglin@xxxxxxxx>
---
  man2/sched_setaffinity.2 | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/man2/sched_setaffinity.2 b/man2/sched_setaffinity.2
index 74bbde81c..277edd0fb 100644
--- a/man2/sched_setaffinity.2
+++ b/man2/sched_setaffinity.2
@@ -107,9 +107,9 @@ is zero, then the mask of the calling thread is returned.
  .SH RETURN VALUE
  On success,
  .BR sched_setaffinity ()
-and
+returns 0, while
  .BR sched_getaffinity ()
-return 0.
+returns the number of bytes copied to the destination mask.
  On error, \-1 is returned, and
  .I errno
  is set appropriately.

Thanks for adding some detail. However, did you take a look at the
glibc wrapper, and also this text in the manual page:

   C library/kernel differences
      [...]   On  success,  the raw sched_getaffinity() system call
      returns the size (in bytes) of the cpumask_t  data  type  that  is
      used internally by the kernel to represent the CPU set bit mask.

Of course, looking at your patch, it's clear that that text is no longer
fully accurate (since Linux 2.6.34, commit cd3d8031eb4311e). I've now
adjusted it to say:

      On  success,  the  raw sched_getaffinity() system call returns the
      number of bytes placed copied into the mask buffer; this  will  be
      the minimum of cpusetsize and the size (in bytes) of the cpumask_t
      data type that is used internally by the kernel to  represent  the
      CPU set bit mask.

Thanks for report!

Cheers,

Michael



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux