Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp878635rdb; Sun, 18 Feb 2024 17:05:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUgI0LIvu1lKohq5J9PZzEJHljYtrvv/E6ghOFJh+HiIcMLo0PmvgHcg/3TBfR9hkf14hRJWVxpX4dyczYqiNfB0bBizcSxtiiXq0oCsw== X-Google-Smtp-Source: AGHT+IH6ZZxE/yZESUDGc5Ngln73ECPwVda8eDhCnEuddaLoBbwSzK2jQO8aB1rOqUZbOUI4Alt3 X-Received: by 2002:a05:6a20:4b22:b0:19e:cd14:1f8d with SMTP id fp34-20020a056a204b2200b0019ecd141f8dmr7852274pzb.35.1708304727391; Sun, 18 Feb 2024 17:05:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708304727; cv=pass; d=google.com; s=arc-20160816; b=RJ86N+SGt6DTLIqZeYWGF63JelCw0eGu9jd00V8VNzLVuq0rIvUsIcmcLTDSlFxZYh rEGp92muSz78rsXCGnn54FCik02CphVMnwchGVAx36NDG3/lW/XHxnK3z4fnIC1FfWeM Vsi9xu3K6bUrrffJcN2nqzzEqcOwwhP4cAL8w0XyGhrPMjdpPb29nuSVZe9w8gxw+la6 hy2fLZd5ZXlJxatjo0Z8ECPWAIt4XfcDY0p0sQfuXFZDIUXHeONOeY/KFT9ZQNxmhJdT 9dfX/Zj+zuOJ0NJrcq8UVh/kBQ8c/PGYQ/e1DPy/nHFbkjrpvn3RLG9XxdWXfNuOOsvy fHig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=mIDaOHUmOnFQVc3Wwg+6+LPaeJ2ta81+Eqz5TMzPBys=; fh=Y7GeBwYqDe56Y/bLPHiO67n8ytBabBzkNU51NYXo1ME=; b=kb5ZsSGcI+nXPh4iy1JJHQmORSLyOtQVTl5gowU4/gjVp6X0795dyMD7jrsgr7YySh gnFRGglOe+9zUU6mUz+DDXc1lKdyd+zYLbxkPxWwultiCzTEgNmn1rx0uDng+DLLaTo6 Gkag8czlQvMktCL3yvG7hLLrWEXamp56Z9eGPfYnWYw9rbfLsyywNRU193Pml8Dgv/k/ elPPBbTkQXT86JprP5pvvhP45c4kRpScyznhsBI46Ow68sQdaH/L79dE9HEOemMdTVg0 Q7wDsiHjgpKWvZ/APcMvbuGTr5FwpkBJykISCoET60iiviP12VgyrSDHIlmOm1WpOJMi 9Ksg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=fz+QvxkG; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-70633-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70633-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x10-20020a170902ec8a00b001db40e91bf8si3530725plg.249.2024.02.18.17.05.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 17:05:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70633-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=fz+QvxkG; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-70633-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70633-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 175862812C9 for ; Mon, 19 Feb 2024 01:05:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2246B2103; Mon, 19 Feb 2024 01:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fz+QvxkG" Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com [209.85.219.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE3F7652 for ; Mon, 19 Feb 2024 01:05:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708304712; cv=none; b=OUMmLuLLXgNQ9doBv3CrrhbPeuXQndkJJ0vmGwETFPTTnDn2fekCmM45LOJ0U8CtMzMS+x7rvPOuJ6t1UYTy2N2IZxXuNyv/J90qHzoPCYUUUNthTFQt7jCjysmPm5UrhavbwQz0YEljXO2j7Yh4jH8Xv3DsrrB0kOsYYVfYFS0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708304712; c=relaxed/simple; bh=RN/oOnbxOXJRjgABecn+1xhjdfXant7wAu1DO9OYV0M=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=IvzThXYuoZnprnjNw3C/gRcQIJVy6/mA+xTCM4Y1znhDCcKV7PxfFBMYaJ2MEMpCxZFXOrJfD5pJovWHtADSVrgR6/GYKLvkXQDenXxeFNssDjckkVocEMaJZTnLONMdmHL9yfr9oFWydSCDa5bL3EzCTEK7cd+wnJXzWaWOZrM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=fz+QvxkG; arc=none smtp.client-ip=209.85.219.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-yb1-f180.google.com with SMTP id 3f1490d57ef6-dc6dcd9124bso3563798276.1 for ; Sun, 18 Feb 2024 17:05:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708304708; x=1708909508; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=mIDaOHUmOnFQVc3Wwg+6+LPaeJ2ta81+Eqz5TMzPBys=; b=fz+QvxkGr229b6bOrKWi9XavB8I5cjL/HDA9sjZn+pP0oqOmBxKuzRnbZm2bmE6Nue 0X98b9HQ0mJuVpQCJ8NsQDg7bMdv4O6KJJIzE6uqTskf5hlTpRx6+OMe0ARgOY0bFZZP 2QfpxR5ErVjv499/jVaEHj6IeV8mVNVWmXWCC4NkPE8oA+lEidFad5YsZfvgtKh3Orr/ hP0JbfDr5YYpgdcjnvL68K/qXF24lAuS2EDLWGYZeMwuDeXvtJBb4N5JExgrI8l5DAHr B6lYOoDQJXe0Lhw9wpOcJKkd84rfPiGTDy54w80WJjCEq8y9G66FW8jcJBmU1Nibcmw/ qh9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708304708; x=1708909508; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mIDaOHUmOnFQVc3Wwg+6+LPaeJ2ta81+Eqz5TMzPBys=; b=DOAm9+WjzoDAPIvPiYu9k55SVWaSCLjNYIkhgiXM0Lp+fC8unMyD5qQXHoVQo3I5da lxcczUl7eOcED0uHkO4aYI6tm0QHoKz2bj0tDhfZBYZMqKN3ysmcCXaZfRfKWnuqqfF7 TARBVJZeJXC+gaEuWwp9zup693xc+KLc5g9EujQQ9A13mR0k4igsMd1lMcdPbPP1tD0B xYuhi8kex4U6lO21f8A4v1AL4k8fXty9LuU+rhTRmUJzgCfPiK2K+KX+9Kz1c/NzkxQz XsV4ar/XhUEadpo0zqXR4R6HAcsNYNjREWiorHtNdEh2sVjCNn1a6umH3Q1bovy4wYjz +YUA== X-Forwarded-Encrypted: i=1; AJvYcCXLNKKvz1W8UV7jcbx+QfbvpAZMKe4FP4GnOjWCU5hq3x8ogpAuSG2TIVCYoajyGlbB3wPFn2Uq7tFtzpY+eQ/qhpcoSGP4d83JopIr X-Gm-Message-State: AOJu0Yxvo1lagdT4NoHekkWQIANl4jnFbaZ6PxRX8i2lOVAF/5JZEMvt TqPMc6aTxtpzg2jp861N6GyLitj1FKQwm061F88WY1I8ZYMT+azkyKsEti2y8BBVQkzEWZWDBB0 2Zc7PIuXv5u3jIr9HHL2bFSU59UBfqwMhkMef X-Received: by 2002:a5b:b43:0:b0:dcc:eb38:199c with SMTP id b3-20020a5b0b43000000b00dcceb38199cmr10258615ybr.56.1708304707680; Sun, 18 Feb 2024 17:05:07 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240212213922.783301-1-surenb@google.com> <20240212213922.783301-33-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Mon, 19 Feb 2024 01:04:54 +0000 Message-ID: Subject: Re: [PATCH v3 32/35] codetag: debug: skip objext checking when it's for objext itself To: Vlastimil Babka Cc: akpm@linux-foundation.org, kent.overstreet@linux.dev, mhocko@suse.com, 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, 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" Content-Transfer-Encoding: quoted-printable On Fri, Feb 16, 2024 at 6:39=E2=80=AFPM Vlastimil Babka wr= ote: > > On 2/12/24 22:39, Suren Baghdasaryan wrote: > > objext objects are created with __GFP_NO_OBJ_EXT flag and therefore hav= e > > 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 fals= e > > 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 > > ... > > > index c4bd0d5348cb..cf332a839bf4 100644 > > --- a/mm/slab.h > > +++ b/mm/slab.h > > @@ -567,6 +567,31 @@ static inline struct slabobj_ext *slab_obj_exts(st= ruct 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 =3D virt_to_slab(obj_exts); > > + slab_exts =3D slab_obj_exts(obj_exts_slab); > > + if (slab_exts) { > > + unsigned int offs =3D obj_to_index(obj_exts_slab->slab_ca= che, > > + 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 */ > > + > > I assume with alloc_slab_obj_exts() moved to slub.c, mark_objexts_empty() > could move there too. No, I think mark_objexts_empty() belongs here. This patch introduced the function and uses it. Makes sense to me to keep it all together. > > > 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 k= mem_cache *s, > > * assign slabobj_exts in parallel. In this case the exis= ting > > * 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 sla= b *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 thr= ow a > > + * warning if slab has extensions but the extension of an object = is > > + * NULL, therefore replace NULL with CODETAG_EMPTY to indicate th= at > > + * the extension for obj_exts is expected to be NULL. > > + */ > > + mark_objexts_empty(obj_exts); > > kfree(obj_exts); > > slab->obj_exts =3D 0; > > } >