From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB9A9C0218A for ; Tue, 28 Jan 2025 22:49:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43BBB2801E3; Tue, 28 Jan 2025 17:49:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3EBF32801D5; Tue, 28 Jan 2025 17:49:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B3952801E3; Tue, 28 Jan 2025 17:49:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0E6082801D5 for ; Tue, 28 Jan 2025 17:49:21 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 7B3711A0653 for ; Tue, 28 Jan 2025 22:49:11 +0000 (UTC) X-FDA: 83058352902.01.E97C217 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf01.hostedemail.com (Postfix) with ESMTP id 951A440009 for ; Tue, 28 Jan 2025 22:49:08 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="CQj/0vMn"; dmarc=none; spf=none (imf01.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=peterz@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738104549; a=rsa-sha256; cv=none; b=UB0EqVTw0U0xR7Uxfs+EJ6AmUei/nE4DWn93lmZWWHnifQEtEAGdfjyy09NkoJlZKo0N4Z nK7LwpTd7574DxP2qxbkFXpjeM9VF00nwyXDC7ps9qUo+w+hG8hSWKhp97JRy+/8HwWZ7U RbVmmxOX0UiMJuvSk+GXS5+g/MQbSEo= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="CQj/0vMn"; dmarc=none; spf=none (imf01.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=peterz@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738104549; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EmJ4phGF0OcE6Yz682bXYpiciEGF8mGXA778RNaVi2M=; b=sWKEj2CMO0Y09bOUW0Q6PSwXG50EfvjPtKsSdBLX66dO/NR3gj5H9Gx3Nr3eWTFGhtllV0 Cy4jZVL5ecJKufmNIZFBlaww/O+opDwzih7QAzI/YEZi6cV3jD74dNXTy9qZCu3xRTI/fb ZDqFhRjcxGm3xClpAqz4+u1myr/uQZQ= 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Queue-Id: 951A440009 X-Rspamd-Server: rspam10 X-Stat-Signature: 19m5kzw6nminoq7iuyepujy8xg194qma X-HE-Tag: 1738104548-252943 X-HE-Meta: U2FsdGVkX19ycDB4hyYC0/zA64pqL1kvsV3UkYED9t0zfHAAbESZqQ2DM3XsjRmciJx0v94mKvWo+5APAej5YV1kTXll6D02urLXlkNcbjP3V//ewguYyefl6v3qHEIjqhKfSfqy2rr2QuCnv05Ftq2egcKIFnCUfAjBv5kzdCDplbTJc2mOoHYDK7SW00UpVBOiRMt4Djr5viETeTXiYaohYve12p4ncnwO0Qz3BqTtZyEsk/DkPtTYlpIEcUf3UkDm6rJ6+Y45G4i2lZX+KaB+3ST1HjBquRdOkDvJljxCh8+uzAixcjU59Gv0EpMtxnJvJ5EAbytoODVtzaoNuAWORyv8pibYOdR7mtKPV/NodH9zCa8TCODvTdyS4CM0qSCBJEaEmOrwZC1OpKx5z8kl1/Dexn9usnon3ZewLZDmtorlFDVUXwmlCFWi/FNj5H+ipVgGB5N8nOsPEG7odGuChEQo4qR3ZppB3ged8jmmd56qPeINiWSZ6LbbXdm4heFPAZL9/lKRTWf/bab1jy+ChFjwM8axyTqDtaZeEf1U8nTIQATWPNhgj+JXSdZqPIYpnxYvl+5JD2BprwwGCzt6J33CbFEbv81Yy9DXNd6ddG3TNjyYu3TLsH7/y4CDH19mZjLwEmeMB6B4/mar8giQEVGFBgZZOYu9pNXrKXauRqGrccijcrTTaWBRRskNn+MGAgUI1OgRLFuTuQnqweRJuTK+BW0IwBNLT0NXDnNboax+JXtD7+iAxOn7cIj+mstxNDBjSOXkwH8z0JEZn/XD8cQ3VmG6DsCTexNFM4pTLRVZbOG9nLG32/5D215Tt5QC2AlG8VC8u+gKsR7RKRclK6635QS/NIpt7gTFseq44ehc/eO5e1//uIycwRZvEZt0j8xRep5czBWytTE1Pf56NZcPYJEkZp6rHhrp4dsPdqfeDp6LMp9v7pdlYsjAaX+bgh0M4TXVtP0XxCZ M5GZ/FDf v6zwhr8PlRQ8CshDxr8eW3R+AkBv688WEi60SMHF0b8xx/v9zh5qFITjv5kWmvFUGZ+qIs47IamfFO3WklhknYtVQhv0tLjfQirWxf+lqYivRVpPSjnj7j440edmg7UuwxKpwJTEvhG3Cs7GFPWmtHUU8NTvLGkNt1uW6+vOVoTlI0mwp+cC0e01xQsoz5TPmZzdd/fgzQrjw96fG3drs9SJuRD4irTzWoN4L8J2+14NBuIw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000708, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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.