From patchwork Wed Feb 21 19:40:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13566212 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 1A789C5478A for ; Wed, 21 Feb 2024 19:42:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D0BBA6B00C2; Wed, 21 Feb 2024 14:42:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C91FA6B00C4; Wed, 21 Feb 2024 14:42:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE4356B00C5; Wed, 21 Feb 2024 14:42:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9602F6B00C2 for ; Wed, 21 Feb 2024 14:42:10 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 782C8A0F68 for ; Wed, 21 Feb 2024 19:42:10 +0000 (UTC) X-FDA: 81816832020.18.F98C40F Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf05.hostedemail.com (Postfix) with ESMTP id A08D810000A for ; Wed, 21 Feb 2024 19:42:08 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=3Wdy1QkO; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf05.hostedemail.com: domain of 3D1LWZQYKCEIwyvirfksskpi.gsqpmry1-qqozego.svk@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3D1LWZQYKCEIwyvirfksskpi.gsqpmry1-qqozego.svk@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708544528; 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=/f5EOcne7K32iqTM6gsyOYn4NQeb5Q9RrrPaWIBtzrU=; b=EKyl4k6iyux/Fo6JHK3cNahLOzM6kobJ1T5zRMxuCQ/mBzw/Fs3kPWkwVIUU6qZffLuou8 JHSlFbsaB71xZi9fAKjruQIJOcy/6xAKUfQitG7LX9nf1M+rtAcaAgV580hbjJpNzvcb2b f3IINBj9vj+HlA0RehiY/WsENqWiBTA= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=3Wdy1QkO; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf05.hostedemail.com: domain of 3D1LWZQYKCEIwyvirfksskpi.gsqpmry1-qqozego.svk@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3D1LWZQYKCEIwyvirfksskpi.gsqpmry1-qqozego.svk@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708544528; a=rsa-sha256; cv=none; b=dCSyj4jcO/L8X4Zsva4N5Ki1BYHQ++9x+uM1EVZhD5NIXlh2UtNQ2B2YvHd31s9kDbMJDB JYyjgbUXY+dDRTWjYbtzGDi2uI396V0K5UgcANU69NsruQkUnpeWBsgr0yjrwio31w2nhF 7CBQlEC3x9V6MzGFwctmpje/xdmwAqI= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dbe9e13775aso10654736276.1 for ; Wed, 21 Feb 2024 11:42:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708544528; x=1709149328; 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=/f5EOcne7K32iqTM6gsyOYn4NQeb5Q9RrrPaWIBtzrU=; b=3Wdy1QkOVUd/oh34rEqRGMvvqlkx63jyX02nquSgXvvTm0v0xCEeL8NkJYbzNC4fV8 iIBQcjB8Mw6/q6R8dj2swfiaR7ljnr40UAdFsYw4Z2ieITczNkSTgjVnVo8kAy6ggEdw AowzM75Ig7r6naEQrvqWmd/Nsa/Dg89g84eqwxMNaaRwGT+R8nYhNklJRVhHqp+rFTM/ POBUcJr6hyYW8uLz4ZcaYDVLpzTzJfiL4THDretG3yG7oc7fTwgsmeMSLQV3WTy/NMnL Swsl7/TiwJP7A5LPS0MQVOOdwJrCvkUFDXe7nrtfGsnyw1m4RObCjxfQssNYy3dNECCh jLdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708544528; x=1709149328; 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=/f5EOcne7K32iqTM6gsyOYn4NQeb5Q9RrrPaWIBtzrU=; b=Teu82paG6z04zJbFCtCa7HaugCxnWYVkLU6DMZpWjfhXEhbeZoloRd8Vdx+H4RhJ9p dmf50UxieEzVJS0LzFCVk6WuPA7Zz1aBnU/4CVNE02WGzj5VuAyn6VQPfFt8a9l8o+wf mtTun/s1MgpBBe3eI3jVLZWBCIawNwbIviLIk8kqLosmeFORx++ML2LK422MwdZYgdIj mtoxhn545hEE9ynYjbHccRl7yYeonJ1k/nD6APU5Gw31d0usoyM5sb7niIwgu8B83LnI dS1EVNMSrluwzBZ915pW11L4e9Ua1vmG1BDQwTJbx1ntFRcQS/ypkuwXSwSNUQySZs6K 346w== X-Forwarded-Encrypted: i=1; AJvYcCUQG/0deM2tYQ1f6p1tR7a38cCfRIaKEwjkAOVbQrH41+fOj5t7aAuoTo/ruORJzGTBP1Pp1PgvkowIQ9onij2BJLw= X-Gm-Message-State: AOJu0YyBPhnOMR7WJ48eFS5qwzVfJJ0ki6c4O1ShXYHAwvQbj7zEfsDe EySKUTaz42oqVWX6n9Ej2DYGZlaW6/5MmmMWO/ark+EqA3O7Q6FtqluVpklkQqE2JJkddYcZpbu F1w== X-Google-Smtp-Source: AGHT+IGFiWXsCIvnXCn7DCHC4E3aqtfNjiBbLG3wTDrJrg+DapwG+olr3URRZ84R+eZCxmTFvxp+ectvo4c= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:953b:9a4e:1e10:3f07]) (user=surenb job=sendgmr) by 2002:a05:6902:134d:b0:dcb:e4a2:1ab1 with SMTP id g13-20020a056902134d00b00dcbe4a21ab1mr67096ybu.11.1708544527496; Wed, 21 Feb 2024 11:42:07 -0800 (PST) Date: Wed, 21 Feb 2024 11:40:45 -0800 In-Reply-To: <20240221194052.927623-1-surenb@google.com> Mime-Version: 1.0 References: <20240221194052.927623-1-surenb@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240221194052.927623-33-surenb@google.com> Subject: [PATCH v4 32/36] 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, 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, 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-Server: rspam09 X-Rspamd-Queue-Id: A08D810000A X-Stat-Signature: kuizwbkaopk44ncjahpyz9qipfr5h5qi X-Rspam-User: X-HE-Tag: 1708544528-928643 X-HE-Meta: U2FsdGVkX1/guxKEKb49h2RGCkJall2Vj32e1C6PyDVj+TTPcO2PlpkwDvUqW1YphRsCDw2icnGviDOsnX76byuQnHurxOeybzc3O4ITjyNFJCFxNVreQOAUNOxNsxqpQKKehzdqxvycu7p5vZGS9+IAUVQwCM2EOogf8EDQ1jALjhT1RVAyJ5lahSRBS/tUm4A5dpsCiyGV9FpP81VpM6Sek3/CycO4uZmQrfkXTcz7Bz+OZNltrxWluCD55DnTjgjkINep66aW/HRFluuDCIvFiHhydSukRdcl59mjIuksKZ1QUK07k1ObCrLG6DmK7c4zmIyo2D1KTheSvm+xYrXj4445/f0I+yNvUJKZue40yIBScqAYPoFFuL4WHWpN3h0hL41t9FeaRUh9L8JcwYyMkuFwmC8EBYudysragdOEAMHnayXa4mFOXB3Iu7+OjgPwRWlvs1S25V/21JO8s+Clwy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yCLG5YeMlZhZmx+MM23LPOW3h6593/7aKw+vxPk7g/xlXchu/fEROSCsgQli9qs3y33J5Y+H4beoRnH+J4OIvgrGHGnEqEBhszMHZh0jivWs8DeSknCVAddj6R4weLS9mNaEgoI= 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 85a24a027403..4a3fc865d878 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 { @@ -91,6 +112,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 920b24b4140e..3e41d45f9fa4 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 @@ 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; }