From patchwork Tue May 14 17:31:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: stefan.nickl@gmail.com X-Patchwork-Id: 1099615 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="fz71tY6E"; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 453Pr42fhyz9sD4 for ; Wed, 15 May 2019 03:31:48 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id E1A0686099; Tue, 14 May 2019 17:31:46 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FYTWEZSEZ4gP; Tue, 14 May 2019 17:31:45 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 96368860B2; Tue, 14 May 2019 17:31:45 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 6A3181BF5F5 for ; Tue, 14 May 2019 17:31:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 5060E301A3 for ; Tue, 14 May 2019 17:31:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id d3eaWbJHDNUU for ; Tue, 14 May 2019 17:31:36 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by silver.osuosl.org (Postfix) with ESMTPS id 9E69030A41 for ; Tue, 14 May 2019 17:31:30 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id i3so3719923wml.4 for ; Tue, 14 May 2019 10:31:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=8GmoqKuR/ToHeStVDkQLO0EpNliMhuof+SPOightz/k=; b=fz71tY6E68cNuDczDAtRsi7lcrPsyHoYWkRB0wwAUcB25C/zsfKXl1Y0DkusEBHo9y TAwXk8OJyU2fxtXMDtaE+8iMeSL2HfzO52kucGBmxN88lf/BL5E76NWAdqyqWthlDaPO oHlxXpLkBEx8hIRMarKEBBWzUqLmsuym/vo2lfTNjjOxor6UX/jaLN/d/I85f9fGSuY4 fPWnZ3JvNmPLmgvHX4SO+rqOg5PgWpWN4CDdrvWv5oc7R7q2KtnuO5VJ1wxAIFa5gkP6 808GemKfZWm9TLVkfyzojKXDBSPansozucqoOVhjYeqRN74bEAQrgxUac/9zxPne8948 BqDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=8GmoqKuR/ToHeStVDkQLO0EpNliMhuof+SPOightz/k=; b=uBWiSoCxCjgp6UCfx/+I5QjbL4DI0//cI3XgghO1YBdO2s0vDnqpgz9KuHnaiYlQGL ochXwBZlHBkgc79V0wZnVUDebI+6yWYIQ6KSHNAsFJZTZjArKb1TTPXdcoAp1903X+pR FpG3Xr4pkVCyIR+fnY4ODHv7U7Qsa8eMiGagF2hKhIIUWQPjfXlgyQ7r22dyaKALJl42 Qgb0adNPGl/wWTDuAFUBZkzRETCoIKdLUd/gQwjvYe2rkwYb1x/7hjtII1U2h3IK6GAE pz2f6n9LsXh/wXjpTf+JRSfba91sYR0d7dMaFPbaice+iy6e4tuWRkdnD4KCJMeU0UoI buHw== X-Gm-Message-State: APjAAAV8TsSfZhI2TEPxM2KpjwzPJd7BBJELnE0e7LBS8iIXljfZehhF slnHmaRt7Xik1TG/f/tC8A4= X-Google-Smtp-Source: APXvYqwqAM6NxgLUGHTt5oYR6i+AhoBZcvDkbnCbLrUqsXwcgrrYTvA9O5El5W44AueZfpcRVnYpiA== X-Received: by 2002:a1c:9c03:: with SMTP id f3mr20908354wme.67.1557855089064; Tue, 14 May 2019 10:31:29 -0700 (PDT) Received: from kaby.fritz.box (p200300D19717A800C7960D44B6A16C83.dip0.t-ipconnect.de. [2003:d1:9717:a800:c796:d44:b6a1:6c83]) by smtp.gmail.com with ESMTPSA id f2sm5497689wmh.3.2019.05.14.10.31.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 14 May 2019 10:31:28 -0700 (PDT) Message-ID: From: stefan.nickl@gmail.com To: Thomas Petazzoni Date: Tue, 14 May 2019 19:31:26 +0200 In-Reply-To: <20190514183356.50c06a52@windsurf> References: <509e7dab95b95c040af26c842e94777b069d6ba5.camel@gmail.com> <20190513221341.4150ab0c@windsurf.home> <071f102e7135306dfdba3203fbd35bdc07aa185f.camel@gmail.com> <20190514183356.50c06a52@windsurf> User-Agent: Evolution 3.32.1 (3.32.1-1.fc30) MIME-Version: 1.0 Subject: [Buildroot] [PATCH] package/musl: Make scheduler functions Linux-compatible X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Korsgaard , "Yann E. MORIN" , buildroot@buildroot.org Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" The POSIX functions sched_getscheduler(), sched_setscheduler(), sched_getparam(), sched_setparam() are technically not correctly implemented by the Linux syscalls of the same name, because what the kernel calls a PID and what POSIX calls a PID isn't truly the same, resulting in somewhat different semantics as to what these functions exactly apply to. Details: https://sourceware.org/bugzilla/show_bug.cgi?id=14829 Since the musl developers put a high premium on POSIX compliance, they deliberately implement these functions to return -ENOSYS instead of relaying them to the respective Linux syscalls as glibc/uClibc do. Unfortunally this breaks virtually all Linux programs using these functions under musl. For example running 'chrt -p 1' fails with 'Function not implemented' on a musl-libc based system. In particular, it affects embedded systems using these interfaces for scheduling real-time processes. As it seems unfeasible to fix all affected programs to manually use syscall wrappers instead of the libc functions, make musl behave the Linux way. Signed-off-by: Stefan Nickl Reviewed-by: Arnout Vandecappelle (Essensium/Mind) --- ...e-scheduler-functions-Linux-compatib.patch | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 package/musl/0002-package-musl-Make-scheduler-functions-Linux-compatib.patch diff --git a/package/musl/0002-package-musl-Make-scheduler-functions-Linux-compatib.patch b/package/musl/0002-package-musl-Make-scheduler-functions-Linux-compatib.patch new file mode 100644 index 0000000000..7c3acf9f02 --- /dev/null +++ b/package/musl/0002-package-musl-Make-scheduler-functions-Linux-compatib.patch @@ -0,0 +1,76 @@ +From 407c96fc790d0d11ca9603a2a533216c745b5051 Mon Sep 17 00:00:00 2001 +From: Stefan Nickl +Date: Mon, 13 May 2019 22:33:21 +0200 +Subject: [PATCH] Make scheduler functions Linux-compatible + +Let sched_getscheduler(), sched_setscheduler(), sched_getparam(), +sched_setparam() invoke the Linux syscalls of the same name instead +of returning -ENOSYS. + +Signed-off-by: Stefan Nickl +--- + src/sched/sched_getparam.c | 3 +-- + src/sched/sched_getscheduler.c | 3 +-- + src/sched/sched_setparam.c | 3 +-- + src/sched/sched_setscheduler.c | 3 +-- + 4 files changed, 4 insertions(+), 8 deletions(-) + +diff --git a/src/sched/sched_getparam.c b/src/sched/sched_getparam.c +index 76f10e4..65be107 100644 +--- a/src/sched/sched_getparam.c ++++ b/src/sched/sched_getparam.c +@@ -1,8 +1,7 @@ + #include +-#include + #include "syscall.h" + + int sched_getparam(pid_t pid, struct sched_param *param) + { +- return __syscall_ret(-ENOSYS); ++ return syscall(SYS_sched_getparam, pid, param); + } +diff --git a/src/sched/sched_getscheduler.c b/src/sched/sched_getscheduler.c +index 394e508..4c922f6 100644 +--- a/src/sched/sched_getscheduler.c ++++ b/src/sched/sched_getscheduler.c +@@ -1,8 +1,7 @@ + #include +-#include + #include "syscall.h" + + int sched_getscheduler(pid_t pid) + { +- return __syscall_ret(-ENOSYS); ++ return syscall(SYS_sched_getscheduler, pid); + } +diff --git a/src/sched/sched_setparam.c b/src/sched/sched_setparam.c +index 18623ee..f699faf 100644 +--- a/src/sched/sched_setparam.c ++++ b/src/sched/sched_setparam.c +@@ -1,8 +1,7 @@ + #include +-#include + #include "syscall.h" + + int sched_setparam(pid_t pid, const struct sched_param *param) + { +- return __syscall_ret(-ENOSYS); ++ return syscall(SYS_sched_setparam, pid, param); + } +diff --git a/src/sched/sched_setscheduler.c b/src/sched/sched_setscheduler.c +index 4435f21..e678221 100644 +--- a/src/sched/sched_setscheduler.c ++++ b/src/sched/sched_setscheduler.c +@@ -1,8 +1,7 @@ + #include +-#include + #include "syscall.h" + + int sched_setscheduler(pid_t pid, int sched, const struct sched_param *param) + { +- return __syscall_ret(-ENOSYS); ++ return syscall(SYS_sched_setscheduler, pid, sched, param); + } +-- +2.21.0 +