Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2938263rdb; Mon, 4 Dec 2023 11:35:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IEv4WkoeGfIgfjDKMOWPviLW/v6hbqs8aPEUNpN25uEG8XSXhprp/Oyaa5MjZaJDRZi3Jyq X-Received: by 2002:a05:6a20:ae0a:b0:18c:da:ba0b with SMTP id dp10-20020a056a20ae0a00b0018c00daba0bmr4377736pzb.44.1701718512237; Mon, 04 Dec 2023 11:35:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701718512; cv=none; d=google.com; s=arc-20160816; b=YZP6htPloZG26pqnLvYqWF2d4M6JygeyXrNJAoVKVVBl1GLSnmS/P3TtHkptqkmBu+ yhq+CFOzZWfSF7Y5W9mFMLmc/aZTaW4xKrV3q7oDTVWJX8dDi+3Z4KmMFr9NOlcswGEr wjwLqQ6NA3GluHQ3OQ/4qia7ZnkvsR/pcSTivmLN6yp8LAXamXQ5ym+jEwH9b2x8GQDk IwJ7zkdA7htFkCZfa4Qc1Gq+RDkF/+L/FEQsIHp8JlCRFJ9T8pJD4JY8I4QpE0cU7nxz XSvtJ199L60NOeV2RYRCt14WrSsbaPZKWBSxW5xxPDrTzgsyswRhHDg80MRKh9ziUq4v C8fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature:dkim-signature; bh=EqcJTAjZFB8lQHDKYDjIZchVKot1dBAP9whijzHZRBs=; fh=QGaHzSWEdTlyx4gN2Cp05xyAuU2J2OcL//unbyREezU=; b=wiMi1Vm+RNFlOGHP1DFTENkzcHPc81DsX5yZPjfGSO6SW7XB4fRdLDwgvHQ0AcsjmJ XNM9Au1G8LRCunS2fYQifTnMCEqfrVo77AEt2KRkzW4FKhionLUnqBdMvxW7flIhZkG1 wTnBTk7ftlJ+J3YS4zqTUrI7yxsVdUeO2P1ADyMFleEP55NJheApCe6p80V1p7Uq+3XD 6GzqxU3y7UV8IVaz/AkEt8fZsv91uHOp+9B8EIXa6CrFGEGQVMBmJ2/PXmT0dv+zOg7Z eDeUg2aOxo4mR2ohfRiljNDRkHBeDSD0lRG7gAbGRX3bKXOeGj8vt228+TnaRB/8KPL4 WPlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=3aoiT3pa; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id s26-20020a65691a000000b005c66b0c9dd7si3746500pgq.786.2023.12.04.11.35.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 11:35:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=3aoiT3pa; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 1FABF805E021; Mon, 4 Dec 2023 11:35:06 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232531AbjLDTet (ORCPT + 99 others); Mon, 4 Dec 2023 14:34:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbjLDTes (ORCPT ); Mon, 4 Dec 2023 14:34:48 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFD56C1 for ; Mon, 4 Dec 2023 11:34:53 -0800 (PST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8DF80220FD; Mon, 4 Dec 2023 19:34:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1701718492; h=from:from:reply-to: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=EqcJTAjZFB8lQHDKYDjIZchVKot1dBAP9whijzHZRBs=; b=3aoiT3paks0mcXiEeezN/xPw9jv7Di3tra3+7n/QDct0IcBebFNeztkLnzZNR1eA+r+5P7 5HTYlXZjd6w/d/4hPiYwAl8U4a6RDNwPAenVha70NBnhh7hjIhw5Mnrb5mEfP6x/vm7DcI RvtCEN+PAXA5BPRclQuH0Zu5ugFOvzQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1701718492; h=from:from:reply-to: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=EqcJTAjZFB8lQHDKYDjIZchVKot1dBAP9whijzHZRBs=; b=LJvwh73CRk0ogt5DyHZYk9KKPNPbooLArhcWhOV7Z8vEi3KnNjT7llf/nkqXmRF2A2S/E1 I9N7BuX+zof3jCDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 70C1D13AC1; Mon, 4 Dec 2023 19:34:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id KHI2G9wpbmUPMwAAD6G6ig (envelope-from ); Mon, 04 Dec 2023 19:34:52 +0000 From: Vlastimil Babka Date: Mon, 04 Dec 2023 20:34:40 +0100 Subject: [PATCH 1/4] mm/slub: fix bulk alloc and free stats MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231204-slub-cleanup-hooks-v1-1-88b65f7cd9d5@suse.cz> References: <20231204-slub-cleanup-hooks-v1-0-88b65f7cd9d5@suse.cz> In-Reply-To: <20231204-slub-cleanup-hooks-v1-0-88b65f7cd9d5@suse.cz> To: 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, Vlastimil Babka X-Mailer: b4 0.12.4 Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spamd-Result: default: False [0.20 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; BAYES_HAM(-0.00)[15.64%]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_TWELVE(0.00)[14]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[linux-foundation.org,linux.dev,gmail.com,google.com,kvack.org,vger.kernel.org,googlegroups.com,suse.cz]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[] X-Spam-Score: 0.20 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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 04 Dec 2023 11:35:06 -0800 (PST) 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 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); -- 2.43.0