Received: by 2002:ac8:5491:0:b0:40f:fb00:664b with SMTP id h17csp615163qtq; Thu, 10 Aug 2023 10:34:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHr356uJig2ZlGbx4jQxfsIhtmCFXzWDckiHz4KxvhYTPqwE3Wc+y7t6F8gAMbhqZkdCNEa X-Received: by 2002:a05:6a20:8f29:b0:126:42ce:bd44 with SMTP id b41-20020a056a208f2900b0012642cebd44mr3691174pzk.17.1691688881692; Thu, 10 Aug 2023 10:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691688881; cv=none; d=google.com; s=arc-20160816; b=jAEWSnK+pSvV/M7EA+sDQTLDpMTYc9w5lWQ6D0wNp7f/uqMWUhIYSbvx7VcEuEyNiG GcdoCbVGhmZL5JZhpJkMZP/lENHAQ8o+T/VWZjmavEM1WYZvF1xH6m2a3ivtqsUIlabh NWjmsU8tDZBpfJz/1aA9LLcX3KHhtmkjhqQWKBkX2UbcCuojx8WPfu7BLaDtMS7ST3ci 3lX+vVRoaY9kcip9/vhan4nVsO+QBNRmb/U54gocn3Lwx8Ph2xLDrl26gDeG32fT16Kx 8dpbAAxvFcS2WBxogDr2ifXz9bv6JkMi7Z0CecTq4/RWkVHJNp8i7ltXkqI/JYOTCwsi vF4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=X+E0unmCYoA/5q96uLhFby2/QU/JbMexzKmCXmErmbw=; fh=2pBnSfjX50e7Wv5klf1T27fGwt6nBz7bVyyBTq15zE4=; b=el0Dhoa/3ZhHzLQcXyJhxUmkXpVT9bC7P+oevu5Ss1fViIkUJEGSPOZdbJBZd+nBS7 IJJiYObf0TKctrBCcpX2FvSvOjll41P1E6ZZNq4iCtzgeM/1qVWFUdAVuLi1VsYJEd8c C8rDnZGqnAZfw9Q+6KRApDFU+N5MNPJItVfHKscVoyTdsSphIPR//NW5CNoGT7WbfNCL D5a0lZFe/lq4y9U2IbRlEFU2WTj+lNvbjdLBlaH3IcfXNWFEG4S+q++zmS5MfOaf0AE/ sI3s+bJWgs6zMPiJIg+pNn8OB0jWLUWatseR3JqbKIDeyJk2RMUX73MkueeubZ4/31Nj QuXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=JWeB4JaU; dkim=neutral (no key) header.i=@suse.cz; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b26-20020a6567da000000b00564b99f1275si1832262pgs.446.2023.08.10.10.34.29; Thu, 10 Aug 2023 10:34:41 -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=@suse.cz header.s=susede2_rsa header.b=JWeB4JaU; dkim=neutral (no key) header.i=@suse.cz; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235087AbjHJQgf (ORCPT + 99 others); Thu, 10 Aug 2023 12:36:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234199AbjHJQge (ORCPT ); Thu, 10 Aug 2023 12:36:34 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DFC99C for ; Thu, 10 Aug 2023 09:36:34 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8EF7621873; Thu, 10 Aug 2023 16:36:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1691685392; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X+E0unmCYoA/5q96uLhFby2/QU/JbMexzKmCXmErmbw=; b=JWeB4JaUfgHvZaQeMrzQj2VqCapH0EynaaBfufBlIRxTx2ECYhL9B4n2CuXBu6jHkxgffL uVIy1YZx4Q6tJiGJvsrFSVobLMkg9U3vkSz/at4f5HT90qx28+/qHEIJYIHKswNOLrQsr4 QED/YEf1+onvGmo/vyJGQ/ZssUBn/y0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1691685392; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X+E0unmCYoA/5q96uLhFby2/QU/JbMexzKmCXmErmbw=; b=LJ6qkOJeM0r8nLNtSMjM6Pg9NO37l/Pq3Eu3JIT5fRdJOyJqXGNu1/AgSzrz+6N0a1tK+A kI0gqf+8T9tuSgDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 61C11139D1; Thu, 10 Aug 2023 16:36:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CIAVFxAS1WSEPQAAMHmgww (envelope-from ); Thu, 10 Aug 2023 16:36:32 +0000 From: Vlastimil Babka To: "Liam R. Howlett" , Matthew Wilcox , Suren Baghdasaryan , Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, Roman Gushchin , linux-mm@kvack.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Vlastimil Babka Subject: [RFC v2 1/7] mm, slub: fix bulk alloc and free stats Date: Thu, 10 Aug 2023 18:36:29 +0200 Message-ID: <20230810163627.6206-10-vbabka@suse.cz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230810163627.6206-9-vbabka@suse.cz> References: <20230810163627.6206-9-vbabka@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS 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 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 --- mm/slub.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mm/slub.c b/mm/slub.c index e3b5d5c0eb3a..a9437d48840c 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -341,6 +341,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 +} + + /* * Tracks for which NUMA nodes we have kmem_cache_nodes allocated. * Corresponds to node_state[N_NORMAL_MEMORY], but can temporarily @@ -3776,7 +3784,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, @@ -3978,6 +3986,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); -- 2.41.0