From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BDAF40D58D for ; Tue, 9 Jun 2026 20:23:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781036620; cv=none; b=aLpqFOcCBGUHkXw8fBU1R0ja95QBCkKzU3fCOXy93uyaoUhDyrZB94a8lb+6JCxzPu2jds0PR7FNzlEOxOsVM9Ot3mt0vZCJxTTI4DV3hDwmO4ZNbedr2BonY8WHheG3xQO8nKhGN1AFYuXvyjGdzUpZjQdog7HbPrQ00e40hy4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781036620; c=relaxed/simple; bh=L42xAMtdTJ59FUUyMbppX34gpimXfFfkbZMx9y3UsNQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lOK/8G9LveKtjwbpdOSegU567QmU6ztRXyqVh+dY0GuzWkFXasHt6gnpuaDDCnsJuEtPBK/ZMmyiVVdPHS4BVjq4X6znB/uOaUnfKAYJAJ8PjW/o0pZ7c9qVPrEO3s06EmKbPmzXPFdQ4n91f4518pLBB6CFLLlNOyby/QhnWQE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=pass smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=YnfjJeIb; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="YnfjJeIb" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=A8qoZc/DU1q3PC5lEoKJJiuJKrByXYf8oJza/KVwCyY=; b=YnfjJeIbuKTBA2oNYtATpzUI6+ O5JakI+yQbS8ukMi0y68cwQ5BHxMY6ij7FoH5TIo2611pvczEqcTFmc+4YQ3SNLE4R0HNAH7Q81dE 1L9WfAl0rLVtK6mqFZt5FnMIKf+l/eNJUn5qjaQ8gIrkqsLTZP/262mFhw4p9oqLAPDBpXyB/LIAl afz0kmc6YsaMlwdULt3cntDGz6c85j3C6oIhwJCdSVc06cVWqjPeOpC+gXtNj4ZCqgZy3fbbP+tnZ vWpLDoBiS7hfycJrapWPtsH/CT7C4dcp53wO1cC7PwYXdqGwryORjj1Yf4GoIAr3fqDFVi7aEJucB dxpTzHqw==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.99.1 #2 (Red Hat Linux)) id 1wX2yx-0000000GKnK-0Zh1; Tue, 09 Jun 2026 20:23:32 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 11DEF302FEF; Tue, 09 Jun 2026 22:23:31 +0200 (CEST) Date: Tue, 9 Jun 2026 22:23:31 +0200 From: Peter Zijlstra To: Thomas Gleixner Cc: Breno Leitao , Ingo Molnar , Darren Hart , Davidlohr Bueso , =?iso-8859-1?Q?Andr=E9?= Almeida , linux-kernel@vger.kernel.org, puranjay@kernel.org, rmikey@meta.com, stuclar@meta.com, namhyung@kernel.org, kernel-team@meta.com Subject: Re: [PATCH RFC] futex: avoid false sharing between hb->chain and the bucket lock Message-ID: <20260609202331.GB187714@noisy.programming.kicks-ass.net> References: <20260605-futex-v1-1-4ad4a0d6f265@debian.org> <20260609104603.GA48970@noisy.programming.kicks-ass.net> <87mrx331wg.ffs@fw13> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87mrx331wg.ffs@fw13> On Tue, Jun 09, 2026 at 10:16:31PM +0200, Thomas Gleixner wrote: > Breno! > > On Tue, Jun 09 2026 at 08:28, Breno Leitao wrote: > > On Tue, Jun 09, 2026 at 12:46:03PM +0200, Peter Zijlstra wrote: > >> On Fri, Jun 05, 2026 at 09:53:12AM -0700, Breno Leitao wrote: > >> perf bench futex hash 192479 195523 +1.5% > >> perf bench futex hash -b 256 3453734 3987880 +15.5% > >> > >> And then I do see the improvement from your patch, but I really cannot > >> make sense of your reasoning for it. > > > > So, let me rephrase it. The bucket cacheline takes hits from four access > > patterns - the three I listed (waiters_pending readers, lock spinners, > > lock-holder chain writes) plus the lockless `fph = hb->priv` load on the > > futex_hash() fast path, which is what c2c surfaced. That priv load is the > > dominant HITM source on baseline, not the chain writes I emphasized. > > Ok. That makes a lot more sense now. > > >> > Cost: one extra cacheline (56 B padding) per bucket. Would it be > >> > acceptable? > >> > >> I'm really not sure, it *doubles* the futex memory cost. > > > > I think it's worth the trade. The global hash scales linearly with > > num_possible_cpus(), so the extra bytes track the same curve as the machines > > that actually need the fix > > > > in simpler words, a box big enough to feel this contention has plenty of RAM > > headroom to absorb it. > > Well, it's not only about the global hash. The per process private hash > is affected too. > > Can you try the completely untested below? This moves the access to futex_hash_put() :-)