From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F7EFC433EF for ; Tue, 26 Apr 2022 09:25:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E55B6B0073; Tue, 26 Apr 2022 05:25:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 096FD6B0074; Tue, 26 Apr 2022 05:25:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9EF96B0075; Tue, 26 Apr 2022 05:25:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id D78ED6B0073 for ; Tue, 26 Apr 2022 05:25:45 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A3D2ADBF for ; Tue, 26 Apr 2022 09:25:45 +0000 (UTC) X-FDA: 79398497850.26.060DD0B Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf08.hostedemail.com (Postfix) with ESMTP id 05427160041 for ; Tue, 26 Apr 2022 09:25:39 +0000 (UTC) Received: by mail-pf1-f169.google.com with SMTP id p8so17426972pfh.8 for ; Tue, 26 Apr 2022 02:25:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=o+Ta1rYC4XzgSBxhpB0c8sQLq8UGlcT6xt5ODkQbkQo=; b=0YIeF2ZAA6Bz11BbIkTaGNdZbAAGqhcO8Mfw6ABDn+OpxksHQQhz1GDiiqSLYGghQC 3nv3WGqy4h5+ZUXp1xITbpDo9XK3aQR0Tb0hiQkzRt8TIun2g/jG2DGAfxKMyIkpdNSW Vu4cFO287vmzQ2PfdSOpgNY6i7Asd9mI4I/RX80dxzVv6gneDwHotHudeU/iBQLeE7DE jEApzYtLLyHf36DBHqDJF8YtlXpvVkIIfeT3QP2RNQMkjlXEYDb9EtEobw5EbSOTm6YD 60QIeqAGTDyWNfNR+inP90SH2UYqXmTxIuZLJHdq3FBAWiBcpb5c4LK3ZQ4/COUrVqMr o8kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=o+Ta1rYC4XzgSBxhpB0c8sQLq8UGlcT6xt5ODkQbkQo=; b=pTm35QhuaROmqzfwVQroSw4B5jw4cfcKTdhT740TiXXkB9WzSadpaFJNa7qkeIvXmK ZoInJOQWpS5i0RwfHZirexqo+yLajtQnf+z9/xw5wydpKHaHu+aqydFOS/azPGRcUTBF q++WnKTBs/JTTmF7NMGWCVHJBM4/HcCc/wRdUdXohplS1zX9/rkWLR4oJ7Pvwxn1t3av 1o6c1GCjhdt13hV2IKPLAZkVzcdiutNsLegB2lKhkY+5j5NWI2rEHGfQ4ijKkXQXREwy h+pMKQdyjssOa8yowLYIrkkGsvygwcySunf+X3D2o+xLlFHiLpL3O69qojHGnWY2rc/0 A9RA== X-Gm-Message-State: AOAM533PeLsfrGyV4wSYp60bK6tbP3E9081tWZfpBPtpFFoh/sH9ZRV2 0I2HayuBXpOQH+PUs7+VvKhGcjYn+U9sIg== X-Google-Smtp-Source: ABdhPJwmGwgasacrYyvp7VYrJteThiRtOydpsibMixp9x/XRgEK8KlC87ROV2hG1Cd3gVBK2ni05XA== X-Received: by 2002:a63:894a:0:b0:3ab:23c7:33ff with SMTP id v71-20020a63894a000000b003ab23c733ffmr9601378pgd.245.1650965144401; Tue, 26 Apr 2022 02:25:44 -0700 (PDT) Received: from localhost ([139.177.225.239]) by smtp.gmail.com with ESMTPSA id c11-20020a056a000acb00b004f35ee129bbsm16002825pfl.140.2022.04.26.02.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 02:25:44 -0700 (PDT) Date: Tue, 26 Apr 2022 17:25:40 +0800 From: Muchun Song To: David Rientjes Cc: cl@linux.com, penberg@kernel.org, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, vbabka@suse.cz, roman.gushchin@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, smuchun@gmail.com Subject: Re: [PATCH] mm: slab: optimize memcg_slab_free_hook() Message-ID: References: <20220425035406.9337-1-songmuchun@bytedance.com> <74f6b949-f9f-deb1-2786-47c92a619fd8@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <74f6b949-f9f-deb1-2786-47c92a619fd8@google.com> X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 05427160041 X-Stat-Signature: gopgeuqp3doumdt5xfbi7npn3px6wf3p X-Rspam-User: Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=0YIeF2ZA; spf=pass (imf08.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-HE-Tag: 1650965139-737241 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Apr 25, 2022 at 12:42:23PM -0700, David Rientjes wrote: > On Mon, 25 Apr 2022, 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(). > > > > I agree that for the SLUB case the code flows better after this, but I'm > wondering if you have any numbers to share on how much better this is once > we've avoided the virt_to_slab() calls? > > IOW, I'm struggling to figure out if this is code cleanup or a performance > optimization. > I think it is both. The numbers are listed in another thread [1]. [1] https://lore.kernel.org/linux-mm/Yme5zE8ZU%2FFN63Av@FVFYT0MHHV2J.usts.net/T/#m7e5c4ae3e92128781664b3396ce300c8076a5b63 Thanks.