From patchwork Mon May 1 16:54:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13227673 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 7DA71C77B61 for ; Mon, 1 May 2023 16:56:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9730A900022; Mon, 1 May 2023 12:56:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FE3A900002; Mon, 1 May 2023 12:56:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77857900022; Mon, 1 May 2023 12:56:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 601E2900002 for ; Mon, 1 May 2023 12:56:40 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2B4461407E5 for ; Mon, 1 May 2023 16:56:40 +0000 (UTC) X-FDA: 80742290160.29.9E28AB8 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf06.hostedemail.com (Postfix) with ESMTP id 5420E180018 for ; Mon, 1 May 2023 16:56:38 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=48U8jHG6; spf=pass (imf06.hostedemail.com: domain of 3Re9PZAYKCIw8A7u3rw44w1u.s421y3AD-220Bqs0.47w@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3Re9PZAYKCIw8A7u3rw44w1u.s421y3AD-220Bqs0.47w@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=1682960198; 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=6mzPQystPbLbDwPdw2fPo41K7qknlkieEKK3sweddW8=; b=E/AQPbyvJuAtGS9FMXextXnBPArZHKTRBjdBTw08RXHkUAXSXSyuiFVH04lNAa31ZXj6b8 96ENJAZE+31lbHpPsRABf85xOvcRgM3/B6LnbOzAU+keL75P489v7ZcLiJOPbDp4IlT4t7 HAL5gUCb0F5haZPPCyOA8rVcgOC9Gmg= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=48U8jHG6; spf=pass (imf06.hostedemail.com: domain of 3Re9PZAYKCIw8A7u3rw44w1u.s421y3AD-220Bqs0.47w@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3Re9PZAYKCIw8A7u3rw44w1u.s421y3AD-220Bqs0.47w@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682960198; a=rsa-sha256; cv=none; b=2Jr0xFpt0hCKka5YaOKW8yN2YH92lpXKJPcQ7uM63V5G3DvjuTDubL5RM9e5yrxBvZeN4C MTyBcsL+JOxHnzDJRAiMRYv4nRzGXk4TJ3PV4Abx2eRmyV3PhhbNgdBVwSY8Kcj67YBCl4 0tZhUBVMVOPEaS96ltumChQYZAP2JDk= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-55a3146ed47so15573147b3.2 for ; Mon, 01 May 2023 09:56:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682960197; x=1685552197; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=6mzPQystPbLbDwPdw2fPo41K7qknlkieEKK3sweddW8=; b=48U8jHG63mdA66+jSc2MsTTE/SQi8BR+RKY6JNGvzt9XyZfx935vfOLln6IV1D1nZA TDOiQ/WUR049cZ5YJ1Q2SXSzODz7LrWrQUYaviS+GqGgkaK3yK5eLgyzf9e3cLjtYX0E QEA8ptoQ0G50fmCmay29a1/AGKziq1anSqyI04k35PIYMGlvV6wz4iKeKGJ75o0JVkmO ON7F5nilmKInR+kNfyJ2/HvMFyxBUo4zG20TTbLKq7fKcUY3NShJQ1fHpbVtH1cQdhj8 PGEM3ZzK108E7+nu3T246tg/tKyPHMfi0CFtYYsesaQA8cqlaVTRPDBW+c2GnGCMueBG 1wCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682960197; x=1685552197; 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=6mzPQystPbLbDwPdw2fPo41K7qknlkieEKK3sweddW8=; b=bK5JKYWn8PDkqL5f4rPi2QgCq3Ju7XKBtOU6agRgS9UKc96zu24jW/nR8QYojuFa6M QeumSLvDwksv7I3QQriLco3AURv2vTow5aFQskiZvZ5RGFph9Y3F7r5cS1o53p6lZZzL 3Vmqb+hxCEnHHFLeaoqi/doaDACYuB0mjaSGrD/+FkJPDzndnEoNU64dqiAa9Lc+DVME n3Z19aYj6H33a1FOTIK5HGxh5mM7ffMQ2LsZl/CddYHz8/Z25pQjhaAgIs05ucTCOLh8 MLMWk/gAK7dEtsruEc3E0gQUrKBrrrkneeeWvwOVZhY9Nf3Hyn5779q//yuwUpEbd2HI X6uQ== X-Gm-Message-State: AC+VfDxL5KFDlGzpynuoDVa4CJg7RWhaPTlSgipX6k7Xk55ltr82iiBK fItzA7pLsh8KVa+LzuwSJV95hz7Zusw= X-Google-Smtp-Source: ACHHUZ4jj2W0kDCYmm99zoZd05S+xWh4GtcVfBuyUeKMJ0WYF9RUn/+Qut27GKgsUVS6rbo/+wwQvYcbMjY= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:6d24:3efd:facc:7ac4]) (user=surenb job=sendgmr) by 2002:a81:e902:0:b0:541:61aa:9e60 with SMTP id d2-20020a81e902000000b0054161aa9e60mr9069879ywm.6.1682960197340; Mon, 01 May 2023 09:56:37 -0700 (PDT) Date: Mon, 1 May 2023 09:54:49 -0700 In-Reply-To: <20230501165450.15352-1-surenb@google.com> Mime-Version: 1.0 References: <20230501165450.15352-1-surenb@google.com> X-Mailer: git-send-email 2.40.1.495.gc816e09b53d-goog Message-ID: <20230501165450.15352-40-surenb@google.com> Subject: [PATCH 39/40] codetag: debug: introduce OBJEXTS_ALLOC_FAIL to mark failed slab_ext allocations 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, ldufour@linux.ibm.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, 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-Stat-Signature: uto5xoniizqo3xs8xfgkwchom16ya155 X-Rspam-User: X-Rspamd-Queue-Id: 5420E180018 X-Rspamd-Server: rspam06 X-HE-Tag: 1682960198-375560 X-HE-Meta: U2FsdGVkX19KmP6yLKy33cEqdqU8FOUji8zTTRrbZupTgA6j9LajPM+fmjKW1Eye9dilKdT2Ma3/MvSFV0756czMIxjE/TKF6d0Ui2DA8dV36qTwK8GetCwx2IYJVYd2Q1YNt8vZ/bYi4FCSLfmBFa+wHLb/Vresjowrbd/LQKfvmUbEF9Hz8BnOxOA1LcfRl9qHjZOV/xXh6rtzvUKp4haZPBRon2QF94Oh+Y9+pAVtgSORBZL9OCgXkayXGnOs4K5wqByPKJZqrNY/RzUrguP5UZh4GbfqY/RygfA7qKTaUnyqlXza6tkKnuVa3mPC+XJM6tPSoOlSqFW5slVr8Wr6DBopbnBvueR1qyIiXL9dj225GrsDNyzrH7E7xRWnt4t72GxtvxESAiZl0QL4o/lLGlC4A6zyyXjfn0jfoP8gaDgdDgKXZ3zWgdFMroXFUKP2l1pjmFDvKvXF/l1e4zI4TrW33trhWRfDZshcjEViG1i8yJxVJvBczEWt2QV2O40pu6dI6XFQqtPzW2XC2Y9ESkJ3WjsPZnSXBnOCZ6PnrCx+AHMnN3Lz+OYVMJA74F4ADNdClFqMS4b32X7IIs+UOWU8U6gue55xtVssJrwmmf4+oIiC8LdbM2XNphyV1JMAYDfrT2SvE9bcPrTuXjr64lHwSDF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icity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: If slabobj_ext vector allocation for a slab object fails and later on it succeeds for another object in the same slab, the slabobj_ext for the original object will be NULL and will be flagged in case when CONFIG_MEM_ALLOC_PROFILING_DEBUG is enabled. Mark failed slabobj_ext vector allocations using a new objext_flags flag stored in the lower bits of slab->obj_exts. When new allocation succeeds it marks all tag references in the same slabobj_ext vector as empty to avoid warnings implemented by CONFIG_MEM_ALLOC_PROFILING_DEBUG checks. Signed-off-by: Suren Baghdasaryan --- include/linux/memcontrol.h | 4 +++- mm/slab_common.c | 27 +++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index c7f21b15b540..3eb8975c1462 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -356,8 +356,10 @@ enum page_memcg_data_flags { #endif /* CONFIG_MEMCG */ enum objext_flags { + /* slabobj_ext vector failed to allocate */ + OBJEXTS_ALLOC_FAIL = __FIRST_OBJEXT_FLAG, /* the next bit after the last actual flag */ - __NR_OBJEXTS_FLAGS = __FIRST_OBJEXT_FLAG, + __NR_OBJEXTS_FLAGS = (__FIRST_OBJEXT_FLAG << 1), }; #define OBJEXTS_FLAGS_MASK (__NR_OBJEXTS_FLAGS - 1) diff --git a/mm/slab_common.c b/mm/slab_common.c index 89265f825c43..5b7e096b70a5 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -217,21 +217,44 @@ int alloc_slab_obj_exts(struct slab *slab, struct kmem_cache *s, { unsigned int objects = objs_per_slab(s, slab); unsigned long obj_exts; - void *vec; + struct slabobj_ext *vec; gfp &= ~OBJCGS_CLEAR_MASK; /* Prevent recursive extension vector allocation */ gfp |= __GFP_NO_OBJ_EXT; vec = kcalloc_node(objects, sizeof(struct slabobj_ext), gfp, slab_nid(slab)); - if (!vec) + if (!vec) { +#ifdef CONFIG_MEM_ALLOC_PROFILING_DEBUG + if (new_slab) { + /* Mark vectors which failed to allocate */ + slab->obj_exts = OBJEXTS_ALLOC_FAIL; +#ifdef CONFIG_MEMCG + slab->obj_exts |= MEMCG_DATA_OBJEXTS; +#endif + } +#endif return -ENOMEM; + } obj_exts = (unsigned long)vec; #ifdef CONFIG_MEMCG obj_exts |= MEMCG_DATA_OBJEXTS; #endif if (new_slab) { +#ifdef CONFIG_MEM_ALLOC_PROFILING_DEBUG + /* + * If vector previously failed to allocate then we have live + * objects with no tag reference. Mark all references in this + * vector as empty to avoid warnings later on. + */ + if (slab->obj_exts & OBJEXTS_ALLOC_FAIL) { + unsigned int i; + + for (i = 0; i < objects; i++) + set_codetag_empty(&vec[i].ref); + } +#endif /* * If the slab is brand new and nobody can yet access its * obj_exts, no synchronization is required and obj_exts can