From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by sourceware.org (Postfix) with ESMTPS id 2F5A93858C52 for ; Thu, 28 Sep 2023 10:40:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2F5A93858C52 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: sourceware.org; spf=none smtp.mailfrom=infradead.org 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=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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?