Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp447832ybm; Thu, 28 May 2020 06:58:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUsuWVtbhoWrUr2tFnQIKQh30OA40n8oiQwRrkzeG/Q/Re29obWjHUuAKPAVGEG6K/Jpk0 X-Received: by 2002:a05:6402:1bd9:: with SMTP id ch25mr3151133edb.15.1590674312768; Thu, 28 May 2020 06:58:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590674312; cv=none; d=google.com; s=arc-20160816; b=ig4nfd50I52CPHH4MIZwqxlu3QsC/eJmjtlHNX+98efUtU8Hadeh3R7uVhoOYXuBrG 55prVSPzTkwitbDW6QSf3mRtW3vbH3QJlg/m0rC/tpqbJuDaFYPEFghRYllU5z4E8W53 sJeOIU3pKj7QYK9jwg3cxY0VulRHJ1M1fF6WUCLAaPHqG88nXZ1oonCN4VzMUF80N2D1 HWsVsXohZ5pe+oBvNrztzfwx/8Hrca0Wls5XVNkkesyC2+Vbqm01vIwvBxDPftgYk8nO swc+T9HE4jGqoaTLa1kAV5opC9GtRSJC7i3MBzABgPbwcgrye5KVN954v/jo2bmYVMbR AgzQ== 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=hwB4H+90PXovf4SJvJe9+Rj3bMo+et+KhIqFvByMq6E=; b=qkhAefEDkgMHf/EDocbRPPHZaRLn0H2AghsJvRIpUgILGb51/bys1ezXITFln+QUH/ Fc6f8mjE/rbY5e51/TgKmRgAco088TpgtDoXUuCqJXyyfgDgoloig0GgLkA15rXorLo5 +HZXZx3TZu5Yd9cj71uaHT36ian9TqLSy4/RtORBvx69rHUBagOjlJJ0eXSCg1ha5+Bt xInvXiL+PTRAhSmH0IWTGQpnRruDK2hzea7KmzMWEQ+nwp5SmPKCuhjlufZQ9X1lBA94 vu6/fRvqKGCjn99/zb7QoX2KQEyyN2pbhHWJnJjTHdPnOFV7QOWjDUly/+JaVoILD1rR NVdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=u6+8QPPP; 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 i12si4054196ejc.462.2020.05.28.06.58.09; Thu, 28 May 2020 06:58:32 -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=u6+8QPPP; 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 S2390833AbgE1Nz4 (ORCPT + 99 others); Thu, 28 May 2020 09:55:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390608AbgE1Nzz (ORCPT ); Thu, 28 May 2020 09:55:55 -0400 Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 910EEC08C5C6 for ; Thu, 28 May 2020 06:55:54 -0700 (PDT) Received: by mail-qv1-xf41.google.com with SMTP id e20so754295qvu.0 for ; Thu, 28 May 2020 06:55:54 -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=hwB4H+90PXovf4SJvJe9+Rj3bMo+et+KhIqFvByMq6E=; b=u6+8QPPPQ1evhnU+zHhuhm+H6IU6aanMcMS3N8hvXpt7mbcsnohnFQr8PfqOqRzsuo sKSkl/Azd37Ky+PuLPfAPk1Q6hke/3fsvRg1YUS5wyyFnLnJWFKYU42bpZjHzRae8MJw iAzXuxKIWvvjrwsScr1hxlJuUnCmcKdiRoRb4= 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=hwB4H+90PXovf4SJvJe9+Rj3bMo+et+KhIqFvByMq6E=; b=gWWfSq0uHEmfd8I0/CuJS8pC/lx4iiUb0OIHAFPV5YJ/03PAv/OGUcW4uWGi9kb/lJ mwIfCi8b+9mhXE3lueGO9jxHHvrIws05bcZusfrUve2a4WfASGt0hCcRpBPvuOpGeqNt +u1YVqcQmAcQmbYsdwfu15Z6jUKUWB9OEm17VNbKbMouDnxnjH2qXjXiFKfGqFXp+BAU k04j2GRJmVBVCJD0CTZzAxDX5usOgFHZVHIzDi7Q183OkWHzrM73ZrrbK9TEjmgRdINp x9yLeWEcdLlOcBG3SZz8BMTWKZTNg52iRmRsD8N/tRPx5epxIE32FbIPf9XnVVSR5l6l wRtw== X-Gm-Message-State: AOAM531wZKhQtg3X1C+n0KTheVLuZGnmr5U+wzGy/DNw/syjBiDjKhe8 0fn8ykAKraaFR/iPCEtMyzobTJlFjHQ= X-Received: by 2002:ad4:404b:: with SMTP id r11mr3286859qvp.44.1590674153409; Thu, 28 May 2020 06:55:53 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id e34sm5186424qtb.21.2020.05.28.06.55.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2020 06:55:52 -0700 (PDT) Date: Thu, 28 May 2020 09:55:52 -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, torvalds@linux-foundation.org Subject: [PATCH] sched/headers: Fix sched_setattr userspace compilation breakage Message-ID: <20200528135552.GA87103@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 also causes a problem with using sched_attr in 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. Fixes: e2d1e2aec572a ("sched/headers: Move various ABI definitions to " Signed-off-by: Joel Fernandes (Google) --- 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