From patchwork Wed Mar 6 18:24:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13584443 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 20D24C5475B for ; Wed, 6 Mar 2024 18:26:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C76B6B00C2; Wed, 6 Mar 2024 13:25:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 04E9D6B00C3; Wed, 6 Mar 2024 13:25:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D94A36B00C4; Wed, 6 Mar 2024 13:25:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id C22246B00C2 for ; Wed, 6 Mar 2024 13:25:58 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8B492C047F for ; Wed, 6 Mar 2024 18:25:58 +0000 (UTC) X-FDA: 81867443196.12.4C289A1 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf28.hostedemail.com (Postfix) with ESMTP id B272EC0025 for ; Wed, 6 Mar 2024 18:25:56 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=nYTTodnv; spf=pass (imf28.hostedemail.com: domain of 3M7XoZQYKCHYmolYhVaiiafY.Wigfchor-ggepUWe.ila@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3M7XoZQYKCHYmolYhVaiiafY.Wigfchor-ggepUWe.ila@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709749556; 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=O0frA1qINx6EEpp9W3MZZMQxDt0vbebTSbODwHd6D+c=; b=zOjt3NzaCYntCUpdJVi2vvOqwjKsZXWojhdYO3QhqNKkGAVIL1rMLbKzcAeLHEm2Rv1Quf VSoB/Hw4ml3T9ETq3vvzWAxYgSZpCktJwbxn3oL69GlD23b5IniiY2Ux39ElztUAU1VTur 7Ezfz7KnL5wNL4N5gPVsCzcy0TSQNV0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709749556; a=rsa-sha256; cv=none; b=NXA418W0Ck+wFefopsNoIxwJAuK03Ikipx2vY2lowQsElaru82gTfrh6WJI//Yjd2HpJp2 IoX7GBBlDJ3ni2zOXhG5jQd/d1Z3g8cBkUzlWy23ZPtbj7r6/N8THUbZqcOznABIUOXB5J zRkhg5aNNO46J3leDl+SyWNWXkRM5jQ= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=nYTTodnv; spf=pass (imf28.hostedemail.com: domain of 3M7XoZQYKCHYmolYhVaiiafY.Wigfchor-ggepUWe.ila@flex--surenb.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3M7XoZQYKCHYmolYhVaiiafY.Wigfchor-ggepUWe.ila@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dcdc3db67f0so1397213276.1 for ; Wed, 06 Mar 2024 10:25:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709749556; x=1710354356; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=O0frA1qINx6EEpp9W3MZZMQxDt0vbebTSbODwHd6D+c=; b=nYTTodnvv3RLfsOXP1eptbUgLp23T+sZ8zRsZI9YvCfdfCyUbjVfxkxiY57jQlOteJ /HQvHtYXF/zgtTYkA+kzIg/O8OmbDVnd5UufsWrttJkK2kjA3q1EomQ6KKOHrGoqpB+Y ypcpdbpbwcrTjm2dnbMdkKnNdJvAbTLX9cXEkG3St3cJAkJH3sCuOPlPG7VfBnJRxi2a NDLmSg35nIaMObGElwzOUVX5vvNsJSxil5BmciGcoBnWHcQBZTho8RfzIPuQzp+MyROt R3FXQJUE3YFAzCQsRjAcOgVAaAspiAjHNT/DPvvo8taQUt594LfupkkKzRwLGjSRsQy8 Mriw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709749556; x=1710354356; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=O0frA1qINx6EEpp9W3MZZMQxDt0vbebTSbODwHd6D+c=; b=jPQPVloFdd9x4glvrldFxRtqZt3jaGQ2tI4m/t0l7Bi5bZz2ZVYQa/dKjurQfT+9Hy Sb9OTbis6wqiczuFSB+rMnFbZMTUB/4am7ZcnsZIcgmlhDjweFLbfuNKRC1mwRxspR2O 98lSDRtLTOtIid1uBw6eeXj+EFqTb85FBCM+kLEQDb3ZmU9Aty2FNQo7OVDms+Y8txsb XKjsI1zfyJyTsIjOwtQ2P6c7H+MO8w6xshRQnHcSdGQv68pbdUD8Pp6f7Z7y9aZa8Q5I lEww3cTT6sUqYssmhAuAaEGua/prvT3i7M0K2jnDLE+3WRgBcbUq5Waps5l589QquLVF UXYw== X-Forwarded-Encrypted: i=1; AJvYcCXC/rC58CZBOBgzdTMpHHSDFZ2uQhuV3+kZ8oBMFazpnoVNQ0DH55Q1YaI+iUbTl+5kJBRCDtyKljvUN0jIfO/69vY= X-Gm-Message-State: AOJu0YxQ7gzKBn3urJV2dZt3B8CImfM0CgROFnOsdex8npGUaailCIff Dw+1SmC0+n+liPxoDjm3r9z+GwPGwIYaJBhvwvoDdTmmynRdr16iR2A8W4KTPuBjNrIxb7aMPAD T0w== X-Google-Smtp-Source: AGHT+IEXefXvPH1tjm5HxKdrHK6H7bskL9rQoKUPz6GiJtbM4dOshetWTVsxTxg9M/C0/zg3HXT9l9SvJvs= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:85f0:e3db:db05:85e2]) (user=surenb job=sendgmr) by 2002:a05:6902:705:b0:dbe:d0a9:2be3 with SMTP id k5-20020a056902070500b00dbed0a92be3mr1901493ybt.3.1709749555637; Wed, 06 Mar 2024 10:25:55 -0800 (PST) Date: Wed, 6 Mar 2024 10:24:31 -0800 In-Reply-To: <20240306182440.2003814-1-surenb@google.com> Mime-Version: 1.0 References: <20240306182440.2003814-1-surenb@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Message-ID: <20240306182440.2003814-34-surenb@google.com> Subject: [PATCH v5 33/37] codetag: debug: skip objext checking when it's for objext itself From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: kent.overstreet@linux.dev, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, roman.gushchin@linux.dev, mgorman@suse.de, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, penguin-kernel@i-love.sakura.ne.jp, 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, jhubbard@nvidia.com, 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, aliceryhl@google.com, rientjes@google.com, minchan@google.com, kaleshsingh@google.com, surenb@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 X-Rspamd-Queue-Id: B272EC0025 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 8hbde9s813qcmeqht4fpddj4ai9nfkjs X-HE-Tag: 1709749556-595199 X-HE-Meta: U2FsdGVkX189dXqg62biNkEPd7JDsUxNMOTCan/r8nv0TIT0qmQG+vImfhsur0ASDG+td4H9Jv4OSGvZDSZytv4mX6lUSr3aabrsPjOAaxToEZIDJ51y3//z9H9uKHIHH+4BgpViCuJ/njD32OP/fkZR6/+s75b5fA6Throfs02FoDq7sU00FQBsBnsOTVLEZ8/hlalwcB24zJXblGGHsEKhSVN07+hsPYQFIinS01JW84LDH7KxezFW+7KFTbCWjZbLkLm1GixWvGcqSQEacvd0VtaNc00FTno/fF52s0gj7t9DQby4mnlieVfVt/sFhF+6XZPVfu+u95YkTMMrg4AKodCJX6CNEcnTFEbyUBSk7OgANuR9HC/oMUoGZWrVCtpGEtRmD7PG9Vn4BmDvGZ0VKe0VGSllt4Y/OFcWL6jP8ZNjT8Q2gIqce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5G9OgLTn9C0JZvb355DBm3gWF/B9672ujlW0w5+AOiKdK6gWG2hyw2MASPa09J5ez1ePoKP22FGla5WECRnBZyrxhMZ5bdq971YxXVMqwFdFaUARqx5O31G3/JpONV16yn6rlaDsz3XIb/MovxlpuCtyFutMLyfoy9aTuH2+Lg18acSmQl7zZ3Cozs/xcsibJJ5C3kSs= 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: objext objects are created with __GFP_NO_OBJ_EXT flag and therefore have no corresponding objext themselves (otherwise we would get an infinite recursion). When freeing these objects their codetag will be empty and when CONFIG_MEM_ALLOC_PROFILING_DEBUG is enabled this will lead to false warnings. Introduce CODETAG_EMPTY special codetag value to mark allocations which intentionally lack codetag to avoid these warnings. Set objext codetags to CODETAG_EMPTY before freeing to indicate that the codetag is expected to be empty. Signed-off-by: Suren Baghdasaryan --- include/linux/alloc_tag.h | 26 ++++++++++++++++++++++++++ mm/slub.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/include/linux/alloc_tag.h b/include/linux/alloc_tag.h index aefe3c81a1e3..c30e6c944353 100644 --- a/include/linux/alloc_tag.h +++ b/include/linux/alloc_tag.h @@ -28,6 +28,27 @@ struct alloc_tag { struct alloc_tag_counters __percpu *counters; } __aligned(8); +#ifdef CONFIG_MEM_ALLOC_PROFILING_DEBUG + +#define CODETAG_EMPTY ((void *)1) + +static inline bool is_codetag_empty(union codetag_ref *ref) +{ + return ref->ct == CODETAG_EMPTY; +} + +static inline void set_codetag_empty(union codetag_ref *ref) +{ + if (ref) + ref->ct = CODETAG_EMPTY; +} + +#else /* CONFIG_MEM_ALLOC_PROFILING_DEBUG */ + +static inline bool is_codetag_empty(union codetag_ref *ref) { return false; } + +#endif /* CONFIG_MEM_ALLOC_PROFILING_DEBUG */ + #ifdef CONFIG_MEM_ALLOC_PROFILING struct codetag_bytes { @@ -140,6 +161,11 @@ static inline void alloc_tag_sub(union codetag_ref *ref, size_t bytes) if (!ref || !ref->ct) return; + if (is_codetag_empty(ref)) { + ref->ct = NULL; + return; + } + tag = ct_to_alloc_tag(ref->ct); this_cpu_sub(tag->counters->bytes, bytes); diff --git a/mm/slub.c b/mm/slub.c index 5e6d68d05740..4a396e1315ae 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1883,6 +1883,30 @@ static inline enum node_stat_item cache_vmstat_idx(struct kmem_cache *s) #ifdef CONFIG_SLAB_OBJ_EXT +#ifdef CONFIG_MEM_ALLOC_PROFILING_DEBUG + +static inline void mark_objexts_empty(struct slabobj_ext *obj_exts) +{ + struct slabobj_ext *slab_exts; + struct slab *obj_exts_slab; + + obj_exts_slab = virt_to_slab(obj_exts); + slab_exts = slab_obj_exts(obj_exts_slab); + if (slab_exts) { + unsigned int offs = obj_to_index(obj_exts_slab->slab_cache, + obj_exts_slab, obj_exts); + /* codetag should be NULL */ + WARN_ON(slab_exts[offs].ref.ct); + set_codetag_empty(&slab_exts[offs].ref); + } +} + +#else /* CONFIG_MEM_ALLOC_PROFILING_DEBUG */ + +static inline void mark_objexts_empty(struct slabobj_ext *obj_exts) {} + +#endif /* CONFIG_MEM_ALLOC_PROFILING_DEBUG */ + /* * The allocated objcg pointers array is not accounted directly. * Moreover, it should not come from DMA buffer and is not readily @@ -1923,6 +1947,7 @@ static int alloc_slab_obj_exts(struct slab *slab, struct kmem_cache *s, * assign slabobj_exts in parallel. In this case the existing * objcg vector should be reused. */ + mark_objexts_empty(vec); kfree(vec); return 0; } @@ -1939,6 +1964,14 @@ static inline void free_slab_obj_exts(struct slab *slab) if (!obj_exts) return; + /* + * obj_exts was created with __GFP_NO_OBJ_EXT flag, therefore its + * corresponding extension will be NULL. alloc_tag_sub() will throw a + * warning if slab has extensions but the extension of an object is + * NULL, therefore replace NULL with CODETAG_EMPTY to indicate that + * the extension for obj_exts is expected to be NULL. + */ + mark_objexts_empty(obj_exts); kfree(obj_exts); slab->obj_exts = 0; }