From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C906EC433DF for ; Fri, 22 May 2020 13:46:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F0172087E for ; Fri, 22 May 2020 13:46:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729839AbgEVNqx (ORCPT ); Fri, 22 May 2020 09:46:53 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:36161 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729406AbgEVNqx (ORCPT ); Fri, 22 May 2020 09:46:53 -0400 Received: from ip5f5af183.dynamic.kabel-deutschland.de ([95.90.241.131] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jc80g-0001Cc-Mb; Fri, 22 May 2020 13:46:50 +0000 Date: Fri, 22 May 2020 15:46:49 +0200 From: Christian Brauner To: Joel Fernandes Cc: LKML , Matthew Blecker , Jesse Barnes , Mike Frysinger , Christian Brauner , Vineeth Remanan Pillai , vineethrp@gmail.com, Peter Zijlstra , stable , Greg Kroah-Hartman Subject: Re: [PATCH RFC] sched/headers: Fix sched_setattr userspace compilation issues Message-ID: <20200522134649.lcqgwbgbnqxebcng@wittgenstein> References: <20200521155346.168413-1-joel@joelfernandes.org> <20200522131355.f4bdc2f4h2zyqbku@wittgenstein> <20200522133816.GB210175@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200522133816.GB210175@google.com> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Fri, May 22, 2020 at 09:38:16AM -0400, Joel Fernandes wrote: > On Fri, May 22, 2020 at 03:13:55PM +0200, Christian Brauner wrote: > > On Thu, May 21, 2020 at 11:55:21AM -0400, Joel Fernandes wrote: > > > On Thu, May 21, 2020 at 11:53 AM Joel Fernandes (Google) > > > wrote: > > > > > > > > On a modern Linux distro, compiling the following program fails: > > > > #include > > > > #include > > > > #include > > > > #include > > > > > > > > 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) > > > > > > If it is more preferable, another option is to move sched_param to > > > include/linux/sched/types.h > > > > Might it be worth Ccing libc-alpha here? Seems like one of those classic > > header conflicts. > > sched_param is defined by POSIX from my reading of the manpage. Is the kernel > supposed to define it in the UAPI at all? I guarded it with __KERNEL__ as you > can see. Your patch is fine of course. :) It's just that conflicts like this have happened before. Another conflict is e.g. in wait.h where the kernel has #define P_* and libc has an enum for P_* and it's not at all guaranteed that they are identical. Plus, sometimes the order of header inclusion matters because of things like this (or something like this). That's why having it seen on libc-alpha might help prevent accidentaly causing bugs where you now include a header that gives you a different definition than you expected. > > Resent with libc-alpha CC'd per your suggestion. Thanks! Christian