Stable Archive on
 help / color / Atom feed
* [PATCH RFC v2] sched/headers: Fix sched_setattr userspace compilation issues
@ 2020-05-22 13:35 Joel Fernandes (Google)
  0 siblings, 0 replies; only message in thread
From: Joel Fernandes (Google) @ 2020-05-22 13:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: Joel Fernandes (Google),
	matthewb, jsbarnes, vapier, christian, vpillai, vineethrp,
	peterz, stable, gregkh, libc-alpha

On a modern Linux distro, compiling the following program fails:

 void main() {
         struct sched_attr sa;


/usr/include/linux/sched/types.h:8:8: \
			error: redefinition of ‘struct sched_param’
    8 | struct sched_param {
      |        ^~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/bits/sched.h:74,
                 from /usr/include/sched.h:43,
                 from /usr/include/pthread.h:23,
                 from /tmp/s.c:4:
note: originally defined here
   23 | struct sched_param
      |        ^~~~~~~~~~~

This is also causing a problem with using sched_attr in Chrome. The issue is
struct sched_param is already provided by glibc and is in POSIX.

Guard the kernel's UAPI definition of sched_param with __KERNEL__ so
that userspace and the kernel can both compile.

Signed-off-by: Joel Fernandes (Google) <>
With the chance that libc needs resolving something, I'm resending with
libc-alpha added as suggested by Christian, and minor commit message fixes.

 include/uapi/linux/sched/types.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/uapi/linux/sched/types.h b/include/uapi/linux/sched/types.h
index c852153ddb0d3..1f10d935a63fe 100644
--- a/include/uapi/linux/sched/types.h
+++ b/include/uapi/linux/sched/types.h
@@ -4,9 +4,11 @@
 #include <linux/types.h>
+#if defined(__KERNEL__)
 struct sched_param {
 	int sched_priority;
 #define SCHED_ATTR_SIZE_VER0	48	/* sizeof first published struct */
 #define SCHED_ATTR_SIZE_VER1	56	/* add: util_{min,max} */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-22 13:35 [PATCH RFC v2] sched/headers: Fix sched_setattr userspace compilation issues Joel Fernandes (Google)

Stable Archive on

Archives are clonable:
	git clone --mirror stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ \
	public-inbox-index stable

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone