Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5742023rwr; Mon, 1 May 2023 10:04:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6VpdZgS5eRuS7rODXgDr8xX8nW38oQD8Mtgas54onUI5/RegAlgyd5mzuh9IuU6zT5hbmT X-Received: by 2002:a17:902:d48b:b0:1a6:ef75:3c53 with SMTP id c11-20020a170902d48b00b001a6ef753c53mr18004277plg.11.1682960656957; Mon, 01 May 2023 10:04:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682960656; cv=none; d=google.com; s=arc-20160816; b=1HJ0jjS5rpKKYMBGXPN7SdwNADSt0ZAVVHWMX4as19WiGrh7xaIIjo+3IxSFYMthPa mpu++DcD6jQWSylkuOBKTrGy1V6ey8ufZAolJuum+G0f9roTrE2JnhJOGW1af20G8sKr LuTb2EcBfBiJpk3Ode9t+30jWy5RmQJWlvgCxbmv3iaJKfDUqvh2YLxNhdiCKbTQcUJR /1IZwPPc7ipyumbvZbVxWbac6UvL0UVHW2uC4jjJS6vwwhwNG6d3IkcjelzOvJz2NRe1 twM3uQ7vLZrNTULVZ1XuqCuoLJEJbt5iQNTswbawy9PpLnQMEgnIFBypjwP7PvUsMQuE KM9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=6mzPQystPbLbDwPdw2fPo41K7qknlkieEKK3sweddW8=; b=R5xtXvjlbiVLNxCeeUNmTnS3BQPtjHaceJsqvWP4xwiMkY9ATL6Don2EalVDYDxqgp T4tUuw88MopzVfZN8JoOp5aMwOQKBlJdlGNLMzvgxKgQc8LAyeiFH6C1H9Tn7ny5viUg 2XDZPIZvV61wpI8p9DMom4tF5zPmPeMQ6aTP2Z/NnQp9kLD8TfhFkd/eKEhHOp/VOSZ+ 64nGRpPG87YDqo0U3A0Y6QmuQPs4VATCWDPSCrGCipwUV8NBfIWR5PMPLGusoxohs1Ru hZu6um/gw2wlKCMQ+KUrvgMU3Y3Nr9vs5KcjavOdCmkcI4ZoJjZAKY7tWv4xxaeD8unq vBag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=48U8jHG6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id li15-20020a170903294f00b001a6e8791efbsi26060832plb.465.2023.05.01.10.04.04; Mon, 01 May 2023 10:04:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=48U8jHG6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233296AbjEARDi (ORCPT + 99 others); Mon, 1 May 2023 13:03:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233167AbjEARCV (ORCPT ); Mon, 1 May 2023 13:02:21 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 131CA420E for ; Mon, 1 May 2023 09:57:09 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-559e281c5dfso25142787b3.3 for ; Mon, 01 May 2023 09:57:08 -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=lq5/1QdS7FRpeQI6018eVUNc5GNm4VYYCOkZyuzXTvFVTTgsjhcJz+KRipKIrERjrO C0YkcdQsiKqnm2nb9biPyRIXtVbMgkEKjWdwaf4vzSyFrSK0g1ht/UWkdLvC30zaQ+En FpONZrqyZ5v10L+Jpi2xnUeIZQMQXkt/NBMnXscIhlGV4HzvVbGf+5lsCDhs37OIZXzH t/LjSLLcAmYDBpCJ9zh5PrjwuxFXezIiSxACKVW0JIYFZy8NAChwOY4uIofevHnhpCEY 9M8UiQIHn6ZtvT5DLZ9lZH/0XnEXHHnbbo6Txs8KMZG67Y8imEJAWW3ITyPxADFfohXg xrnA== X-Gm-Message-State: AC+VfDxGnTM1dVsDu68CoIEo8hl33wNS/sL0E1s+B1lX2/MFeK9226kH Wtvx57pBPebMkadwdS+TSWTLIYTB03k= 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 2.40.1.495.gc816e09b53d-goog