Bug 97051

Summary: get_mempolicy(2) inconsistent with numaif.h
Product: Documentation Reporter: Nadav Har'El (nyh)
Component: man-pagesAssignee: documentation_man-pages (documentation_man-pages)
Status: RESOLVED CODE_FIX    
Severity: normal CC: andi-bz, mtk.manpages
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: Subsystem:
Regression: No Bisected commit-id:

Description Nadav Har'El 2015-04-21 22:28:38 UTC
get_mempolicy(2)'s synopsis is:

       #include <numaif.h>

       int get_mempolicy(int *mode, unsigned long *nodemask,
                         unsigned long maxnode, unsigned long addr,
                         unsigned long flags);

However, the actual prototype in numif.h (and implementation in numactl's syscall.c) is subtly different:

       long get_mempolicy(int *policy, const unsigned long *nmask,
                        unsigned long maxnode, void *addr, int flags);

The funny thing is, that prototype is isn't quite right either - it pretends nmask is a const pointer, but it most definitely isn't, and the data pointed by it get written to. But that isn't a man-page bug.
Comment 1 Michael Kerrisk 2015-05-05 09:19:10 UTC
Andi, could you comment on this bug?

Thanks,

Michael

On 22 April 2015 at 00:28,  <bugzilla-daemon@bugzilla.kernel.org> wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=97051
>
>             Bug ID: 97051
>            Summary: get_mempolicy(2) inconsistent with numaif.h
>            Product: Documentation
>            Version: unspecified
>           Hardware: All
>                 OS: Linux
>             Status: NEW
>           Severity: normal
>           Priority: P1
>          Component: man-pages
>           Assignee: documentation_man-pages@kernel-bugs.osdl.org
>           Reporter: nyh@math.technion.ac.il
>         Regression: No
>
> get_mempolicy(2)'s synopsis is:
>
>        #include <numaif.h>
>
>        int get_mempolicy(int *mode, unsigned long *nodemask,
>                          unsigned long maxnode, unsigned long addr,
>                          unsigned long flags);
>
> However, the actual prototype in numif.h (and implementation in numactl's
> syscall.c) is subtly different:
>
>        long get_mempolicy(int *policy, const unsigned long *nmask,
>                         unsigned long maxnode, void *addr, int flags);
>
> The funny thing is, that prototype is isn't quite right either - it pretends
> nmask is a const pointer, but it most definitely isn't, and the data pointed
> by
> it get written to. But that isn't a man-page bug.
>
> --
> You are receiving this mail because:
> You are watching the assignee of the bug.
Comment 2 Michael Kerrisk 2016-11-09 13:21:20 UTC
Andi, Could you comment on this bug?
Comment 3 Andi Kleen 2016-11-16 01:31:03 UTC
Yes the manpage version is better and the const is incorrect.
Should probably fix the version in numactl
Comment 4 Andi Kleen 2017-05-25 20:39:48 UTC
Sorry for the delay.

I fixed numactl to drop the const from the get_mempolicy prototype, and also changed flags to unsigned.

I didn't change the addr argument to unsigned long because that would cause warnings in existing code. 

I would recommend to change the manpage to this prototype to match numaif.h:

long get_mempolicy(int *mode, unsigned long *nmask,
                        unsigned long maxnode, void *addr, unsigned flags);
Comment 5 Michael Kerrisk 2017-05-30 03:06:34 UTC
(In reply to Andi Kleen from comment #4)
> Sorry for the delay.
> 
> I fixed numactl to drop the const from the get_mempolicy prototype, and also
> changed flags to unsigned.
> 
> I didn't change the addr argument to unsigned long because that would cause
> warnings in existing code. 
> 
> I would recommend to change the manpage to this prototype to match numaif.h:
> 
> long get_mempolicy(int *mode, unsigned long *nmask,
>                         unsigned long maxnode, void *addr, unsigned flags);

Okay -- I've made that change to the man page.

I'll close this bug now. Nadav Har'El, if you think someting is still wrong, please reopen.

Thanks,

Michael