Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp802326rdb; Thu, 15 Feb 2024 16:33:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW7PyFR8fyU7RFxxciIEpJNB55HGCJhtSl78lsz8H/YLqjzdWX3TROu8yEgzlrP0jp+QO9hH9vHsiPpjJRQkWrgYnXzqKwlGydptjbFYQ== X-Google-Smtp-Source: AGHT+IGpsVdmbVkfV/mUShps8zDMswGLf+K6MQ8plGRVg76au+Cr2Tf+TdRgooqu+hdpVlo1y8h7 X-Received: by 2002:a05:6902:2412:b0:dc6:d6f6:cc13 with SMTP id dr18-20020a056902241200b00dc6d6f6cc13mr4059085ybb.20.1708043617559; Thu, 15 Feb 2024 16:33:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708043617; cv=pass; d=google.com; s=arc-20160816; b=UF4iRfIsYCrW3CKSxchjuuEb7II7U0nrAHF6VK3WwV+FTejnz4smvHS/phkyUgMCcx WgAEKIKQyPfio7FE9ozkcJPheJDMyDawmty+6CeP88glb1ZhHEG38P6jc/bEzsRofRpS B72fUpzGfqpZ0BLBgxLPJbdCzUU8q2Ir/XYXljy/MTMxbBc/c9si120hHEVxZFAJEONo Pp8B2j8j1mUsoFshKQJ6WZTKk48xzVttCJWvJyEiTfv4U8ssiAGn+bTvOtb4JiXvger7 fCBXKWzXiKV2KjNGkTDiXi/49Gecgr5u/aa1dmYLLEEuIzJXe6jvp2VNAECsE4G01yDh JXmQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:dkim-signature:date; bh=BwLdbKvwbuT7Py0w8ufFkW1cCk4JPEqYMR9dx/1h65M=; fh=OiwBIvYIPHGDMdlNleqgT10F8L7VFJzUbQ6V59nSWw8=; b=gBCR1YvCpzjqgWkPCKVpkCaMPKXiaLmokYD4x6xur2GnlBrvElWhdkzWQo+Espthhp iNyW27zBjL3RO0t6BDM9hPoipcy7gKC4FnAuWdBG6OS5qKx1OW+zck9GwVdI9q5fi9w+ 6U+d63DfTDNLDTFUoU5l2W5ULuO/6/q9Ivo2u2yy5CAy0OMdCTf8Mhg0TnfXYkfjm10p SpPvovfWf8V0m3s38dNkueSnMKARqS0AXCYX7gvxeQ43bfN1K31F95hmipfFtOBqBFkF 4I8YasxHoqnnrMShd3DQ4aexm7SA2eW11xKdpQv8jJ9VQT2ZdlCqbHSixp+Lctr4HMbs 6w4Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=TCBheLyH; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-67898-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67898-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r17-20020a05620a03d100b00785db659ad7si2755792qkm.212.2024.02.15.16.33.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 16:33:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67898-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=TCBheLyH; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-67898-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67898-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 509571C23953 for ; Fri, 16 Feb 2024 00:33:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 19778881E; Fri, 16 Feb 2024 00:33:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="TCBheLyH" Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) (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 5C3F7A21 for ; Fri, 16 Feb 2024 00:33:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708043604; cv=none; b=G1i/QYAsxgPLVJRWyPKAptspw0BoaxVYgem76nxd+eL9Cj8bArQgSkxQP+d6LSKADESfPauB7ftVLEtFVAzR/0anELQ8veTl65PlZEDHv6wi08KWba8txTQOSv4GpdKWhHJQwdJf1kevYj63S6FcembMSHVYoRocHzyf3m6nNho= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708043604; c=relaxed/simple; bh=XuXzzdT4qpI/thepOvg44pFxyCWv6wsSemsRQD9/TFQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=D2+G4Tc904tCWpO8qzoc8TXq3B2incZDAqIp9RNdI2gvx9VUhWrYUCqvDvW4iBvhz0YHnf2DjIez2zSOqA7LizWsY/VRo7BYS1GdxpptjjFMDJM/6Akz2iprpxtxkoWLeJT69TK8Wyqaiq935t4EhY/+P3HUjKPK5qb37Ou1NMI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=TCBheLyH; arc=none smtp.client-ip=95.215.58.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=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> 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: <20240215192141.03421b85@gandalf.local.home> X-Migadu-Flow: FLOW_OUT 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.