Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1232668rdb; Fri, 16 Feb 2024 09:04:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV5i7vmPkxVDRMpT9ToTT8gJHNgwn8lvyqBR+p20zQBskku0/LZ80DyFMM8DqVcGveuecAQae8gj86at9FtKTX6etNDpaBB1pPp0LP3hA== X-Google-Smtp-Source: AGHT+IFcFUm6+F2SnYqO0O5t87caq2AskwKotbq9ne4zYZw838dlOKWEkjPLOaGqQ8ovo+Bsl8vL X-Received: by 2002:a05:6a20:94c9:b0:19e:ca05:226e with SMTP id ht9-20020a056a2094c900b0019eca05226emr7670816pzb.9.1708103074906; Fri, 16 Feb 2024 09:04:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708103074; cv=pass; d=google.com; s=arc-20160816; b=QeIyhkQ7s3/3iVFo5hlFHY1JDk6NFnNLcMLVtZCLYwaV9Au+09R/H21ZLnTOi2PuX2 AcQVRrvEeMBc09A0vpXR31Me/YIPf/kBQRtalN2zzjDOwuqz+1oohh/MVGHYrM2buM0Y 8dGqMgCmoOHR/hFkfUKcdQIaMlcauLKv7xVrx+740Ge3PVfaOiJ6LP2TBoCUFGuqhm4N /5ARz2Y4jRSSYtbunETEhjDv4AlqF9EGM3HCQAaxEme2+xIzRES8ZcnaYcNGP19LSQTE SRClX0qCoT7NJhzOK3UtXXg18sv1AjwnoTPwMONQXILxdTvCIx8XoEJ7hEjsaNj5M0a6 Zeiw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=AONf6Rwt70Y/InxvAsZm9qasH+QAXmnPb6exgsQbAn0=; fh=TZi3dkCL0rUd/caw11aaFVdnnGRgThLF0YyMl7+tzRQ=; b=I9Qyj0opUT20YVfUxNPkvfPWPb5KzCsWi2vffffRFHWqxVxWW0KEZ8+o6zeILHt/Yx OHTbB4vPWesc3LlaVlu++QiZRZrNhewBjJNSjArXzn4S7bxSd0mnORSE/40ZAYABSmSo q8VrW1pLRp9GqYNV4l2CIX0jVXz7aId0rJMbs4Dp/uue0UaV35ZApkdblo4q842LDrdY bf7XCBpAK7MdZcRlTOKJgf+q0CojU64JUGbu5OLJ52hJtp+BPqRMV/ly6YvOWCC3rLGg +0TUWIP305Hzh6JldZ9JOsyMVcNSCC1IJgTyFRIPqAp6DJXHXOjjOxRDzXvJHsMKHnjT d6YA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qdH7rwIE; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-69010-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69010-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j3-20020a654283000000b005dc42946a85si156273pgp.214.2024.02.16.09.04.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 09:04:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69010-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qdH7rwIE; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-69010-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69010-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 94AD22857DA for ; Fri, 16 Feb 2024 17:04:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 889A0131725; Fri, 16 Feb 2024 17:04:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qdH7rwIE" Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94357130AD8 for ; Fri, 16 Feb 2024 17:04:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708103063; cv=none; b=sTxaIRwWzBeQH5QAwKE+WX+kKMh9N1HQq7rcttYjRNutILqaFhzXN82PKfatW4KXUjeAJCeuJtEo3dfnsC1It4DGrNY3jAwyopEHgH4mGnrqCkZzp+rVgTFaOsKQmwJd4uFW3YToXrZCHh9uKG1V8/7HEVo+1poP72w4YLW3WbQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708103063; c=relaxed/simple; bh=3a7FMORiulYeKmE84zKi/piBb+dkvwU96kx/uVbaQFg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Vo71jfa0M04voWckAlHdO4M7xHXDTsmLArewspkawvKYSZFDfSFQ/RVLPDIQU2bK3D0l3OKyvE1+P+10wRZQ35xvsWjXr1vEo+tqRRi4EZnDejwJIA7Xb98GUKpsc5jI53oZqgfZKYoBJd7mQglaSfKxmxhBBukYynyTL8E0B1k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=qdH7rwIE; arc=none smtp.client-ip=209.85.219.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-dcc73148611so2506653276.3 for ; Fri, 16 Feb 2024 09:04:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708103060; x=1708707860; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=AONf6Rwt70Y/InxvAsZm9qasH+QAXmnPb6exgsQbAn0=; b=qdH7rwIEutJjohj3+iLQ+MrYMO2JOxTZXt6DXmZHUv4X0WOsHTSDV2pY0udsMdTxtd fofwGxmK4la2Ejmxb14rS2/69OpBaCCYH3oE6YLgqnyflnOj7KwxVInQOUlWoyZNCw6F UtxWHzIoJjDI5gsC5hm7OT61vrKzYu3SvSEcYgPVQOj1ixFQKtyoHh69I2vb7X89nQPC fy49PYaHmgz/BIyi9V2/HaaQPH+gvUWs8wvQODnJ/1Ggx9UG5p0dWyX3Qoj13/abE4KN XZCU5DSADi8rvmwmeeZiyGwGVKBtS5q7JvcvcDqanvdlGVWhPMEzpmPo8p0b43EMG9E+ v37g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708103060; x=1708707860; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AONf6Rwt70Y/InxvAsZm9qasH+QAXmnPb6exgsQbAn0=; b=jPljJuBf7vJj1UWUkiCaVJJotoLqU6DPigdAKT2RBAdtTZb4CbUIgvwlsQMhrp1Har LdEcgGOvVqz3s9rcnVuT04X7MPObM3K5zuwit9txmjcwJ2dZPm6lxOGBiSoYOyO+B6Nm p8UvJmabZCGPkeMLdMO+uRxL1I45UF5HvI4OovUXhPVZ97b2VdNgfthThniX/+DBZDg5 P5NYqssIp7keY6CANbkDjZjVw5FFdahetODTDvJKdVWrXMXiebFehEsOpm654YdhIu2E vz+0tppOrVO8v/3fJDE7bMJlkzIKvJDvAp8IoUixvLXpgpLFe62mBq0Qa3DKij26Etms v5rA== X-Forwarded-Encrypted: i=1; AJvYcCU87LhRsdUHY1slJ0gbjUCFuGoZFIWd7ogI6SXDIsDYluRBcIGzrZhRKFdPXtfZCZBJkGpVbowPUHmTdxPaHVB7EwIz8seulBlyjmv/ X-Gm-Message-State: AOJu0Yy+9kKw/yxr9CN7aCPkhnX2yuARr/cBx//yHjaH0z2tncDITjI5 95vsi0eYBmL/tdW85HlkfNFLJHe32QNAKkWUFCHask7sk77n+DwcEbc97mqLT/5p/DaNfyxVd0j VBYlGoNp2nUEcvNrPkO/93Y6pCs+SqwObTDr2 X-Received: by 2002:a81:71d6:0:b0:604:a75:4274 with SMTP id m205-20020a8171d6000000b006040a754274mr4969437ywc.51.1708103060160; Fri, 16 Feb 2024 09:04:20 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240212213922.783301-1-surenb@google.com> <20240212213922.783301-21-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Fri, 16 Feb 2024 09:04:06 -0800 Message-ID: Subject: Re: [PATCH v3 20/35] lib: add codetag reference into slabobj_ext To: Vlastimil Babka Cc: akpm@linux-foundation.org, kent.overstreet@linux.dev, mhocko@suse.com, 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, rostedt@goodmis.org, 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Feb 16, 2024 at 7:36=E2=80=AFAM Vlastimil Babka wr= ote: > > On 2/12/24 22:39, Suren Baghdasaryan wrote: > > To store code tag for every slab object, a codetag reference is embedde= d > > into slabobj_ext when CONFIG_MEM_ALLOC_PROFILING=3Dy. > > > > Signed-off-by: Suren Baghdasaryan > > Co-developed-by: Kent Overstreet > > Signed-off-by: Kent Overstreet > > --- > > include/linux/memcontrol.h | 5 +++++ > > lib/Kconfig.debug | 1 + > > mm/slab.h | 4 ++++ > > 3 files changed, 10 insertions(+) > > > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > > index f3584e98b640..2b010316016c 100644 > > --- a/include/linux/memcontrol.h > > +++ b/include/linux/memcontrol.h > > @@ -1653,7 +1653,12 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_d= ata_t *pgdat, int order, > > * if MEMCG_DATA_OBJEXTS is set. > > */ > > struct slabobj_ext { > > +#ifdef CONFIG_MEMCG_KMEM > > struct obj_cgroup *objcg; > > +#endif > > +#ifdef CONFIG_MEM_ALLOC_PROFILING > > + union codetag_ref ref; > > +#endif > > } __aligned(8); > > So this means that compiling with CONFIG_MEM_ALLOC_PROFILING will increas= e > the memory overhead of arrays allocated for CONFIG_MEMCG_KMEM, even if > allocation profiling itself is not enabled in runtime? Similar concern to > the unconditional page_ext usage, that this would hinder enabling in a > general distro kernel. > > The unused field overhead would be smaller than currently page_ext, but > getting rid of it when alloc profiling is not enabled would be more work > than introducing an early boot param for the page_ext case. Could be howe= ver > solved similarly to how page_ext is populated dynamically at runtime. > Hopefully it wouldn't add noticeable cpu overhead. Yes, slabobj_ext overhead is much smaller than page_ext one but still considerable and it would be harder to eliminate. Boot-time resizing of the extension object might be doable but that again would be quite complex and better be done as a separate patchset. This is lower on my TODO list than page_ext ones since the overhead is order of magnitude smaller. > > > static inline void __inc_lruvec_kmem_state(void *p, enum node_stat_ite= m idx) > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > > index 7bbdb0ddb011..9ecfcdb54417 100644 > > --- a/lib/Kconfig.debug > > +++ b/lib/Kconfig.debug > > @@ -979,6 +979,7 @@ config MEM_ALLOC_PROFILING > > depends on !DEBUG_FORCE_WEAK_PER_CPU > > select CODE_TAGGING > > select PAGE_EXTENSION > > + select SLAB_OBJ_EXT > > help > > Track allocation source code and record total allocation size > > initiated at that code location. The mechanism can be used to t= rack > > diff --git a/mm/slab.h b/mm/slab.h > > index 77cf7474fe46..224a4b2305fb 100644 > > --- a/mm/slab.h > > +++ b/mm/slab.h > > @@ -569,6 +569,10 @@ int alloc_slab_obj_exts(struct slab *slab, struct = kmem_cache *s, > > > > static inline bool need_slab_obj_ext(void) > > { > > +#ifdef CONFIG_MEM_ALLOC_PROFILING > > + if (mem_alloc_profiling_enabled()) > > + return true; > > +#endif > > /* > > * CONFIG_MEMCG_KMEM creates vector of obj_cgroup objects conditi= onally > > * inside memcg_slab_post_alloc_hook. No other users for now. >