* sys/prctl.h differences vs man page
@ 2025-06-12 6:49 Sebastian Andrzej Siewior
2025-06-12 14:31 ` [musl] " enh
0 siblings, 1 reply; 13+ messages in thread
From: Sebastian Andrzej Siewior @ 2025-06-12 6:49 UTC (permalink / raw)
To: musl; +Cc: Namhyung Kim, Arnaldo Carvalho de Melo
Hi,
the man page for prctl(2) states:
| SYNOPSIS
| #include <linux/prctl.h> /* Definition of PR_* constants */
| #include <sys/prctl.h>
if one is going to include both headers then this happens:
| In file included from file.c:6:
| /usr/include/sys/prctl.h:88:8: error: redefinition of 'struct prctl_mm_map'
| 88 | struct prctl_mm_map {
| | ^~~~~~~~~~~~
| In file included from file.c:5:
| /linux/tools/include/uapi/linux/prctl.h:134:8: note: originally defined here
| 134 | struct prctl_mm_map {
| | ^~~~~~~~~~~~
The problem is that musl's provided sys/prctl.h defines the struct
prctl_mm_map which is a copy of linux kernel's linux/prctl.h. This breaks
compiles based on the man page because that struct is defined twice.
It makes it harder to write software which replaces linux/prctl.h with
current header file while testing for recent features. It also increases
the maintenance on musl's side to keep that file up to date.
Could you please ship sys/prctl.h which provides the prctl() definition
and include the PR_* definition from linux/prctl.h?
This problem has been observed on Alpine Linux by Namhyung Kim [0].
[0] https://lore.kernel.org/all/aEh6xO14wDSCFUDr@google.com/T/#u
Sebastian
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [musl] sys/prctl.h differences vs man page
2025-06-12 6:49 sys/prctl.h differences vs man page Sebastian Andrzej Siewior
@ 2025-06-12 14:31 ` enh
2025-06-12 16:26 ` Rich Felker
0 siblings, 1 reply; 13+ messages in thread
From: enh @ 2025-06-12 14:31 UTC (permalink / raw)
To: musl; +Cc: Namhyung Kim, Arnaldo Carvalho de Melo
yeah, apologies that i don't think i reported this to the list before,
but android also hit various prctl portability issues trying to use
musl as the host libc and added this ahead of the musl <sys/prctl.h>
as our workaround:
#ifndef _SYS_PRCTL_H
#define _SYS_PRCTL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
/*
* Get the constants and structs from uapi so that code that
* includes <linux/prctl.h> doesn't conflict with <sys/prctl.h>.
*/
#include <linux/prctl.h>
int prctl (int, ...);
#ifdef __cplusplus
}
#endif
#endif
"we don't duplicate anything that's in a uapi header" is just what
bionic does for everything, all the time, but interestingly
<sys/prctl.h> is a rare header where glibc also doesn't do their usual
copy & paste and just includes <linux/prctl.h> instead. (which is why
this is an issue unique to musl, not one shared with glibc.)
On Thu, Jun 12, 2025 at 2:49 AM Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
>
> Hi,
>
> the man page for prctl(2) states:
> | SYNOPSIS
> | #include <linux/prctl.h> /* Definition of PR_* constants */
> | #include <sys/prctl.h>
>
> if one is going to include both headers then this happens:
> | In file included from file.c:6:
> | /usr/include/sys/prctl.h:88:8: error: redefinition of 'struct prctl_mm_map'
> | 88 | struct prctl_mm_map {
> | | ^~~~~~~~~~~~
> | In file included from file.c:5:
> | /linux/tools/include/uapi/linux/prctl.h:134:8: note: originally defined here
> | 134 | struct prctl_mm_map {
> | | ^~~~~~~~~~~~
>
> The problem is that musl's provided sys/prctl.h defines the struct
> prctl_mm_map which is a copy of linux kernel's linux/prctl.h. This breaks
> compiles based on the man page because that struct is defined twice.
> It makes it harder to write software which replaces linux/prctl.h with
> current header file while testing for recent features. It also increases
> the maintenance on musl's side to keep that file up to date.
>
> Could you please ship sys/prctl.h which provides the prctl() definition
> and include the PR_* definition from linux/prctl.h?
>
> This problem has been observed on Alpine Linux by Namhyung Kim [0].
>
> [0] https://lore.kernel.org/all/aEh6xO14wDSCFUDr@google.com/T/#u
>
> Sebastian
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: sys/prctl.h differences vs man page
2025-06-12 14:31 ` [musl] " enh
@ 2025-06-12 16:26 ` Rich Felker
2025-06-12 16:28 ` enh
2025-06-12 16:32 ` A. Wilcox
0 siblings, 2 replies; 13+ messages in thread
From: Rich Felker @ 2025-06-12 16:26 UTC (permalink / raw)
To: enh; +Cc: musl, Namhyung Kim, Arnaldo Carvalho de Melo,
Sebastian Andrzej Siewior
On Thu, Jun 12, 2025 at 10:31:03AM -0400, enh wrote:
> yeah, apologies that i don't think i reported this to the list before,
> but android also hit various prctl portability issues trying to use
> musl as the host libc and added this ahead of the musl <sys/prctl.h>
> as our workaround:
>
> #ifndef _SYS_PRCTL_H
> #define _SYS_PRCTL_H
>
> #ifdef __cplusplus
> extern "C" {
> #endif
>
> #include <stdint.h>
>
> /*
> * Get the constants and structs from uapi so that code that
> * includes <linux/prctl.h> doesn't conflict with <sys/prctl.h>.
> */
> #include <linux/prctl.h>
>
> int prctl (int, ...);
>
> #ifdef __cplusplus
> }
> #endif
>
> #endif
>
> "we don't duplicate anything that's in a uapi header" is just what
> bionic does for everything, all the time, but interestingly
> <sys/prctl.h> is a rare header where glibc also doesn't do their usual
> copy & paste and just includes <linux/prctl.h> instead. (which is why
> this is an issue unique to musl, not one shared with glibc.)
musl policy is generally the opposite; we don't include any linux uapi
headers and don't expect them to be namespace-safe to include from
userspace headers. Many historically haven't been, and aside from
namespace violations, they made conflicting definitions with userspace
types.
glibc is more in the middle on this, usually not including linux uapi
headers, but sometimes doing it.
I don't see where it's documented that one should include
<linux/prctl.h> to use the prctl API. It's not in my copy of the man
page.
Rich
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: sys/prctl.h differences vs man page
2025-06-12 16:26 ` Rich Felker
@ 2025-06-12 16:28 ` enh
2025-06-12 16:34 ` Rich Felker
2025-06-12 16:36 ` Thorsten Glaser
2025-06-12 16:32 ` A. Wilcox
1 sibling, 2 replies; 13+ messages in thread
From: enh @ 2025-06-12 16:28 UTC (permalink / raw)
To: Rich Felker
Cc: musl, Namhyung Kim, Arnaldo Carvalho de Melo,
Sebastian Andrzej Siewior
https://man7.org/linux/man-pages/man2/prctl.2.html
On Thu, Jun 12, 2025 at 12:26 PM Rich Felker <dalias@libc.org> wrote:
>
> On Thu, Jun 12, 2025 at 10:31:03AM -0400, enh wrote:
> > yeah, apologies that i don't think i reported this to the list before,
> > but android also hit various prctl portability issues trying to use
> > musl as the host libc and added this ahead of the musl <sys/prctl.h>
> > as our workaround:
> >
> > #ifndef _SYS_PRCTL_H
> > #define _SYS_PRCTL_H
> >
> > #ifdef __cplusplus
> > extern "C" {
> > #endif
> >
> > #include <stdint.h>
> >
> > /*
> > * Get the constants and structs from uapi so that code that
> > * includes <linux/prctl.h> doesn't conflict with <sys/prctl.h>.
> > */
> > #include <linux/prctl.h>
> >
> > int prctl (int, ...);
> >
> > #ifdef __cplusplus
> > }
> > #endif
> >
> > #endif
> >
> > "we don't duplicate anything that's in a uapi header" is just what
> > bionic does for everything, all the time, but interestingly
> > <sys/prctl.h> is a rare header where glibc also doesn't do their usual
> > copy & paste and just includes <linux/prctl.h> instead. (which is why
> > this is an issue unique to musl, not one shared with glibc.)
>
> musl policy is generally the opposite; we don't include any linux uapi
> headers and don't expect them to be namespace-safe to include from
> userspace headers. Many historically haven't been, and aside from
> namespace violations, they made conflicting definitions with userspace
> types.
>
> glibc is more in the middle on this, usually not including linux uapi
> headers, but sometimes doing it.
>
> I don't see where it's documented that one should include
> <linux/prctl.h> to use the prctl API. It's not in my copy of the man
> page.
>
> Rich
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: sys/prctl.h differences vs man page
2025-06-12 16:26 ` Rich Felker
2025-06-12 16:28 ` enh
@ 2025-06-12 16:32 ` A. Wilcox
2025-06-12 16:38 ` Rich Felker
1 sibling, 1 reply; 13+ messages in thread
From: A. Wilcox @ 2025-06-12 16:32 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 348 bytes --]
On Jun 12, 2025, at 11:26, Rich Felker <dalias@libc.org> wrote:
> I don't see where it's documented that one should include
> <linux/prctl.h> to use the prctl API. It's not in my copy of the man
> page.
>
> Rich
https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/man/man2/prctl.2?id=ae31bd15b65ce03a143860e8f4daa99fcd5125a4
[-- Attachment #2: Type: text/html, Size: 2849 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: sys/prctl.h differences vs man page
2025-06-12 16:28 ` enh
@ 2025-06-12 16:34 ` Rich Felker
2025-06-12 16:50 ` Sebastian Andrzej Siewior
2025-06-12 16:36 ` Thorsten Glaser
1 sibling, 1 reply; 13+ messages in thread
From: Rich Felker @ 2025-06-12 16:34 UTC (permalink / raw)
To: enh; +Cc: musl, Namhyung Kim, Arnaldo Carvalho de Melo,
Sebastian Andrzej Siewior
On Thu, Jun 12, 2025 at 12:28:24PM -0400, enh wrote:
> https://man7.org/linux/man-pages/man2/prctl.2.html
OK, apparently this is either a regression since the man-pages 6.8-r0
package I have here on Alpine, or an old version. Guess we should look
at the git history and how that happened...
> On Thu, Jun 12, 2025 at 12:26 PM Rich Felker <dalias@libc.org> wrote:
> >
> > On Thu, Jun 12, 2025 at 10:31:03AM -0400, enh wrote:
> > > yeah, apologies that i don't think i reported this to the list before,
> > > but android also hit various prctl portability issues trying to use
> > > musl as the host libc and added this ahead of the musl <sys/prctl.h>
> > > as our workaround:
> > >
> > > #ifndef _SYS_PRCTL_H
> > > #define _SYS_PRCTL_H
> > >
> > > #ifdef __cplusplus
> > > extern "C" {
> > > #endif
> > >
> > > #include <stdint.h>
> > >
> > > /*
> > > * Get the constants and structs from uapi so that code that
> > > * includes <linux/prctl.h> doesn't conflict with <sys/prctl.h>.
> > > */
> > > #include <linux/prctl.h>
> > >
> > > int prctl (int, ...);
> > >
> > > #ifdef __cplusplus
> > > }
> > > #endif
> > >
> > > #endif
> > >
> > > "we don't duplicate anything that's in a uapi header" is just what
> > > bionic does for everything, all the time, but interestingly
> > > <sys/prctl.h> is a rare header where glibc also doesn't do their usual
> > > copy & paste and just includes <linux/prctl.h> instead. (which is why
> > > this is an issue unique to musl, not one shared with glibc.)
> >
> > musl policy is generally the opposite; we don't include any linux uapi
> > headers and don't expect them to be namespace-safe to include from
> > userspace headers. Many historically haven't been, and aside from
> > namespace violations, they made conflicting definitions with userspace
> > types.
> >
> > glibc is more in the middle on this, usually not including linux uapi
> > headers, but sometimes doing it.
> >
> > I don't see where it's documented that one should include
> > <linux/prctl.h> to use the prctl API. It's not in my copy of the man
> > page.
> >
> > Rich
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: sys/prctl.h differences vs man page
2025-06-12 16:28 ` enh
2025-06-12 16:34 ` Rich Felker
@ 2025-06-12 16:36 ` Thorsten Glaser
1 sibling, 0 replies; 13+ messages in thread
From: Thorsten Glaser @ 2025-06-12 16:36 UTC (permalink / raw)
To: musl
On Thu, 12 Jun 2025, enh wrote:
>https://man7.org/linux/man-pages/man2/prctl.2.html
As was pointed out on this ML recently, these document the
situation for Linux/glibc.
Interestingly enough, the uapi header was added to that page
between 5.10 (on my system) and 6.10 (on the web). Might be
useful to bugreport to them to ask them to add something like
#ifdef glibc (don’t know the correct one out of my head) to
around the uapi header in that page.
bye,
//mirabilos
--
[00:02] <Vutral> gecko: benutzt du emacs ?
[00:03] <gecko> nö [00:03] <gecko> nur n normalen mac
[00:04] <Vutral> argl [00:04] <Vutral> ne den editor
-- Vutral und gecko2 in #deutsch (NB: Editor? Betriebssystem.)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: sys/prctl.h differences vs man page
2025-06-12 16:32 ` A. Wilcox
@ 2025-06-12 16:38 ` Rich Felker
2025-06-12 20:36 ` [musl] " Alejandro Colomar
0 siblings, 1 reply; 13+ messages in thread
From: Rich Felker @ 2025-06-12 16:38 UTC (permalink / raw)
To: A. Wilcox; +Cc: musl, Alejandro Colomar
On Thu, Jun 12, 2025 at 11:32:47AM -0500, A. Wilcox wrote:
> On Jun 12, 2025, at 11:26, Rich Felker <dalias@libc.org> wrote:
> > I don't see where it's documented that one should include
> > <linux/prctl.h> to use the prctl API. It's not in my copy of the man
> > page.
> >
> > Rich
>
> https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/man/man2/prctl.2?id=ae31bd15b65ce03a143860e8f4daa99fcd5125a4
CC'ing commit author on this breakage.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: sys/prctl.h differences vs man page
2025-06-12 16:34 ` Rich Felker
@ 2025-06-12 16:50 ` Sebastian Andrzej Siewior
2025-06-12 17:21 ` [musl] " Rich Felker
0 siblings, 1 reply; 13+ messages in thread
From: Sebastian Andrzej Siewior @ 2025-06-12 16:50 UTC (permalink / raw)
To: Rich Felker; +Cc: enh, musl, Namhyung Kim, Arnaldo Carvalho de Melo
On 2025-06-12 12:34:08 [-0400], Rich Felker wrote:
> On Thu, Jun 12, 2025 at 12:28:24PM -0400, enh wrote:
> > https://man7.org/linux/man-pages/man2/prctl.2.html
>
> OK, apparently this is either a regression since the man-pages 6.8-r0
> package I have here on Alpine, or an old version. Guess we should look
> at the git history and how that happened...
That would be commit
ae31bd15b65ce ("prctl.2, PR_*.2const: SYNOPSIS: #include <linux/prctl.h> for the PR_* constants")
https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/?id=ae31bd15b65ce
Commit is present since man-pages-6.9.
Sebastian
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [musl] sys/prctl.h differences vs man page
2025-06-12 16:50 ` Sebastian Andrzej Siewior
@ 2025-06-12 17:21 ` Rich Felker
2025-06-13 19:42 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 13+ messages in thread
From: Rich Felker @ 2025-06-12 17:21 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: enh, musl, Namhyung Kim, Arnaldo Carvalho de Melo
On Thu, Jun 12, 2025 at 06:50:00PM +0200, Sebastian Andrzej Siewior wrote:
> On 2025-06-12 12:34:08 [-0400], Rich Felker wrote:
> > On Thu, Jun 12, 2025 at 12:28:24PM -0400, enh wrote:
> > > https://man7.org/linux/man-pages/man2/prctl.2.html
> >
> > OK, apparently this is either a regression since the man-pages 6.8-r0
> > package I have here on Alpine, or an old version. Guess we should look
> > at the git history and how that happened...
>
> That would be commit
> ae31bd15b65ce ("prctl.2, PR_*.2const: SYNOPSIS: #include <linux/prctl.h> for the PR_* constants")
> https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/?id=ae31bd15b65ce
>
> Commit is present since man-pages-6.9.
Yes, that looks completely unmotivated and should be reverted.
In general, you should never include both the linux uapi and
userspace/libc header for the same thing.
If your libc delegates to the linux uapi header, it will already have
included it implicitly to get the definitions.
If not, the two conflict.
And abstractly: one is describing the application-to-libc-function
interface, the other is describing the raw syscall interface. You
include the header for which one you're using.
Rich
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [musl] sys/prctl.h differences vs man page
2025-06-12 16:38 ` Rich Felker
@ 2025-06-12 20:36 ` Alejandro Colomar
2025-06-12 23:01 ` Alejandro Colomar
0 siblings, 1 reply; 13+ messages in thread
From: Alejandro Colomar @ 2025-06-12 20:36 UTC (permalink / raw)
To: Rich Felker; +Cc: A. Wilcox, musl
[-- Attachment #1: Type: text/plain, Size: 1034 bytes --]
Hi Rich,
On Thu, Jun 12, 2025 at 12:38:48PM -0400, Rich Felker wrote:
> On Thu, Jun 12, 2025 at 11:32:47AM -0500, A. Wilcox wrote:
> > On Jun 12, 2025, at 11:26, Rich Felker <dalias@libc.org> wrote:
> > > I don't see where it's documented that one should include
> > > <linux/prctl.h> to use the prctl API. It's not in my copy of the man
> > > page.
> > >
> > > Rich
> >
> > https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/man/man2/prctl.2?id=ae31bd15b65ce03a143860e8f4daa99fcd5125a4
>
> CC'ing commit author on this breakage.
I'd say I only changed the formatting of the information, but the manual
page already claimed you should include both <sys/prctl.h> and
<linux/prctl.h>; it just dit it in a weird way.
So, should we consider <sys/prctl.h> to be the provider of PR_*
constants? I'd be happy to update the manual page, but libc maintainers
should state what is the official header for the PR_* constants.
Have a lovely day!
Alex
--
<https://www.alejandro-colomar.es/>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [musl] sys/prctl.h differences vs man page
2025-06-12 20:36 ` [musl] " Alejandro Colomar
@ 2025-06-12 23:01 ` Alejandro Colomar
0 siblings, 0 replies; 13+ messages in thread
From: Alejandro Colomar @ 2025-06-12 23:01 UTC (permalink / raw)
To: Rich Felker
Cc: A. Wilcox, musl-ZwoEplunGu1jrUoiu81ncdBPR1lH4CV8,
linux-man-u79uwXL29TY76Z2rM5mHXA,
libc-help-9JcytcrH/bA+uJoB2kUjGw
[-- Attachment #1: Type: text/plain, Size: 5564 bytes --]
[CC += linux-man@, libc-help@]
Hi Rich,
On Thu, Jun 12, 2025 at 10:37:00PM +0200, Alejandro Colomar wrote:
> Hi Rich,
>
> On Thu, Jun 12, 2025 at 12:38:48PM -0400, Rich Felker wrote:
> > On Thu, Jun 12, 2025 at 11:32:47AM -0500, A. Wilcox wrote:
> > > On Jun 12, 2025, at 11:26, Rich Felker <dalias-8zAoT0mYgF4@public.gmane.org> wrote:
> > > > I don't see where it's documented that one should include
> > > > <linux/prctl.h> to use the prctl API. It's not in my copy of the man
> > > > page.
> > > >
> > > > Rich
> > >
> > > https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/man/man2/prctl.2?id=ae31bd15b65ce03a143860e8f4daa99fcd5125a4
> >
> > CC'ing commit author on this breakage.
>
> I'd say I only changed the formatting of the information, but the manual
> page already claimed you should include both <sys/prctl.h> and
> <linux/prctl.h>; it just dit it in a weird way.
>
> So, should we consider <sys/prctl.h> to be the provider of PR_*
> constants? I'd be happy to update the manual page, but libc maintainers
> should state what is the official header for the PR_* constants.
Here's some research about the history of this manual page:
alx@devuan:~/src/linux/man-pages/man-pages/master$ git blame -- man/man2/prctl.2 | grep 'linux/prctl.h'
ae31bd15b6 man/man2/prctl.2 (Alejandro Colomar 2024-05-31 21:47:29 +0200 15) .BR "#include <linux/prctl.h>" " /* Definition of " PR_* " constants */"
alx@devuan:~/src/linux/man-pages/man-pages/master$ git show ae31bd15b6 -- man/man2/prctl.2 | grep -e ^diff -e linux/prctl.h | grep -v -B1 ^d
prctl.2, PR_*.2const: SYNOPSIS: #include <linux/prctl.h> for the PR_* constants
diff --git a/man/man2/prctl.2 b/man/man2/prctl.2
+.BR "#include <linux/prctl.h>" " /* Definition of " PR_* " constants */"
-(with values defined in \fI<linux/prctl.h>\fP), and further
alx@devuan:~/src/linux/man-pages/man-pages/master$ git blame ae31bd15b6^ -- man/man2/prctl.2 | grep 'linux/prctl.h'
1a329b567a man2/prctl.2 (Michael Kerrisk 2007-12-10 07:16:56 +0000 35) (with values defined in \fI<linux/prctl.h>\fP), and further
alx@devuan:~/src/linux/man-pages/man-pages/master$ git show 1a329b567a -- man2/prctl.2 | grep -e ^diff -e linux/prctl.h | grep -v -B1 ^d
diff --git a/man2/prctl.2 b/man2/prctl.2
-(with values defined in <\fIlinux/prctl.h\fP>), and further
+(with values defined in \fI<linux/prctl.h>\fP), and further
alx@devuan:~/src/linux/man-pages/man-pages/master$ git blame 1a329b567a^ -- man2/prctl.2 | grep 'linux/prctl.h'
^fea681daf (Michael Kerrisk 2004-11-03 13:51:07 +0000 50) (with values defined in <\fIlinux/prctl.h\fP>), and further
alx@devuan:~/src/linux/man-pages/man-pages/master$ git blame korg/prehistory -- man2/prctl.2 | grep 'linux/prctl.h'
3b676b1346 (Krónos 1998-04-19 23:53:00 +0200 44) (with values defined in <\fIlinux/prctl.h\fP>), and further
alx@devuan:~/src/linux/man-pages/man-pages/master$ git show 3b676b1346 -- man2/prctl.2 | grep -e ^diff -e linux/prctl.h | grep -v -B1 ^d
diff --git a/man2/prctl.2 b/man2/prctl.2
+.B #include <linux/prctl.h>
+(with values defined in <\fIlinux/prctl.h\fP>), and further
alx@devuan:~/src/linux/man-pages/man-pages/master$ git log --pretty=fuller -1 3b676b1346 | head
commit 3b676b1346f336fd0e9841365689f2dde1dff528
Author: Krónos <Krónos@Sāturnus>
AuthorDate: Sun Apr 19 23:53:00 1998 +0200
Commit: Alejandro Colomar <alx-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
CommitDate: Mon Dec 19 21:01:33 2022 +0100
man-pages 1.19
Link: <https://www.win.tue.nl/~aeb/ftpdocs/linux-local/manpages.archive/>
Signed-off-by: Alejandro Colomar <alx-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
In man-pages-1.19, the text saying that <linux/prctl.h> provides PR_*
was added. It also included the header in the SYNOPSIS.
alx@devuan:~/src/linux/man-pages/man-pages/master$ git blame -- man/man2/prctl.2 | grep 'sys/prctl.h'
^fea681daf man2/prctl.2 (Michael Kerrisk 2004-11-03 13:51:07 +0000 16) .B #include <sys/prctl.h>
alx@devuan:~/src/linux/man-pages/man-pages/master$ git blame korg/prehistory -- man2/prctl.2 | grep 'sys/prctl.h'
1205550985 (Krónos 2000-03-06 01:54:00 +0100 37) .B #include <sys/prctl.h>
alx@devuan:~/src/linux/man-pages/man-pages/master$ git show 1205550985 -- man2/prctl.2 | grep -e ^diff -e /prctl.h | grep -v -B1 ^d
diff --git a/man2/prctl.2 b/man2/prctl.2
-.B #include <linux/prctl.h>
+.B #include <sys/prctl.h>
alx@devuan:~/src/linux/man-pages/man-pages/master$ git log --pretty=fuller -1 1205550985 | head
commit 1205550985885436f2554b2ed38c6c565118c979
Author: Krónos <Krónos@Sāturnus>
AuthorDate: Mon Mar 6 01:54:00 2000 +0100
Commit: Alejandro Colomar <alx-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
CommitDate: Mon Dec 19 21:01:34 2022 +0100
man-pages 1.29
Link: <https://www.win.tue.nl/~aeb/ftpdocs/linux-local/manpages.archive/>
Signed-off-by: Alejandro Colomar <alx-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
In man-pages-1.29, the SYNOPSIS was updated to show <sys/prctl.h>, but
the text within the DESCRIPTION saying that <linux/prctl.h> was the
provider of these macros wasn't removed.
I don't know if it should have been removed back then and they forgot,
or if something has changed in the meantime and nobody documented it.
Please suggest what changes should be applied to the manual page.
Have a lovely night!
Alex
--
<https://www.alejandro-colomar.es/>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: sys/prctl.h differences vs man page
2025-06-12 17:21 ` [musl] " Rich Felker
@ 2025-06-13 19:42 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-06-13 19:42 UTC (permalink / raw)
To: Rich Felker, Sebastian Andrzej Siewior
Cc: enh, musl, Namhyung Kim, Adrian Hunter, Ian Rogers, James Clark,
Jiri Olsa, Kan Liang
On Thu, Jun 12, 2025 at 01:21:26PM -0400, Rich Felker wrote:
> On Thu, Jun 12, 2025 at 06:50:00PM +0200, Sebastian Andrzej Siewior wrote:
> > On 2025-06-12 12:34:08 [-0400], Rich Felker wrote:
> > > On Thu, Jun 12, 2025 at 12:28:24PM -0400, enh wrote:
> > > > https://man7.org/linux/man-pages/man2/prctl.2.html
> > > OK, apparently this is either a regression since the man-pages 6.8-r0
> > > package I have here on Alpine, or an old version. Guess we should look
> > > at the git history and how that happened...
> > That would be commit
> > ae31bd15b65ce ("prctl.2, PR_*.2const: SYNOPSIS: #include <linux/prctl.h> for the PR_* constants")
> > https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/?id=ae31bd15b65ce
> > Commit is present since man-pages-6.9.
>
> Yes, that looks completely unmotivated and should be reverted.
> In general, you should never include both the linux uapi and
> userspace/libc header for the same thing.
So glibc has:
⬢ [acme@toolbx perf-tools]$ rpm -qf /usr/include/sys/prctl.h
glibc-devel-2.41-5.fc42.x86_64
⬢ [acme@toolbx perf-tools]$ grep include /usr/include/sys/prctl.h
#include <features.h>
#include <linux/prctl.h> /* The magic values come from here */
⬢ [acme@toolbx perf-tools]$
So we don't need to include linux/prctl.h
We do it in perf to get the newest stuff, and then it works, but since
musl doesn't do this, i.e. includes linux/prctl.h, it doesn't get the
copy we have, so I think at this point we're stuck with:
diff --git a/tools/perf/bench/futex-hash.c b/tools/perf/bench/futex-hash.c
index fdf133c9520f73a4..d2d6d7f3ea331c84 100644
--- a/tools/perf/bench/futex-hash.c
+++ b/tools/perf/bench/futex-hash.c
@@ -18,7 +18,6 @@
#include <stdlib.h>
#include <linux/compiler.h>
#include <linux/kernel.h>
-#include <linux/prctl.h>
#include <linux/zalloc.h>
#include <sys/time.h>
#include <sys/mman.h>
diff --git a/tools/perf/bench/futex.c b/tools/perf/bench/futex.c
index 26382e4d8d4ce2ff..4c4fee107e5912d5 100644
--- a/tools/perf/bench/futex.c
+++ b/tools/perf/bench/futex.c
@@ -2,11 +2,18 @@
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
-#include <linux/prctl.h>
#include <sys/prctl.h>
#include "futex.h"
+#ifndef PR_FUTEX_HASH
+#define PR_FUTEX_HASH 78
+# define PR_FUTEX_HASH_SET_SLOTS 1
+# define FH_FLAG_IMMUTABLE (1ULL << 0)
+# define PR_FUTEX_HASH_GET_SLOTS 2
+# define PR_FUTEX_HASH_GET_IMMUTABLE 3
+#endif // PR_FUTEX_HASH
+
void futex_set_nbuckets_param(struct bench_futex_parameters *params)
{
unsigned long flags;
(END)
Which at this point is, as I added stuff after trying to build it in the
set of containers I have, attributed to:
commit 699450aed5456001d1c9232562a753b1ca96ea73 (HEAD -> perf-tools)
Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed Jun 11 11:25:42 2025 +0200
perf bench futex: Fix prctl include in musl libc
With:
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reported-by: Namhyung Kim <namhyung@kernel.org>
Closes: https://lore.kernel.org/r/20250611092542.F4ooE2FL@linutronix.de
[ Remove one more in tools/perf/bench/futex-hash.c and conditionally define PR_FUTEX_HASH and friends ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Sebastian, can I keep this? If you disagree with this attribution and
prefer for me to take the blame, lemme know, but I want to get this
moving.
- Arnaldo
^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-06-13 19:42 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-12 6:49 sys/prctl.h differences vs man page Sebastian Andrzej Siewior
2025-06-12 14:31 ` [musl] " enh
2025-06-12 16:26 ` Rich Felker
2025-06-12 16:28 ` enh
2025-06-12 16:34 ` Rich Felker
2025-06-12 16:50 ` Sebastian Andrzej Siewior
2025-06-12 17:21 ` [musl] " Rich Felker
2025-06-13 19:42 ` Arnaldo Carvalho de Melo
2025-06-12 16:36 ` Thorsten Glaser
2025-06-12 16:32 ` A. Wilcox
2025-06-12 16:38 ` Rich Felker
2025-06-12 20:36 ` [musl] " Alejandro Colomar
2025-06-12 23:01 ` Alejandro Colomar
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).