From patchwork Mon Feb 12 21:39:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13554070 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 7D40BC4829E for ; Mon, 12 Feb 2024 21:41:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6668C6B00B7; Mon, 12 Feb 2024 16:40:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F9716B00B9; Mon, 12 Feb 2024 16:40:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4427C6B00BA; Mon, 12 Feb 2024 16:40:45 -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 2B8476B00B7 for ; Mon, 12 Feb 2024 16:40:45 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0645F1406CF for ; Mon, 12 Feb 2024 21:40:45 +0000 (UTC) X-FDA: 81784471650.09.17B84A8 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf22.hostedemail.com (Postfix) with ESMTP id 2CBA3C001A for ; Mon, 12 Feb 2024 21:40:42 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=cbruGCtD; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of 3WZDKZQYKCNgMOL8H5AIIAF8.6IGFCHOR-GGEP46E.ILA@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3WZDKZQYKCNgMOL8H5AIIAF8.6IGFCHOR-GGEP46E.ILA@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707774043; 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=/sI0PWD0cr+RKARN01FIe/JdJLbOCpqo744sqtIKAHU=; b=JBgdu8LfNQCxL820niLWxWrwU3co0wfv/mV16FwfonTGLLAg7+WDMuqPfiRfPWjHTQEjAX xbA1RceRiTQ9Th5aU+i6aL5raoXwmmWJbXyCTOSDZkz6vBWp+KQ9YCSgo7fevrcFZoitI0 E7xloUmz8RVqHBi2wcVl8L5pSTTX2Oc= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=cbruGCtD; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of 3WZDKZQYKCNgMOL8H5AIIAF8.6IGFCHOR-GGEP46E.ILA@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3WZDKZQYKCNgMOL8H5AIIAF8.6IGFCHOR-GGEP46E.ILA@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707774043; a=rsa-sha256; cv=none; b=u6NBJjKo2mT8SO3TI8hAoiuRGuW2Nkxoyt68Dx91Uhv41JGytmstOkrV6/jPYRC/4cnXDG IeokpMajLgV9Gcrs6vzxgb4veI0idcgCGlWPsvmzY+JQqw+BDFb8mxrp6an5siovhV9NY8 QgeTAhxY72lhsqrG3XdFfZakeoPuR10= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6047a047f4cso97758597b3.3 for ; Mon, 12 Feb 2024 13:40:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707774042; x=1708378842; 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=/sI0PWD0cr+RKARN01FIe/JdJLbOCpqo744sqtIKAHU=; b=cbruGCtDsBHj1oL5+F4uVE6/C0+JAXlcGV81tVMUwO5ZMibQ18e+XPvNpRklpUR/1g 5pImFl3xUuhQfPWr3J5DvVeOlI8SoOiDBjs3uiFP/0EzP4G63hXGgqDU3YI5ExVATgvU UvIewxAbScHu8PkYkCvfpKkz0CSDpxfTm5mMeLoQEeME4wyUbcrHTRFGjt84nuF5QcFb oV/FDyuynm/F8MzWmzVujEWdoI0CY0YygBsCyIGhH+MRQzPyQthh0b1+H/S+eiSZ523A iUnfhlr8J4NHKxC5kRaDjH0MItin87TINMwpPA7MjO/UzUuuQfP3nl0lC8EjYiIX1g/v yuPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707774042; x=1708378842; 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=/sI0PWD0cr+RKARN01FIe/JdJLbOCpqo744sqtIKAHU=; b=MBnkR0EViao2K3yh2AaOcAZtupjlsvicekMJKbPGaNU0fHQ1okQRfPWr8eboxABoSx FmCEOU6sSC9goeMM8M9+lNmGOIZj4HyEefXx1k584wxaCLj5ZZxfPKXpQ50cPXulFfxO 93oviPdAM//q5H1t+Xpzp19Qt2E9hae2uk5RDhwNG350t7bDT2Gl+ylFh5fp0sT6w18B byT2EpdrdE7ASe01tI2bWDVkRm97QXexfMgQBtq5MTyf7p+VuGtNM424ZXTP67kUGxUk EKOSFu6dfsc1ATrd79CwzAC50+4vsoCqFEBe+QV68felNPz/Eos1mQe68bz9LvAMd8n3 P1PQ== X-Forwarded-Encrypted: i=1; AJvYcCVnC9uWYA4LeiBxnDrI/Lai5f1ViSXgHmGAj7opnNZIw5zCAh/f/xweSAUCHfFKZ301WPSgJaKk7uGdbQv0TWR4o7U= X-Gm-Message-State: AOJu0YwpSnHxwxI34kx9NPrnNEBuS+69h6Bo1VD2ZBCpB5Qe5Z9PGa1n fkFHuhaKn9SFSSPZi93wKpWvKmXNwwBCPnFrUmlIv/nQC8WtaWdD1Saq6hjmffi/YHDKjYpc1MN JmA== X-Google-Smtp-Source: AGHT+IGlJug7UeocMp/yJN58BwDAI5E8aN7090iq/Hzoe26lNZkGF0b2He1z8X2tvc+mRRdeZBlUlmhSz1U= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:b848:2b3f:be49:9cbc]) (user=surenb job=sendgmr) by 2002:a05:6902:2186:b0:dc6:cafd:dce5 with SMTP id dl6-20020a056902218600b00dc6cafddce5mr2274526ybb.12.1707774041837; Mon, 12 Feb 2024 13:40:41 -0800 (PST) Date: Mon, 12 Feb 2024 13:39:18 -0800 In-Reply-To: <20240212213922.783301-1-surenb@google.com> Mime-Version: 1.0 References: <20240212213922.783301-1-surenb@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240212213922.783301-33-surenb@google.com> Subject: [PATCH v3 32/35] 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, 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-Queue-Id: 2CBA3C001A X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: u9hf9tg5biddcbg3e6dufrrsdpdyw9qy X-HE-Tag: 1707774042-768903 X-HE-Meta: U2FsdGVkX1+kpj4VldmVm7HqSVdXOUEMgAsPWkfkX7gCL5m0o5/xS2/azoUf+45om3tjrfwUQ5DOITPflzTEFsrLVXcfR3NyQiFIjs2qORxJkEBtzDIQhoP9XHCPcHsJZXER9DQtEdVV4OUnBIVYrQQk8CKJQA/QpekVAoX8zaYZwOo/oe9kpARakEc00CzoiYVNxcFw+tgqtUjaBLzxtN4DEpwzV+De6NywzUzKIx6S+HVBNRZt9ZRMDp5EapDE6QjdaQMNr5l6GTTAcbe+vdEkHNar24adWDZ3dgKMe1ibRByaxOi5L9gtqsTaDCsKQzKuwJZr+S2KVJJ7PXO2frkJI4JkPN2kVaOXw0944wWiYj6BoVYxv4wElfr1DS0uxLCF3gG21rDW28H67fEr9pdI/o02/uTFCaU34HXl+nkk6jVutImzOewg9Q/3TuAzmBQ+ZUqkJsui++CF/LUNV2ZU0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z4HlISozVO/LfdF7LdnALRcB5Wja/iZVuFBuIwiTmmh998neZgG4+g2rOX3DN7SowaVlVxg1Bb3YwK8i77u7zTM0zCMl08v2NF3EJMY6Kos8= 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/slab.h | 25 +++++++++++++++++++++++++ mm/slab_common.c | 1 + mm/slub.c | 8 ++++++++ 4 files changed, 60 insertions(+) diff --git a/include/linux/alloc_tag.h b/include/linux/alloc_tag.h index 0a5973c4ad77..1f3207097b03 100644 --- a/include/linux/alloc_tag.h +++ b/include/linux/alloc_tag.h @@ -77,6 +77,27 @@ static inline struct alloc_tag_counters alloc_tag_read(struct alloc_tag *tag) return v; } +#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 */ + static inline void __alloc_tag_sub(union codetag_ref *ref, size_t bytes) { struct alloc_tag *tag; @@ -87,6 +108,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/slab.h b/mm/slab.h index c4bd0d5348cb..cf332a839bf4 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -567,6 +567,31 @@ static inline struct slabobj_ext *slab_obj_exts(struct slab *slab) int alloc_slab_obj_exts(struct slab *slab, struct kmem_cache *s, gfp_t gfp, bool new_slab); + +#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 */ + static inline bool need_slab_obj_ext(void) { #ifdef CONFIG_MEM_ALLOC_PROFILING diff --git a/mm/slab_common.c b/mm/slab_common.c index 21b0b9e9cd9e..d5f75d04ced2 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -242,6 +242,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; } diff --git a/mm/slub.c b/mm/slub.c index 4d480784942e..1136ff18b4fe 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1890,6 +1890,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; }