From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 27644 invoked from network); 8 Aug 2023 03:04:40 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 8 Aug 2023 03:04:40 -0000 Received: (qmail 1872 invoked by uid 550); 8 Aug 2023 03:04:37 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 1848 invoked from network); 8 Aug 2023 03:04:36 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691463864; x=1692068664; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=lU9dy9acxPivAK9sAqV8O5YVQrlBKU/PVmJCwK+iI40=; b=j/IuvRWHR0mJZ3utT4ETYOM1KM7sGD4D6iWKBc2trPoxvnlwBsoMfnx9RWBa1z6e4Q zh+eICNT4DNpZQz/9VGiflvBuBBXTR9hcNTIP1Ow3nAaYXIQISn+2rtaXXj4mGHfCoRe U3UiwSZ0sb6z3uEQUkWgqiYituiD53v18EKtRQiSRqmF9qVCCjCmohtLSh0+tF/YU90z lcb4DDR5c5C2omHAhYF2c7OcYjx+EV+w/+DVkEMsaqwPlk2qdWuCcVGn66mbCa3gYc5B 7/9ycVjVsgMGhM/0GJ7Ht3uobSj4qHwVbW5eN/73sM1CV6a0RqokIYWwr6WQcmfcbvBo D8Ug== 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=eBv8FKASxV47LM1hXzT6YDL30HDaZ6Lq1AJQeSxdKLMCBgBzq440KLyjNR4G1+3oww JOXtfqG9AT3KBSDVjTKAnD/O0wOOscviBaaC0EXURIfSCb3hAvAnKieiTMlmsMQ1BB0R Jr4gq+oAIODXu8ifFPTRZ0dbdB4tYJjx5n4NwGrSnHJmnH5Qun4kvgrkutxzVOtJLanw JBPWp8fFEG800hF9fc0gmAFxYfwMKw/wRml1sWA7sOAzt+3Xvc266bTBbBJxvEnTY181 M8SP5/nZQFIxSfjawuRICFUaNP+C9TYdYTosR0azSUwaJ/n9P2iWaYGdNquQDWzn8kod q4DA== X-Gm-Message-State: AOJu0YyqI38lDbF+4jRbSnl3D2ud5k/Ok2c41l487+t8MdamqjBghi9I wWLCqqyes4LwMniQts8c2ow= 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) From: Kir Kolyshkin 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 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [musl] [PATCH] sched/headers: move struct sched_param out of uapi 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} */ -- 2.41.0