From: Joel Fernandes <joel@joelfernandes.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Matthew Blecker <matthewb@google.com>,
Jesse Barnes <jsbarnes@google.com>,
Mike Frysinger <vapier@google.com>,
Christian Brauner <christian@brauner.io>,
Vineeth Remanan Pillai <vpillai@digitalocean.com>,
vineethrp@gmail.com, Peter Zijlstra <peterz@infradead.org>,
stable <stable@vger.kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH RFC] sched/headers: Fix sched_setattr userspace compilation issues
Date: Thu, 21 May 2020 11:55:21 -0400 [thread overview]
Message-ID: <CAEXW_YTj83gO0STovrOuL9zgDwEYWRJusUZ3ebVw_jOG6yJxTg@mail.gmail.com> (raw)
In-Reply-To: <20200521155346.168413-1-joel@joelfernandes.org>
On Thu, May 21, 2020 at 11:53 AM Joel Fernandes (Google)
<joel@joelfernandes.org> wrote:
>
> On a modern Linux distro, compiling the following program fails:
> #include<stdlib.h>
> #include<stdint.h>
> #include<pthread.h>
> #include<linux/sched/types.h>
>
> void main() {
> struct sched_attr sa;
>
> return;
> }
>
> with:
> /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:
> /usr/include/x86_64-linux-gnu/bits/types/struct_sched_param.h:23:8:
> note: originally defined here
> 23 | struct sched_param
> | ^~~~~~~~~~~
>
> This is also causing a problem on using sched_attr Chrome. The issue is
> sched_param is already provided by glibc.
>
> Guard the kernel's UAPI definition of sched_param with __KERNEL__ so
> that userspace can compile.
>
> Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
If it is more preferable, another option is to move sched_param to
include/linux/sched/types.h
- Joel
> ---
> 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;
> };
> +#endif
>
> #define SCHED_ATTR_SIZE_VER0 48 /* sizeof first published struct */
> #define SCHED_ATTR_SIZE_VER1 56 /* add: util_{min,max} */
> --
> 2.26.2.761.g0e0b3e54be-goog
>
next prev parent reply other threads:[~2020-05-21 15:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-21 15:53 [PATCH RFC] sched/headers: Fix sched_setattr userspace compilation issues Joel Fernandes (Google)
2020-05-21 15:55 ` Joel Fernandes [this message]
2020-05-22 13:13 ` Christian Brauner
2020-05-22 13:38 ` Joel Fernandes
2020-05-22 13:46 ` Christian Brauner
2020-05-22 14:02 ` Peter Zijlstra
2020-05-22 19:08 ` Joel Fernandes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAEXW_YTj83gO0STovrOuL9zgDwEYWRJusUZ3ebVw_jOG6yJxTg@mail.gmail.com \
--to=joel@joelfernandes.org \
--cc=christian@brauner.io \
--cc=gregkh@linuxfoundation.org \
--cc=jsbarnes@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matthewb@google.com \
--cc=peterz@infradead.org \
--cc=stable@vger.kernel.org \
--cc=vapier@google.com \
--cc=vineethrp@gmail.com \
--cc=vpillai@digitalocean.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).