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 E77D128DA1 for ; Tue, 28 Jan 2025 22:49:19 +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=1738104562; cv=none; b=Tr8kXvzLC/HtYXXwBcgghwwCE+zXZ6FxYl5Z/kjiw/k4gs9Bq9D81UBBTNibtKfT2JTYJ1Cwu2tMAVkAdGsMhdqx7Bdh1D1N8gvsYjfHZq9ISjHsb6X34upukq/wmNxGWI9xY90r5wZit6kx386sNtWdqVWgmsGBxPr6DI5RjvA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738104562; c=relaxed/simple; bh=iq00dfBdFTXrM2a5YQC7HKFTkmxiFcs6xI/EulD4fi4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Iyv9CqSDuJZxz0LxaMbPrWwa3L46ASQP5UtohwyKpcCMlw6d2SRCuTC3LCp1zlqXbW2snKCVJ3jzlmw6szUlpUzHweWM8tLinELpkJSTTzCYjWuNcAPKGmIyUDuJ9NX/Dd/PtRXHbjo8RndxmPQ/t9h7lIslPlHwoxHSilrtic4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=CQj/0vMn; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none 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="CQj/0vMn" 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=EmJ4phGF0OcE6Yz682bXYpiciEGF8mGXA778RNaVi2M=; b=CQj/0vMncuTo/UAg/4tVyUu7ll Cx/exuB6YnxsdCNgPK5GH+XgzRXucLljUiLepkgBc7UdumLdtY2sMpVYJXhLUvt5xDXu11w8qaT/W E3d3VvDBGZ3vmZR2JuShvYaSNFc7ZQGCRoxrlSRDn8jXYurDhswlDMpzLox4H5s02grFZEg6ajnv7 DTvJ+mqCdXy3NFdVGzVAWNamUcu/be+vpfZ4QoijfKVoRLtjnad04N6enxnHmpN1+X28BgNWx29UA j/GhTxCV12m0p9JUClT4eHp2dn4hWOSZ3s3Wl6a2KO+CWWPZ0gT9mVdMjFjOatzQdIl3lGR1Fugm9 0imeVrgA==; Received: from 77-249-17-89.cable.dynamic.v4.ziggo.nl ([77.249.17.89] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tcuOF-0000000BEI1-1rXK; Tue, 28 Jan 2025 22:49:03 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id A581B30050D; Tue, 28 Jan 2025 23:49:02 +0100 (CET) Date: Tue, 28 Jan 2025 23:49:02 +0100 From: Peter Zijlstra To: Vlastimil Babka Cc: Suren Baghdasaryan , akpm@linux-foundation.org, kent.overstreet@linux.dev, yuzhao@google.com, minchan@google.com, shakeel.butt@linux.dev, souravpanda@google.com, pasha.tatashin@soleen.com, 00107082@163.com, quic_zhenhuah@quicinc.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] alloc_tag: uninline code gated by mem_alloc_profiling_key in slab allocator Message-ID: <20250128224902.GA20077@noisy.programming.kicks-ass.net> References: <20250126070206.381302-1-surenb@google.com> <20250126070206.381302-2-surenb@google.com> 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: On Sun, Jan 26, 2025 at 05:47:08PM +0100, Vlastimil Babka wrote: > On 1/26/25 08:02, Suren Baghdasaryan wrote: > > When a sizable code section is protected by a disabled static key, that > > code gets into the instruction cache even though it's not executed and > > consumes the cache, increasing cache misses. This can be remedied by > > moving such code into a separate uninlined function. The improvement > > Weird, I thought the static_branch_likely/unlikely/maybe was already > handling this by the unlikely case being a jump to a block away from the > fast-path stream of instructions, thus making it less likely to get cached. > AFAIU even plain likely()/unlikely() should do this, along with branch > prediction hints. Very much depends on the compiler :-( sometimes unlikely just moves it to the end of the function, sometimes it's moved to .text.unlikely. Some compilers have label attributes: l_yes: __attribute__((cold)); but the same compilers utterly ignore it when it's combined with asm-goto or something -- we could never get it to work reliably. It's been a while since I looked at this, so I'm not entirely sure what the current version of compilers do.