Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2428577rwd; Wed, 17 May 2023 09:43:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6qJ13kWV+9K8v4pm+uGi3uDuvIrbnGTULp/d4mrMk9FloCDOHwrkl//uZ7hpcjJ3hcUEOp X-Received: by 2002:a17:90b:4a8f:b0:250:2192:1bff with SMTP id lp15-20020a17090b4a8f00b0025021921bffmr278547pjb.23.1684341792586; Wed, 17 May 2023 09:43:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684341792; cv=pass; d=google.com; s=arc-20160816; b=Fi+HKhOEleYmXiiVbJNxC5BbWq50gYgX3w1GtdcllIUOc4DBFIH2OnHEAg7y3S9DMq a8sYtJanSJmTy9fSoMUodbRDLUZwSsTnDnS5ZXFvM4xy/y3YhJftKLCMIpUWvHsmOqCF XNrPxc2m8KPouxza6LrQYV0eqCSdGCBRWbvnwosACpILyEE+fpPXUPGUvcvwX4WHZq66 D0A2CV+GbTtm873mpR45K+xAHfUYhFvu16eKh48U/qeD+k8/dHsDAUcO7MpWZ+2kRvu7 CjG1uBF6wzfpGJMZ9IT20eoE9VfwtAtmDJWQsjBi69aBzwT2szJtD1AicyhRHsg84sdx qqGg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=VXKqe3jgNKbRnhNO0B2pUNp9eHQyU6zNHI/Xvc/t0e4=; b=wnnOh2WmnWveGDNbxK9Y2Anl6la1PTcL8zH68ICFrBeru/C/wSuFR+cc6Hfqhb5kHt +LY36HfJhhkjAe1jqNRRaDpxjqSnZQ6IrVKYjhOxDAf3rxeqB4UAilZiujMyiXlc3hnQ OrbhhVqJWYZBgHyCeRkeq/2NrDnto2z4CSrWxvidhZOS9UaiAXdmnK87iuerkxN8tJHc fZyo2/qGpPqMWSjv+xVxrulvlTZhdjfppD+DO9uwO27Y/fBVv22aKJdSLB3SozFmtd1Q RiFMCbD5G0bd19TebKkecd1N+vRZUfZpzfJIe4ts/Cw50zgcxr0RMlr9UgcqqEiwjOdS v+Lw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@stgolabs.net header.s=dreamhost header.b=dlFmXIyQ; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t2-20020a17090ad50200b00252d84b7af0si2046592pju.181.2023.05.17.09.43.00; Wed, 17 May 2023 09:43:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@stgolabs.net header.s=dreamhost header.b=dlFmXIyQ; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229656AbjEQQld (ORCPT + 99 others); Wed, 17 May 2023 12:41:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjEQQlb (ORCPT ); Wed, 17 May 2023 12:41:31 -0400 Received: from bee.birch.relay.mailchannels.net (bee.birch.relay.mailchannels.net [23.83.209.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08678A5D7; Wed, 17 May 2023 09:41:09 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id B8785762444; Wed, 17 May 2023 16:41:08 +0000 (UTC) Received: from pdx1-sub0-mail-a245.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 9D77B76251B; Wed, 17 May 2023 16:41:05 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1684341668; a=rsa-sha256; cv=none; b=Lxw+3UaSmZUVI2O9OZtRvy3Bd40NNV+PqdwYNl5n69OGv8j7D5bRybTsQU/a7J6kcnjGYX Oc9F+GnhW7B/2URGRWKGulzqBJ/ODGxHBYtlm5yvRJIo/gY8mqMokfZhIMWHg4UjmeVk1K 4tyPStGUf1B382FTGKRyTTyryRyR7fEoHyVWeF6Rlufzc/4H4MlB4w8YhSZKn/UzRVQd5V PzQ7vCYXaUZLAM3du/CNjYaPMfgwiBUW5QM2iBMlGV5LbPl685Sha21hZDkKLC6FWr0nkF h+o+lpNIe8Zl4wYTNPVJjUYDZIiNN6lQwdio8VmJrEDyXZ8T4AGgXd7np4sIiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1684341668; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=VXKqe3jgNKbRnhNO0B2pUNp9eHQyU6zNHI/Xvc/t0e4=; b=jhNXvhs+TY+moRx10tepTNbDr+qJFTAnrnfKV2x+o5pQIk5fz2vLjzFwdxtuU5XP9JEZqq SqZNXPLZq+vJbXqCk483kr1iRmqaszV2UxU5g7NG/nX/KoMO/fBpHxG4Fn2/eqPJq4wBll pGDSG4MApUYfrQmfzouMkpGMtPkV4l4S8cHjNzd30e4iJHyUIFbI+pINYNvpf+J+HgOVbR 2znEGMJogR/S+mrsrcnnWdZc8FdB8k6Bz9/fOeFTQJcEmx9b6I86sho9Z6taPHNox72OXz LaMUkOYxKJ5r2GtSXbvFO2ff1x3CCe8xqsYuff8dbzo7t8roSsIeQouSXAO2sw== ARC-Authentication-Results: i=1; rspamd-5cdf8fd7d9-ws6n5; auth=pass smtp.auth=dreamhost smtp.mailfrom=dave@stgolabs.net X-Sender-Id: dreamhost|x-authsender|dave@stgolabs.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|dave@stgolabs.net X-MailChannels-Auth-Id: dreamhost X-Attack-Shelf: 62d8a2582083a651_1684341668443_4082558754 X-MC-Loop-Signature: 1684341668443:922589920 X-MC-Ingress-Time: 1684341668443 Received: from pdx1-sub0-mail-a245.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.109.138.48 (trex/6.8.1); Wed, 17 May 2023 16:41:08 +0000 Received: from offworld (ip72-199-50-187.sd.sd.cox.net [72.199.50.187]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dave@stgolabs.net) by pdx1-sub0-mail-a245.dreamhost.com (Postfix) with ESMTPSA id 4QLzPp3pgMz3P; Wed, 17 May 2023 09:41:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stgolabs.net; s=dreamhost; t=1684341663; bh=VXKqe3jgNKbRnhNO0B2pUNp9eHQyU6zNHI/Xvc/t0e4=; h=Date:From:To:Cc:Subject:Content-Type:Content-Transfer-Encoding; b=dlFmXIyQIztX0tJouWHTvTY1Rb0sk+fq5HQzDnG4pl2dG1LMjo37/QrY4WR1oVVQY zcOBu+lN+vSkuZn5/ajgy1n75kD9f51+QkzLgfPmdWX6higJ9F9Vagb6cEOO5Je2uY ehCbK2LXPCK5UNTiYQYqyHNPqqNtrR/I1NEN1sutBItnI03zvazV43ZDGo7DZkGrvx anhgfky3eGrtK4g4rgDArvPVkYrt0fcc6pRCSI3PWFwiWLigq7bHm8QCOrv8CL1+Po WGMUqZ3CJS2VWnzG8ji4V7wvWkPm//uPWeVckwWKO4bo7WZX9QW8Dd3Z9PVeHPKPA1 Ct5U9TCw1skHA== Date: Wed, 17 May 2023 09:07:56 -0700 From: Davidlohr Bueso To: Mathieu Desnoyers Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, Thomas Gleixner , "Paul E . McKenney" , Boqun Feng , "H . Peter Anvin" , Paul Turner , linux-api@vger.kernel.org, Christian Brauner , Florian Weimer , David.Laight@ACULAB.COM, carlos@redhat.com, Peter Oskolkov , Alexander Mikhalitsyn , Chris Kennelly , Ingo Molnar , Darren Hart , =?utf-8?B?QW5kcsOvwr/CvQ==?= Almeida , libc-alpha@sourceware.org, Steven Rostedt , Jonathan Corbet , longman@redhat.com Subject: Re: [RFC PATCH 0/4] Extend rseq with sched_state field Message-ID: References: <20230517152654.7193-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20230517152654.7193-1-mathieu.desnoyers@efficios.com> User-Agent: NeoMutt/20230407 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +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=E9 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 >