Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1477423iog; Tue, 14 Jun 2022 06:55:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxXupwWZdRbNHqO4TlJ1HvxapyPvOvYDjkXyxKtIGGnIjse5y3++OSNgoDrsfUh2UpoQp6 X-Received: by 2002:a17:906:e87:b0:6df:8602:5801 with SMTP id p7-20020a1709060e8700b006df86025801mr4543042ejf.140.1655214917146; Tue, 14 Jun 2022 06:55:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655214917; cv=none; d=google.com; s=arc-20160816; b=u6CoVa0fqe9snQtXbEtiRgEaTA1weqs0e3OotGTqyqFXWkPSWCIldiQwmi9P3ucdAQ REAqv/I3gj81hpRELWCKsFdY+iFaWkh/4pJYRnay22HZSbdclmpSo2roVgWKkT5pLZjv aMwSFcu3TyVfBIIgrrG8SOgiSbWsZ+V1Vf5jmPSNHxy9ScNmyk+BSSocZdm9almq4cQb KEo6OipHJQSjWI69+JjsSERgVV0OSgerZELs9MAGR4axW2RndYxmBtIqQolyA76+ksLN HksZA9839W5fryj3WGr0tAfHY74B6I4F9QjdrvspNNsoGNZyC07VPYZaxImmW18SByzN /ghw== 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:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=SMr1/XLuAOMxSe9sGiC+UXBNDWGlTqQ/hao0UnZOiCI=; b=UrSmK38sfAOJttpiVZtfN2JTB4i5b19Sv3QXJtKwDFqfthPfmQRrQALDjaQP+wdTZH ZTss1wiGvLbGDpMjAlBdGj6aI6Mu+opCFVCzPqTUMw+Cg/EDQxZtJj6tVc/WX7Anp+sm bDc+RaLQ3pyK6kd69eMGHMDe5oj9yqJYUlPrLex6bvfV4iZdxPt0f1X5ZLg6gmziL9qi m1oCLxI8CtqzzVjTa+xy51sZiSnMuZjxJFuHJ82As7Y5TSM1MVnMBf1Q1NXfCyZxh2mU R/p9/J5hKU6+KzYmR1joKvtssAhxT/WcFOKgfxrwNJvmDiM7moCPx+TeEzZEL/ZUK6t6 XOwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=aqiIxHDc; 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 p29-20020a17090664dd00b006fece7848fcsi10382095ejn.252.2022.06.14.06.54.49; Tue, 14 Jun 2022 06:55:17 -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=aqiIxHDc; 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 S244894AbiFNM71 (ORCPT + 99 others); Tue, 14 Jun 2022 08:59:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245146AbiFNM7G (ORCPT ); Tue, 14 Jun 2022 08:59:06 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C82233373 for ; Tue, 14 Jun 2022 05:59:03 -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-out2.suse.de (Postfix) with ESMTPS id 99F841F944; Tue, 14 Jun 2022 12:59:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1655211542; 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=SMr1/XLuAOMxSe9sGiC+UXBNDWGlTqQ/hao0UnZOiCI=; b=aqiIxHDc67wDyQai+z0F83OzfB6xGkNrq/XkHJKxk4FcWvVQeetmOEq0jVM5nfkw4U6W0i AhDlvbtg2eMpBk0xaKpXpe8G3ER+p0aRY2dxxo2TcCUwYnfsopDv0v+Tl98P2bDPPILGPn dzb9IQ8M9zYiYajZIYWnGU+uxp2NuO8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1655211542; 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=SMr1/XLuAOMxSe9sGiC+UXBNDWGlTqQ/hao0UnZOiCI=; b=hQCKkXMCzGmeos73iIO0EA1Qpu3C+txcsjMekPresAyq9BtOQv68ZbQfgxh2bnHPTSyi+n /+DygIGkVcahWSAw== 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 6FADE1361C; Tue, 14 Jun 2022 12:59:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id fHpgGhaGqGKVGwAAMHmgww (envelope-from ); Tue, 14 Jun 2022 12:59:02 +0000 Message-ID: <66864da8-4eb4-f177-3518-dc4e16aa183a@suse.cz> Date: Tue, 14 Jun 2022 14:59:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH v2] mm: slab: optimize memcg_slab_free_hook() Content-Language: en-US To: Muchun Song , cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, roman.gushchin@linux.dev Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, smuchun@gmail.com References: <20220429123044.37885-1-songmuchun@bytedance.com> From: Vlastimil Babka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On 6/9/22 08:34, Muchun Song wrote: > On Fri, Apr 29, 2022 at 08:30:44PM +0800, Muchun Song wrote: >> Most callers of memcg_slab_free_hook() already know the slab, which could >> be passed to memcg_slab_free_hook() directly to reduce the overhead of an >> another call of virt_to_slab(). For bulk freeing of objects, the call of >> slab_objcgs() in the loop in memcg_slab_free_hook() is redundant as well. >> Rework memcg_slab_free_hook() and build_detached_freelist() to reduce >> those unnecessary overhead and make memcg_slab_free_hook() can handle bulk >> freeing in slab_free(). >> >> Move the calling site of memcg_slab_free_hook() from do_slab_free() to >> slab_free() for slub to make the code clearer since the logic is weird >> (e.g. the caller need to judge whether it needs to call >> memcg_slab_free_hook()). It is easy to make mistakes like missing calling >> of memcg_slab_free_hook() like fixes of: >> >> commit d1b2cf6cb84a ("mm: memcg/slab: uncharge during kmem_cache_free_bulk()") >> commit ae085d7f9365 ("mm: kfence: fix missing objcg housekeeping for SLAB") >> >> This optimization is mainly for bulk objects freeing. The following numbers >> is shown for 16-object freeing. >> >> before after >> kmem_cache_free_bulk: ~430 ns ~400 ns >> >> The overhead is reduced by about 7% for 16-object freeing. >> >> Signed-off-by: Muchun Song > > Hi Vlastimil, > > Wolud you mind picking it up? I did not see this patch on the > slab tree. Sorry, was waiting for rc1 to start the for-5.20 branches and was away for another week then. Now pushed to slab/for-5.20/optimizations > Thanks. >