From patchwork Tue Aug 8 03:03:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kir Kolyshkin X-Patchwork-Id: 73786 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 E91C53857355 for ; Tue, 8 Aug 2023 03:04:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E91C53857355 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1691463888; bh=lU9dy9acxPivAK9sAqV8O5YVQrlBKU/PVmJCwK+iI40=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=mLw2Yj32UNrcDlP5ramn19+ziWZ8LAH1rycgO7ONSC2k49unHToyqJ6VkYBTcqTkV rjThWC6RixZdwE2rfwNjVDxi1sHj0bDc73r4sWh+zXrd/m+/JN31DnUmUOuxkMohr9 MVsvNOPhIfiXEa3H5RIKnIndLB4Oc692nujZy7vM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by sourceware.org (Postfix) with ESMTPS id E20283858416 for ; Tue, 8 Aug 2023 03:04:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E20283858416 Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3a44cccbd96so3601076b6e.3 for ; Mon, 07 Aug 2023 20:04:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691463864; x=1692068664; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lU9dy9acxPivAK9sAqV8O5YVQrlBKU/PVmJCwK+iI40=; b=ZuvjI90sTsmlpg8JwHtKBdd4FBB/lX91028NtNF3+6NJP6AIUJZMyBo8IUF/LLCO9Y zMKLP2Ykp6507qNMvtUf2ZNXhVfxrvp5A70iszEf2kXKTCG2TMki9GAo8xSWEF7kzIjC qqDYpc1HZaewK1vPDc6egCubEKLjIKzDqiID5A8srhWyqdO7NpdM6PSDJRKirezR2cV1 vsjjTkXz+4zqlpqVrRmpSRw7Wz7/MbqoZN167K8TLHWxvI3dYRuHkQP8Dicz5DSECE1S PBS4xP9I/Nlzj4PNHlmze7169l8pTFH+c3xPEDQtvIuYwxxvwxhwbvVT/mmcF4mjv8XY z4QA== X-Gm-Message-State: AOJu0Yyc1RhK7N8UiVmjVlCPaq7nfDJut/d08xMoX9rbIidiHw3mRMM4 YVBDMKOraz8Snq5we8Tj7m4= X-Google-Smtp-Source: AGHT+IFywI2BuYDLZVDGsdFfFF6DvxQuyBA8SR3uuOj7it5jlV6PY2OX2KTP4ilZALeWIK9XjjALHQ== X-Received: by 2002:aca:170d:0:b0:3a7:a34a:ea9 with SMTP id j13-20020aca170d000000b003a7a34a0ea9mr3018690oii.56.1691463863950; Mon, 07 Aug 2023 20:04:23 -0700 (PDT) Received: from kir-rhat.lan (c-76-104-243-248.hsd1.wa.comcast.net. [76.104.243.248]) by smtp.gmail.com with ESMTPSA id b2-20020a17090a010200b002636dfcc6f5sm7276425pjb.3.2023.08.07.20.04.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 20:04:23 -0700 (PDT) To: linux-kernel@vger.kernel.org Cc: Kir Kolyshkin , libc-alpha@sourceware.org, musl@lists.openwall.com, linux-api@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Joel Fernandes , Christian Brauner Subject: [PATCH] sched/headers: move struct sched_param out of uapi Date: Mon, 7 Aug 2023 20:03:57 -0700 Message-ID: <20230808030357.1213829-1-kolyshkin@gmail.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , X-Patchwork-Original-From: Kir Kolyshkin via Libc-alpha From: Kir Kolyshkin Reply-To: Kir Kolyshkin Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Both glibc and musl define struct sched_param in sched.h, while kernel has it in uapi/linux/sched/types.h, making it cumbersome to use sched_getattr(2) or sched_setattr(2) from userspace. For example, something like this: #include #include struct sched_attr sa; will result in "error: redefinition of ‘struct sched_param’" (note the code doesn't need sched_param at all -- it needs struct sched_attr plus some stuff from sched.h). The situation is, glibc is not going to provide a wrapper for sched_{get,set}attr, thus the need to include linux/sched_types.h directly, which leads to the above problem. Thus, the userspace is left with a few sub-par choices when it wants to use e.g. sched_setattr(2), such as maintaining a copy of struct sched_attr definition, or using some other ugly tricks. OTOH, struct sched_param is well known, defined in POSIX, and it won't be ever changed (as that would break backward compatibility). So, while struct sched_param is indeed part of the kernel uapi, exposing it the way it's done now creates an issue, and hiding it (like this patch does) fixes that issue, hopefully without creating another one: common userspace software rely on libc headers, and as for "special" software (like libc), it looks like glibc and musl do not rely on kernel headers for struct sched_param definition (but let's Cc their mailing lists in case it's otherwise). The alternative to this patch would be to move struct sched_attr to, say, linux/sched.h, or linux/sched/attr.h (the new file). Oh, and here is the previous attempt to fix the issue: https://lore.kernel.org/all/20200528135552.GA87103@google.com/ While I support Linus arguments, the issue is still here and needs to be fixed. Cc: libc-alpha@sourceware.org Cc: musl@lists.openwall.com Cc: linux-api@vger.kernel.org Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Joel Fernandes Cc: Christian Brauner Fixes: e2d1e2aec572 ("sched/headers: Move various ABI definitions to ") Signed-off-by: Kir Kolyshkin --- include/linux/sched.h | 5 ++++- include/uapi/linux/sched/types.h | 4 ---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 609bde814cb0..3167e97a6b04 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -63,7 +63,6 @@ struct robust_list_head; struct root_domain; struct rq; struct sched_attr; -struct sched_param; struct seq_file; struct sighand_struct; struct signal_struct; @@ -370,6 +369,10 @@ extern struct root_domain def_root_domain; extern struct mutex sched_domains_mutex; #endif +struct sched_param { + int sched_priority; +}; + struct sched_info { #ifdef CONFIG_SCHED_INFO /* Cumulative counters: */ diff --git a/include/uapi/linux/sched/types.h b/include/uapi/linux/sched/types.h index f2c4589d4dbf..90662385689b 100644 --- a/include/uapi/linux/sched/types.h +++ b/include/uapi/linux/sched/types.h @@ -4,10 +4,6 @@ #include -struct sched_param { - int sched_priority; -}; - #define SCHED_ATTR_SIZE_VER0 48 /* sizeof first published struct */ #define SCHED_ATTR_SIZE_VER1 56 /* add: util_{min,max} */