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 67157C4829E for ; Fri, 16 Feb 2024 00:33:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D47B36B0089; Thu, 15 Feb 2024 19:33:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CF7026B008A; Thu, 15 Feb 2024 19:33:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B4B3A6B008C; Thu, 15 Feb 2024 19:33:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9D9FA6B0089 for ; Thu, 15 Feb 2024 19:33:27 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CAD2A163FBF for ; Fri, 16 Feb 2024 00:33:26 +0000 (UTC) X-FDA: 81795793212.18.4BBB100 Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) by imf12.hostedemail.com (Postfix) with ESMTP id 8466D4001B for ; Fri, 16 Feb 2024 00:33:24 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=TCBheLyH; spf=pass (imf12.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.180 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708043604; 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=BwLdbKvwbuT7Py0w8ufFkW1cCk4JPEqYMR9dx/1h65M=; b=CM8KQyCwo02UqV5bqaI4WHlmmmxPQhCyKpdZDkbDemSaJTs2bOGghBlRCFuL5akCdJ/zxW o6GckKK9k0i97q7+q3325sfuj3lnSZVAczoCYOxqmLeLSRgDRdglSU4C6bKqyl2OaT6WKL VDIAL2GZb7WsyRmE6dkbIS82qYEwI+w= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708043604; a=rsa-sha256; cv=none; b=xOPe5+bMHPFBUVDFI2ykhl7IJOCqcAEqs1aZWjrog4CCV1T6oz59ncdvWt1eEmg5d5rSPE /cd3hIanc6F1Z9F6dZ4jBcaXrv7AWUoxTBhPKCvdUoYFrFe0TdOiJYYdIKmQ0qS9SiFyVL Ahwn/4qdd3bICt0W6peb+hAu6eDQ2a4= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=TCBheLyH; spf=pass (imf12.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.180 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev Date: Thu, 15 Feb 2024 19:32:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1708043600; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=BwLdbKvwbuT7Py0w8ufFkW1cCk4JPEqYMR9dx/1h65M=; b=TCBheLyHkvkCr2rg0SrQW08oAxBRtTvcZx+IRR+qV8bqJLfXAVvHTLefKtevmhJLC2yagF 90KJRsTt6yvwTHkdPhpkVXfpIaPw9mB+yLAmbC/9FosSVc2V4C/QiUfYBPe+UYZAzKt98o D2JEy+U5Cbi2lIuDcjB+L1a1QUd7tzU= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Steven Rostedt Cc: Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , akpm@linux-foundation.org, hannes@cmpxchg.org, roman.gushchin@linux.dev, mgorman@suse.de, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, corbet@lwn.net, void@manifault.com, peterz@infradead.org, juri.lelli@redhat.com, catalin.marinas@arm.com, will@kernel.org, arnd@arndb.de, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, peterx@redhat.com, david@redhat.com, axboe@kernel.dk, mcgrof@kernel.org, masahiroy@kernel.org, nathan@kernel.org, dennis@kernel.org, tj@kernel.org, muchun.song@linux.dev, rppt@kernel.org, paulmck@kernel.org, pasha.tatashin@soleen.com, yosryahmed@google.com, yuzhao@google.com, dhowells@redhat.com, hughd@google.com, andreyknvl@gmail.com, keescook@chromium.org, ndesaulniers@google.com, vvvvvv@google.com, gregkh@linuxfoundation.org, ebiggers@google.com, ytcoode@gmail.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, bsegall@google.com, bristot@redhat.com, vschneid@redhat.com, cl@linux.com, penberg@kernel.org, iamjoonsoo.kim@lge.com, 42.hyeyoo@gmail.com, glider@google.com, elver@google.com, dvyukov@google.com, shakeelb@google.com, songmuchun@bytedance.com, jbaron@akamai.com, rientjes@google.com, minchan@google.com, kaleshsingh@google.com, kernel-team@android.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, kasan-dev@googlegroups.com, cgroups@vger.kernel.org Subject: Re: [PATCH v3 31/35] lib: add memory allocations report in show_mem() Message-ID: References: <320cd134-b767-4f29-869b-d219793ba8a1@suse.cz> <20240215180742.34470209@gandalf.local.home> <20240215192141.03421b85@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240215192141.03421b85@gandalf.local.home> X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 8466D4001B X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 7dqkyzu5ccxcyexswdw16caqf1yik67m X-HE-Tag: 1708043604-922846 X-HE-Meta: U2FsdGVkX190vzwIq7zw3UWcTAbh3feeSnm3LBcmwNHkrOnbu0JcwofYfS0jR6jXezHhob9CTvbwjGBOoIDjpTpAZMGpyHrXedZTQbMHrdMYDbcGncT+OgkdsC7bQuGjtdN8Pmvd5Am/P8Ymr24nE347/wTT/26Hk98n/8yIR0/oxBOj5ccQbiM84Xg9B0aV++2omu/lokB1zKPlHRd8xrVFZ1d/laA0UKkv/wMo/h2RW9zcxfGQnKre8GRq9dUmKF8pLzTJzH70IQ5uBRc64Jj5nglzzPusDRsa1WXkO49mYJqKTYMZ6IE9PcqBlB5n7XSm2TVW9sBoPItWjaP07+up/L4dwt+RCCSTFtxM+GCMWRJXX6X3+4gc9vk/PoLMtadiHHWIh3YiKJTX7CJOJZXRbwq69rG8xBAczHoLPBYbPzPnaEg10J6CMbRYYX84+iJy1DGGR2Of6JGv6W5nIEzfFxU3nORI7f8Fgc1zVya5D6pQK0FZIEkbTHgmkkNhHuVsa3XiQc1kzSq1XeKV6l1N55I5x6dWY+CE7ISV9SwG7RDkGir94uwh0EaEk6I0ZwjwbqL3KDAe0sJl5OpSu4PNqN1dXQpGR4A1a/TRVATzbvA8iAt16F9XO8e1hc0L8wz0IfT4NCPH6gXaRmSE+/RN0wY0vKfHMsFMZ+ZbtxzistWrJG1U84pOFEmWnJpVh1kJzt0bCqEMeZs3w4l1YfCR4OEikFCVHKIMP3tgniJW9iSzN3kzaWgZicaDG+xe9xcWu/El3cmZG+fDOX4yu6lN19mPpAzGcxlT0c0RlywQr4qyZuGEP1ZhjWLtfobVTDpd1dVBLbZMYMuNZiIsuIbvHx3DM4nkU9NbulMwUKfGYPElXlIbPu8WJIVJVOtVBoH5NKyO843VsjmouY5JGPN4WsdC8tfwKXT4TtztS1ft82T9ZI3JyWtWkJt2IU4oqgzYjHPdMu9ARv3mOw1 +74M1k+f aE2XUeWubw5D3fnCi0O3a+LdNJUCe2HFL1oan8BUPtiXJSXgPl+TGcGdU/XSEzpDHUApw/gk9oP2jM+P+17ifhZOJHleBOGUOC+2TRkjJf3xNH5cTmQZQsT7za54MJZwVVChyCeXdB7FtazAv/ihNcK5Qx8Dx/uwgY890e1sdBCwXuegTePiDBu1KHde+jkHtmkPwwk5+JzA0zwg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 Thu, Feb 15, 2024 at 07:21:41PM -0500, Steven Rostedt wrote: > On Thu, 15 Feb 2024 18:51:41 -0500 > Kent Overstreet wrote: > > > Most of that is data (505024), not text (68582, or 66k). > > > > And the 4K extra would have been data too. "It's not that much" isn't an argument for being wasteful. > > The data is mostly the alloc tags themselves (one per allocation > > callsite, and you compiled the entire kernel), so that's expected. > > > > Of the text, a lot of that is going to be slowpath stuff - module load > > and unload hooks, formatt and printing the output, other assorted bits. > > > > Then there's Allocation and deallocating obj extensions vectors - not > > slowpath but not super fast path, not every allocation. > > > > The fastpath instruction count overhead is pretty small > > - actually doing the accounting - the core of slub.c, page_alloc.c, > > percpu.c > > - setting/restoring the alloc tag: this is overhead we add to every > > allocation callsite, so it's the most relevant - but it's just a few > > instructions. > > > > So that's the breakdown. Definitely not zero overhead, but that fixed > > memory overhead (and additionally, the percpu counters) is the price we > > pay for very low runtime CPU overhead. > > But where are the benchmarks that are not micro-benchmarks. How much > overhead does this cause to those? Is it in the noise, or is it noticeable? Microbenchmarks are how we magnify the effect of a change like this to the most we'll ever see. Barring cache effects, it'll be in the noise. Cache effects are a concern here because we're now touching task_struct in the allocation fast path; that is where the "compiled-in-but-turned-off" overhead comes from, because we can't add static keys for that code without doubling the amount of icache footprint, and I don't think that would be a great tradeoff. So: if your code has fastpath allocations where the hot part of task_struct isn't in cache, then this will be noticeable overhead to you, otherwise it won't be.