Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp130190rdb; Tue, 5 Dec 2023 00:13:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtaoaxSrlWxONnkwa7J4v20STaFkLdgUMouO8sZly8uclQX3y3soC1avUZ0gKm/b7R1+5v X-Received: by 2002:a05:6a20:728b:b0:18b:c8f8:e539 with SMTP id o11-20020a056a20728b00b0018bc8f8e539mr2835406pzk.42.1701763992688; Tue, 05 Dec 2023 00:13:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701763992; cv=none; d=google.com; s=arc-20160816; b=f2BS5TMKUYf/XudG/cJY62iSmdEL2I5fcJfw/snNkn36iFh+ir6RLbFcHBIGztQMbl io7ZlVfCsqyu28z/onYg3POjr+NFGKAlIo1VuuHqL5w33T5tsV7/GuhVhLgH0caTq9Qp SKnr+n7SThnLGn13iy+f45zay6oTlykxQTu8W92R7ic9KKe0qfXVtpAlzL0MXLaP2c1/ sTpOu1U2OteT0Mkz4ZnJqYE6RUKODCU7k4uHcc0SrOadLNik5iECbqxg279I3SF2JNzw V9BsxuFnb1ontfb4cuVWvW6Bqi7tlXQsx5pmyjameSCmXMBaXiDyuAw26/bDxplWW158 i61A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=c7tcXxVB37+e74YIJ/SoIf8Zq3/8qsP6opp7sTACB/E=; fh=zuD9N5pN5mzGyGYPnd9z08QWmYn9dfavasdtweZowiE=; b=P0RcHoq/07C0PRHq/hyjW9zB0Hsp9MvKEduhubBq36xlPb7o6rF0C+FkDQCgBqBuXp /3icJKBiFL0bPPVYfO21efRIIGUe3CGbLof6TgU4awttaSUutwtgyaQup3HH/dBzKI47 CZhZo19aucVpTySQwqUCnTAxXJ20H/Tgw/yl08FTEes3UUGanM0aeXMjs/44oq0IJHUJ meE680A8PJ2KBT+r9IQjD5JTPdbwFrZCz76hShf57ewQ2NQtojJsSccM/q9735FYM+Wc KsolIUoQian5ZDjYzyJ+oXFFo4xKJEtRAyT0Sn1S4TfsDFLXsvvaAzwUIpG9bIIul2fY BW3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=JtHkQHye; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id me14-20020a17090b17ce00b002867eb143afsi4677496pjb.133.2023.12.05.00.13.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 00:13:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=JtHkQHye; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 4221180205FE; Tue, 5 Dec 2023 00:13:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344730AbjLEIMn (ORCPT + 99 others); Tue, 5 Dec 2023 03:12:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346735AbjLEILG (ORCPT ); Tue, 5 Dec 2023 03:11:06 -0500 Received: from out-176.mta1.migadu.com (out-176.mta1.migadu.com [IPv6:2001:41d0:203:375::b0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D707187 for ; Tue, 5 Dec 2023 00:11:11 -0800 (PST) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1701763870; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c7tcXxVB37+e74YIJ/SoIf8Zq3/8qsP6opp7sTACB/E=; b=JtHkQHyeKWUXLqCtj1D8woxmlUkmgsj3Um+0N3QTI3d/nMPguMeFOjwjbSAInQkyo3dw0D 7ZF4YwUoaQ7Wm4u+Abva2IoSi7um8PSW/xk+rytL9QW97nhEQrts6YnggQOIkjGr9NtkGO AkrlZet2qEakUYb2N7eODaod68dWZW8= Date: Tue, 5 Dec 2023 16:11:03 +0800 MIME-Version: 1.0 Subject: Re: [PATCH 1/4] mm/slub: fix bulk alloc and free stats Content-Language: en-US To: Vlastimil Babka , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim Cc: Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alexander Potapenko , Marco Elver , Dmitry Vyukov , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com References: <20231204-slub-cleanup-hooks-v1-0-88b65f7cd9d5@suse.cz> <20231204-slub-cleanup-hooks-v1-1-88b65f7cd9d5@suse.cz> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou In-Reply-To: <20231204-slub-cleanup-hooks-v1-1-88b65f7cd9d5@suse.cz> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 05 Dec 2023 00:13:10 -0800 (PST) On 2023/12/5 03:34, Vlastimil Babka wrote: > The SLUB sysfs stats enabled CONFIG_SLUB_STATS have two deficiencies > identified wrt bulk alloc/free operations: > > - Bulk allocations from cpu freelist are not counted. Add the > ALLOC_FASTPATH counter there. > > - Bulk fastpath freeing will count a list of multiple objects with a > single FREE_FASTPATH inc. Add a stat_add() variant to count them all. > > Signed-off-by: Vlastimil Babka Looks good to me! Reviewed-by: Chengming Zhou > --- > mm/slub.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/mm/slub.c b/mm/slub.c > index 3f8b95757106..d7b0ca6012e0 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -396,6 +396,14 @@ static inline void stat(const struct kmem_cache *s, enum stat_item si) > #endif > } > > +static inline > +void stat_add(const struct kmem_cache *s, enum stat_item si, int v) > +{ > +#ifdef CONFIG_SLUB_STATS > + raw_cpu_add(s->cpu_slab->stat[si], v); > +#endif > +} > + > /* > * The slab lists for all objects. > */ > @@ -4268,7 +4276,7 @@ static __always_inline void do_slab_free(struct kmem_cache *s, > > local_unlock(&s->cpu_slab->lock); > } > - stat(s, FREE_FASTPATH); > + stat_add(s, FREE_FASTPATH, cnt); > } > #else /* CONFIG_SLUB_TINY */ > static void do_slab_free(struct kmem_cache *s, > @@ -4545,6 +4553,7 @@ static inline int __kmem_cache_alloc_bulk(struct kmem_cache *s, gfp_t flags, > c->freelist = get_freepointer(s, object); > p[i] = object; > maybe_wipe_obj_freeptr(s, p[i]); > + stat(s, ALLOC_FASTPATH); > } > c->tid = next_tid(c->tid); > local_unlock_irqrestore(&s->cpu_slab->lock, irqflags); >