Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp284248ybr; Fri, 22 May 2020 06:38:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3iIBn16d1JzlQWyTJYCnkQrXaEnUi15Txt+pF0HBH91qtDrgciiadPz7puezxDMhOXU+9 X-Received: by 2002:a50:8750:: with SMTP id 16mr2875342edv.309.1590154694592; Fri, 22 May 2020 06:38:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590154694; cv=none; d=google.com; s=arc-20160816; b=shP/zQqFZnd6JGVnhl/ZAmDn25gID6A5CLPlHOYr3Bo1mgLaViXS3Bc1FRvEM1/ka+ U/uVk1ggzUM/HxrqjYZZeZFn910AS/rmjZQGbU3uqIycnUxz4Fd8EHqegVxPXl/mWCxz BRp2PlcAqfGXgRnh4mVVgaulBeYM1FMSP3UPQdMtzOzq0auA9OPtkN0G6f+1g3ZcQ3qT QeO5FXASfRNkDd0ckniKc0ZeStvLpP1h6YeuHJc/ini3JWGT+7hqPXRHoYADn2sr8w5k c4XTUUbdAp4vOt4WmkZLRcJfb8S99FyHbPj40vfuz3dadVfjtDzILDz3eRFpdadeAFoe yH3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=654C6HMAJavjEr0S4/IKvBvbc+mHWyzBMrpEJYlc/nQ=; b=kfwz/hxBRFZbmRp4g35p4TfkGmJV6W7oqX7eAgU+deuSArfBu+4JuEDuUuDtAuyoCT opAkJzCP6cSYsx9AabZJeRFwNyUjJCYrZlkxQpwoVbFhvquIb+z8Rce4Il60Q3FCGMZY oPKEa69rtVIpPMStJef2UWsGs/VB2+gV5oDsTJUJJuP8pz0yjRSpiwrQx/Jym/fF6Xnc 2AGsj8pGJO3hJg9fQOW4mwPwWDJwkPHuacKvQiaNHvcd1sDIWB7Dh1Kf9kUWEBPVEirn NpestnVrcrQ8KuTlux2Fk6hu5qqZYLx5TNthqlSpRo9XHDF4kAHywsEwMDcbVFFa0J5A 1/FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=DmsE28c0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si892783ejr.290.2020.05.22.06.37.51; Fri, 22 May 2020 06:38:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=DmsE28c0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729868AbgEVNfb (ORCPT + 99 others); Fri, 22 May 2020 09:35:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729406AbgEVNfb (ORCPT ); Fri, 22 May 2020 09:35:31 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DC4CC05BD43 for ; Fri, 22 May 2020 06:35:30 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id p12so8217331qtn.13 for ; Fri, 22 May 2020 06:35:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding; bh=654C6HMAJavjEr0S4/IKvBvbc+mHWyzBMrpEJYlc/nQ=; b=DmsE28c0J4Ygt6MtPOMJu6De7QbehaWK0RU3Yt0kC42y6Vc7yki+njWWBM7fLypkG/ UEXTDSBaYM3HFOvM8cVvl53RjaU6IhdSf0zLQ0DUHW4aXXe5/znsiuC1r0m6VIenhnt/ 8+yupTCx847h5bTOXDYzsIAHc6vXTr9aNLSGE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding; bh=654C6HMAJavjEr0S4/IKvBvbc+mHWyzBMrpEJYlc/nQ=; b=HYQAhqHVdD8dGPuGTDW+uPIuU1LNvskqINO0fbWOkSJ+mpReMp6lXc/5J7go9eAGDV w8h77Ml2+bVZJZfNNl9a3AmQlUBU640y2LRCM8SUVZgS/kfxC7Ugbuo8d00/38Rajgq4 xIlUM61H0/er1dxU9SlvVxsWwXaCcW1F5ZAEmBcRItHBluwofdWrOQ/+8GbsckUhr2Jv IghftLm5GHijo+nZhP2gWUDwULKIz2wHQ57K2lPMESNR4Lt5rwmC+ZSeBN6CoeWrl7/r JvqDAcCd7139kzAlOe8q2iqeEh/WQXkccN/kD5mAd7pbQo4pDbLhhZjicJ2LgncGw3Ui wLZw== X-Gm-Message-State: AOAM532Y3waJi3+c4baLnU5DUMHksPfCAwqRYDS/SvAZfZwxhrQoxSgS ++3TX013oC720L/RUT1oKg7dL9sb24s= X-Received: by 2002:ac8:71c1:: with SMTP id i1mr7363784qtp.320.1590154529140; Fri, 22 May 2020 06:35:29 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id q46sm2013046qta.79.2020.05.22.06.35.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 06:35:28 -0700 (PDT) Date: Fri, 22 May 2020 09:35:28 -0400 From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , matthewb@google.com, jsbarnes@google.com, vapier@google.com, christian@brauner.io, vpillai@digitalocean.com, vineethrp@gmail.com, peterz@infradead.org, stable@vger.kernel.org, gregkh@linuxfoundation.org, libc-alpha@sourceware.org Subject: [PATCH RFC v2] sched/headers: Fix sched_setattr userspace compilation issues Message-ID: <20200522133528.GA210175@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Mailer: git-send-email 2.26.2.761.g0e0b3e54be-goog Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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) --- v1->v2: 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 +#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