From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) (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 71AB5133287 for ; Fri, 16 Feb 2024 17:11:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708103491; cv=none; b=T3FEBV6iDWNB6jwGpLuqpvPM+N9rBds+nwiV8YiXjXe5v1J56WPCt8oqQ5D6dj6tERNxJjYEdXtpId1lr365ug+sU7yeJLtss7g75lVsvRfv6dPqkDX62yVIdAENGpTxmLNxHCFUFiOfIkDOYdB1FMA3Fo3e+xaSErpK1Hu48/M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708103491; c=relaxed/simple; bh=s5/J21l0Vb16qAasTR2af/DM49VlLYJehTHe2iQrZgA=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=c4tQr/33uaUMDdmK+j4dThi/wkjiZsvTcSFcex+XqAVJ4IjjznyQygv08dDKhbhyc8FwPeckZZzpaXuuDiQexw5OCT30VZT9R102RnapQoFV8UtBbeWZGIzHqBb/SVLj1YZWo5sWcdN7Pfb/6iTZxFZjBlNmuyU29cdjAQhs/jU= 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=IhonjF7i; arc=none smtp.client-ip=209.85.128.176 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IhonjF7i" Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-607bfa4c913so21752397b3.3 for ; Fri, 16 Feb 2024 09:11:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708103488; x=1708708288; 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=uuBxuiKdZN3KVCrAhLvxlGbAMwEHkyTmKhPVF6pp06o=; b=IhonjF7i5YFBSeoTWMrM3zJPshDaeWbhHkyvFnB+NDDQ+Ij7VL1y4CDWuUtJ3qQLKl Au2LnVhttTY8EleOOAm8nAZxngUYvF8wO9XVhoNzUP7uRfsFK7nsIze8PDhcPxzxV3D6 mY5DAN0NDRyj7KYkKpaZbc/I74WFsIAVT6M7orsE99u+Y6LhXh3tpyK0pYUpcZVO14LV iRr1SyOi5R2XYruaFZcRpTauoDgU2vsEtDFpLIIU5MvTRJYmFF61013C/57ZufhKGjMe 7voZSdkoVMKYEfSFym991AfVyG+N6LxkRFWrdXJdC/stdT+Z6pCznTPs3dldYjYueFhU aklw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708103488; x=1708708288; 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=uuBxuiKdZN3KVCrAhLvxlGbAMwEHkyTmKhPVF6pp06o=; b=A/qFQgv+UvU2QFLUQAVWRFr/mOEoqxykre5FXn7qTq+M6xpsPYkIWrPu/y3c5hLeyB q+P9e1Ut6FfHsGNutZ0I3RkBsChWI+jFxXNIR5pBKHTYtlGk1rJ+8NdQOS8t06ZnYnw2 BnOZeBXf+NEBS0NWDxHpZl9HeuNJKv/HO/dVb4EohXb0C4HRw74dU2b+gCjzwZp5EL3F 9/hdQZn0FsoNE5KganbhsgBC4g5cx4f/2AbQ6utIxjwRo9zvq2oWdyuQXezq4jfgckwa uoBPbEdYOkDyJ94EPcwFlZmhLbv3J3hdrRb8YGkzXhLgCxdz2wXVAK2ctk14FHp1pQFt fSbg== X-Forwarded-Encrypted: i=1; AJvYcCUOquHJ+O7Y/Wt7KMwRMr3mpjfyIdqapqAW0H67nKNxUojZsp+soYjk+9Mn3/7jbBtzJaoS+8tHKg6QQzsvMaXSF1HFyS9PvtfykfJ3KA== X-Gm-Message-State: AOJu0YwYygvRJzosRg9eyE/2xMgpZNub/nIcSJI2BNmtTB9/w5OchQvf h105s8zV9ddBSvp+CKjHE/cnJQawo5xOrptmVfqS4AbJw21dRgd1kqvNPrKCcf1hxkGNbkkqhDf ySXFcAhnjEho18Fn5jzv5rEj2+bdrp+rIkagc X-Google-Smtp-Source: AGHT+IGrTdDphKuPSMMFIAFPJovR9x9JDU4EDFPzTY0y3WFZl7FqMruLomlujQStik0SDQEztF8S9x7Y+PwqmZ025HY= X-Received: by 2002:a81:8391:0:b0:607:e1c0:450b with SMTP id t139-20020a818391000000b00607e1c0450bmr4624095ywf.0.1708103488010; Fri, 16 Feb 2024 09:11:28 -0800 (PST) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240212213922.783301-1-surenb@google.com> <20240212213922.783301-22-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Fri, 16 Feb 2024 09:11:17 -0800 Message-ID: Subject: Re: [PATCH v3 21/35] mm/slab: add allocation accounting into slab allocation and free paths To: Kent Overstreet Cc: Vlastimil Babka , akpm@linux-foundation.org, 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 8:39=E2=80=AFAM Kent Overstreet wrote: > > On Fri, Feb 16, 2024 at 05:31:11PM +0100, Vlastimil Babka wrote: > > On 2/12/24 22:39, Suren Baghdasaryan wrote: > > > Account slab allocations using codetag reference embedded into slabob= j_ext. > > > > > > Signed-off-by: Suren Baghdasaryan > > > Co-developed-by: Kent Overstreet > > > Signed-off-by: Kent Overstreet > > > --- > > > mm/slab.h | 26 ++++++++++++++++++++++++++ > > > mm/slub.c | 5 +++++ > > > 2 files changed, 31 insertions(+) > > > > > > diff --git a/mm/slab.h b/mm/slab.h > > > index 224a4b2305fb..c4bd0d5348cb 100644 > > > --- a/mm/slab.h > > > +++ b/mm/slab.h > > > @@ -629,6 +629,32 @@ prepare_slab_obj_exts_hook(struct kmem_cache *s,= gfp_t flags, void *p) > > > > > > #endif /* CONFIG_SLAB_OBJ_EXT */ > > > > > > +#ifdef CONFIG_MEM_ALLOC_PROFILING > > > + > > > +static inline void alloc_tagging_slab_free_hook(struct kmem_cache *s= , struct slab *slab, > > > + void **p, int objects) > > > +{ > > > + struct slabobj_ext *obj_exts; > > > + int i; > > > + > > > + obj_exts =3D slab_obj_exts(slab); > > > + if (!obj_exts) > > > + return; > > > + > > > + for (i =3D 0; i < objects; i++) { > > > + unsigned int off =3D obj_to_index(s, slab, p[i]); > > > + > > > + alloc_tag_sub(&obj_exts[off].ref, s->size); > > > + } > > > +} > > > + > > > +#else > > > + > > > +static inline void alloc_tagging_slab_free_hook(struct kmem_cache *s= , struct slab *slab, > > > + void **p, int objects) {} > > > + > > > +#endif /* CONFIG_MEM_ALLOC_PROFILING */ > > > > You don't actually use the alloc_tagging_slab_free_hook() anywhere? I s= ee > > it's in the next patch, but logically should belong to this one. > > I don't think it makes any sense to quibble about introducing something > in one patch that's not used until the next patch; often times, it's > just easier to review that way. Yeah, there were several cases where I was debating with myself which way to split a patch (same was, as you noticed, with prepare_slab_obj_exts_hook()). Since we already moved prepare_slab_obj_exts_hook(), alloc_tagging_slab_free_hook() will probably move into the same patch. I'll go over the results once more to see if the new split makes more sense, if not will keep it here. Thanks!