From patchwork Fri May 22 13:35:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Joel Fernandes (Google)" X-Patchwork-Id: 39352 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A66C6383F848; Fri, 22 May 2020 13:35:34 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by sourceware.org (Postfix) with ESMTPS id 9D6EA385E830 for ; Fri, 22 May 2020 13:35:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9D6EA385E830 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=joelfernandes.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=joel@joelfernandes.org Received: by mail-qt1-x841.google.com with SMTP id m64so8269961qtd.4 for ; Fri, 22 May 2020 06:35:29 -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=jjwdLDuEx0h3mFKUAmDQy4/eU5wkoGjWBnh5tJZd8wEsirZRIoR+a95SvcaFgL7nWI PpgW+pVSJYb2KYCzgfYUO+HVZBM4B2xeZlZ5NCW77TcGQd3L+apLPtcMzepyHDe8sTKv zw3OnfC646zJrbzxAWNGPzsSMEahVyHhxr/pP6DgBdaiM6TB7sr8GoPkNx5sQFiyKMLl Ky/fyo1zeRdVqBdwA/lx6awKZRnpeSD1tEsuT2CL9Q7UwxhI5chgouuztGdEsvpFIXu5 tCcXEeK4qEDEJ67srnSIz+kS0r7oy1O6GKWSKuOiXSlvmhT/Qg0yEW7WsgOcXnDugeoU HKnA== X-Gm-Message-State: AOAM531e2WSsIL7BjJc+F5++ZtvcqlEfWwh85kY1KamPQsYtGYaH2MIl SSD4nz8hIV93DUbnQnWmd0iU6g== X-Google-Smtp-Source: ABdhPJz1FUSjDoLtfHJN/Zeql66rPIzcdUtptDSzo52IvftehA3efMQx/T0H8ocig9sAnzaM1pbAfQ== 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 Subject: [PATCH RFC v2] sched/headers: Fix sched_setattr userspace compilation issues Message-ID: <20200522133528.GA210175@google.com> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email 2.26.2.761.g0e0b3e54be-goog X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: libc-alpha@sourceware.org, vpillai@digitalocean.com, gregkh@linuxfoundation.org, stable@vger.kernel.org, vineethrp@gmail.com, peterz@infradead.org, matthewb@google.com, vapier@google.com, "Joel Fernandes \(Google\)" , jsbarnes@google.com Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" 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} */