Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3223028rdh; Thu, 28 Sep 2023 06:18:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdK7d/dLvkaDXHfiQMQxf+5YHehR4ja4A8RuNLNiGkyewKVbyegp19opXgU6/wsKf4Cw4z X-Received: by 2002:a05:6e02:1549:b0:34f:d945:23b0 with SMTP id j9-20020a056e02154900b0034fd94523b0mr1305966ilu.30.1695907094206; Thu, 28 Sep 2023 06:18:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695907094; cv=none; d=google.com; s=arc-20160816; b=BBiYI2t9oAw8Te1zgDUriE91GDcnzCs5esRISk4FMrf+T0EzZNwLDI2Qsx8B+QYGvS cPfAHfFveGK8wvaztvwYX9QbsCa/aBhs6Mc/zMxo4EIfA9iTlL1qQHgOb6XZwUUwGMAI Q4RImtkMtWP6NziX+/ggKlZDnya30MsF4DQbEtZL9qJjfiBiH94YNABpvaXEmFIktlxc RyDT6dLbxxuh4o1EiFatve0TkGVggkLu3MZFMriq/fUTkI34VOA/2JYeoxDTzRZk/AHg UUFPsgkGxfG8r4DJ4SLtSXZyAbN9kD1yD472795E2dZxjnpdYJfhEd66AszykV3DnCve bQxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0ZBqAeAxhLgaHzA0U30eyOYtBMrVtY+bz7/Iu08opZY=; fh=1rkI2lTE16xZZyUTUnt2m4i71PJOzdADVQUI786jtzc=; b=UAavrFqlwBqKFx7KI57KnY7BMfBqahGljNX1cnwHjUSa+Yt3YY8KwTVRjePrSWTPMQ 4Bgwrw5NL1BKCOvwLTOQTZlW4QKsARizgvoDNtqTuhSynvNyBmpREFAlmcb27ZeYeWLE oalemujSGIGoLV2VXY3KOk5W3oTgU4s9/kOa1Tt9V7ZnrEBZ2nvqVGNd24oobTL5WMI0 Uj5+LgeQkW1cnibE2O4phgcqffMLpKyt9/a8SJdwOPIrsSKtMhl08MCJ3N6xP+BS9KwT crQhjIQEFT8YqQqm37waXH/AWr3Lqwp51bM1XWcxrfQhpnBskDn7ACJyxMZT+6V4QZlW 2Byw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=g7rlIogZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id bs65-20020a632844000000b005855bd1ebbasi4064094pgb.204.2023.09.28.06.18.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 06:18:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=g7rlIogZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 8A1E483DD693; Thu, 28 Sep 2023 03:40:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231378AbjI1KkK (ORCPT + 99 others); Thu, 28 Sep 2023 06:40:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231516AbjI1KkI (ORCPT ); Thu, 28 Sep 2023 06:40:08 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BA4219B; Thu, 28 Sep 2023 03:40:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=0ZBqAeAxhLgaHzA0U30eyOYtBMrVtY+bz7/Iu08opZY=; b=g7rlIogZMEeSYihTHBu7xdq+FY ATEFll57FfDYCVpVKC5ixPvUGmcn6PZZcL3q0qAGBY6XZZovo1npBpoA80oKeL0otH990eaH1/Aor mwUWU8x6wheXOpOCCHRUMw4vqnnTIbtp5sVFeXFAj8NmLQyQRPFeZ90cMzOhOM5nSAQ4BcOJNwf6l MBojAoJE5V06blZJTWbbOJDmalUtiCrE0kWJXR6ocJHPxx1WOYTZ439H6IsHJAyvGC+3CXSg7n6xV AjTipxUkFB4liGxt3UqmTrPA1qpSFfJPjMrvWfmn3eqXSzZZFWiNxHkcHSJZLTFDyhZexhQxHzUhU QQ8NuTJw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qloQX-004wXX-16; Thu, 28 Sep 2023 10:39:27 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 742293002E3; Thu, 28 Sep 2023 12:39:26 +0200 (CEST) Date: Thu, 28 Sep 2023 12:39:26 +0200 From: Peter Zijlstra To: Mathieu Desnoyers Cc: 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 , Davidlohr Bueso , =?iso-8859-1?Q?Andr=E9?= Almeida , libc-alpha@sourceware.org, Steven Rostedt , Jonathan Corbet , Noah Goldstein , Daniel Colascione , longman@redhat.com, Florian Weimer Subject: Re: [RFC PATCH v2 1/4] rseq: Add sched_state field to struct rseq Message-ID: <20230928103926.GI9829@noisy.programming.kicks-ass.net> References: <20230529191416.53955-1-mathieu.desnoyers@efficios.com> <20230529191416.53955-2-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230529191416.53955-2-mathieu.desnoyers@efficios.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 28 Sep 2023 03:40:18 -0700 (PDT) On Mon, May 29, 2023 at 03:14:13PM -0400, Mathieu Desnoyers wrote: > Expose the "on-cpu" state for each thread through struct rseq to allow > adaptative mutexes to decide more accurately between busy-waiting and > calling sys_futex() to release the CPU, based on the on-cpu state of the > mutex owner. > > It is only provided as an optimization hint, because there is no > guarantee that the page containing this field is in the page cache, and > therefore the scheduler may very well fail to clear the on-cpu state on > preemption. This is expected to be rare though, and is resolved as soon > as the task returns to user-space. > > 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. As always, are syscalls really *that* expensive? Why can't we busy wait in the kernel instead? I mean, sure, meltdown sucked, but most people should now be running chips that are not affected by that particular horror show, no?