Message ID | 20230517152654.7193-1-mathieu.desnoyers@efficios.com (mailing list archive) |
---|---|
Headers |
Return-Path: <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> 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 5A3663858C5E for <patchwork@sourceware.org>; Wed, 17 May 2023 15:27:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5A3663858C5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684337249; bh=nompxkvZUzuou45SdMeS8Sk3Hn8mVXDPCY85VmhN7P4=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=lCg7bQQuVEHdG4iJj2Z8sNsNPcxvDiv/idO8njP6XBBAN9nR7vYtPHABTflsR3T2y gaz2ZPHTOA1i4A73NUd5gVQOXASE8+aOLDOYOFetWpz/FxUALejTkOPCp4RH4T0Z1h InD5llAIaQMrzNIgEUtF8aDxpMvD2DMDQu9d2D4o= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (unknown [IPv6:2607:5300:203:b2ee::31e5]) by sourceware.org (Postfix) with ESMTPS id 6558A3858D39 for <libc-alpha@sourceware.org>; Wed, 17 May 2023 15:27:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6558A3858D39 Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QLxmR1RqKz131q; Wed, 17 May 2023 11:27:03 -0400 (EDT) To: Peter Zijlstra <peterz@infradead.org> Cc: linux-kernel@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de>, "Paul E . McKenney" <paulmck@kernel.org>, Boqun Feng <boqun.feng@gmail.com>, "H . Peter Anvin" <hpa@zytor.com>, Paul Turner <pjt@google.com>, linux-api@vger.kernel.org, Christian Brauner <brauner@kernel.org>, Florian Weimer <fw@deneb.enyo.de>, David.Laight@ACULAB.COM, carlos@redhat.com, Peter Oskolkov <posk@posk.io>, Alexander Mikhalitsyn <alexander@mihalicyn.com>, Chris Kennelly <ckennelly@google.com>, Ingo Molnar <mingo@redhat.com>, Darren Hart <dvhart@infradead.org>, Davidlohr Bueso <dave@stgolabs.net>, =?utf-8?q?Andr=C3=A9_Almeida?= <andrealmeid@igalia.com>, libc-alpha@sourceware.org, Steven Rostedt <rostedt@goodmis.org>, Jonathan Corbet <corbet@lwn.net>, Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Subject: [RFC PATCH 0/4] Extend rseq with sched_state field Date: Wed, 17 May 2023 11:26:50 -0400 Message-Id: <20230517152654.7193-1-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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 <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: Mathieu Desnoyers via Libc-alpha <libc-alpha@sourceware.org> Reply-To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> |
Series | Extend rseq with sched_state field | |
Message
Mathieu Desnoyers
May 17, 2023, 3:26 p.m. UTC
This prototype extends struct rseq with a new sched_state field, which contains a "on-cpu" flag kept up-to-date by the scheduler. It is meant to be used by userspace adaptative mutexes to decide between busy-wait and futex wait system call (releasing the CPU) behaviors based on the current state of the mutex owner. The goal is to improve use-cases where the duration of the critical sections for a given lock follows a multi-modal distribution, preventing statistical guesses from doing a good job at choosing between busy-wait and futex wait behavior. This is in response to the LWN coverage of 2023 Open Source Summit North America (https://lwn.net/Articles/931789/) unscheduled slot "Adaptive spinning in user space" presented by André Almeida. Feedback is welcome! Mathieu Mathieu Desnoyers (4): rseq: Add sched_state field to struct rseq selftests/rseq: Add sched_state rseq field and getter selftests/rseq: Implement sched state test program selftests/rseq: Implement rseq_mutex test program include/linux/sched.h | 12 ++ include/uapi/linux/rseq.h | 17 +++ kernel/rseq.c | 14 ++ tools/testing/selftests/rseq/.gitignore | 2 + tools/testing/selftests/rseq/Makefile | 3 +- tools/testing/selftests/rseq/rseq-abi.h | 17 +++ tools/testing/selftests/rseq/rseq.h | 5 + tools/testing/selftests/rseq/rseq_mutex.c | 120 ++++++++++++++++++ .../testing/selftests/rseq/sched_state_test.c | 71 +++++++++++ 9 files changed, 260 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/rseq/rseq_mutex.c create mode 100644 tools/testing/selftests/rseq/sched_state_test.c
Comments
+Cc Waiman. On Wed, 17 May 2023, Mathieu Desnoyers wrote: >This prototype extends struct rseq with a new sched_state field, which >contains a "on-cpu" flag kept up-to-date by the scheduler. > >It is meant to be used by userspace adaptative mutexes to decide between >busy-wait and futex wait system call (releasing the CPU) behaviors based >on the current state of the mutex owner. > >The goal is to improve use-cases where the duration of the critical >sections for a given lock follows a multi-modal distribution, preventing >statistical guesses from doing a good job at choosing between busy-wait >and futex wait behavior. > >This is in response to the LWN coverage of 2023 Open Source Summit North >America (https://lwn.net/Articles/931789/) unscheduled slot "Adaptive >spinning in user space" presented by André Almeida. > >Feedback is welcome! > >Mathieu > >Mathieu Desnoyers (4): > rseq: Add sched_state field to struct rseq > selftests/rseq: Add sched_state rseq field and getter > selftests/rseq: Implement sched state test program > selftests/rseq: Implement rseq_mutex test program > > include/linux/sched.h | 12 ++ > include/uapi/linux/rseq.h | 17 +++ > kernel/rseq.c | 14 ++ > tools/testing/selftests/rseq/.gitignore | 2 + > tools/testing/selftests/rseq/Makefile | 3 +- > tools/testing/selftests/rseq/rseq-abi.h | 17 +++ > tools/testing/selftests/rseq/rseq.h | 5 + > tools/testing/selftests/rseq/rseq_mutex.c | 120 ++++++++++++++++++ > .../testing/selftests/rseq/sched_state_test.c | 71 +++++++++++ > 9 files changed, 260 insertions(+), 1 deletion(-) > create mode 100644 tools/testing/selftests/rseq/rseq_mutex.c > create mode 100644 tools/testing/selftests/rseq/sched_state_test.c > >-- >2.25.1 >
On Wed, 17 May 2023 11:26:50 -0400 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> wrote: > This prototype extends struct rseq with a new sched_state field, which > contains a "on-cpu" flag kept up-to-date by the scheduler. > > It is meant to be used by userspace adaptative mutexes to decide between > busy-wait and futex wait system call (releasing the CPU) behaviors based > on the current state of the mutex owner. Woot! I'm so glad I talked Jon into hanging around for André's spurious talk. He's the one that brought up rseq (as he mentioned in his article), and I guess you read that :-) Unfortunately, I'm in the process of a lot of trips and meetings/presentations over the next few weeks, and I will not be able to look into this. But I hope that André could test it out. Cheers! -- Steve