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 57F84C48BC4 for ; Fri, 23 Feb 2024 09:46:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E37FF6B007E; Fri, 23 Feb 2024 04:46:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DE67E6B007D; Fri, 23 Feb 2024 04:46:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CAF8D6B007E; Fri, 23 Feb 2024 04:46:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id BAF0C6B007B for ; Fri, 23 Feb 2024 04:46:32 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 99A7741071 for ; Fri, 23 Feb 2024 09:46:32 +0000 (UTC) X-FDA: 81822588624.29.2259AA5 Received: from out-187.mta0.migadu.com (out-187.mta0.migadu.com [91.218.175.187]) by imf10.hostedemail.com (Postfix) with ESMTP id E9CEFC0007 for ; Fri, 23 Feb 2024 09:46:30 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=J4HpwTYM; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf10.hostedemail.com: domain of chengming.zhou@linux.dev designates 91.218.175.187 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708681591; h=from:from:sender: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:dkim-signature; bh=zUiVr8FrIAV4I+cbYerjVXtjBCfQ4VEZa/T8yi40/2g=; b=bMZs3Il7U9xoWuIxmNPvNF08/xDtE8XB8GTnffCXfXRlWLI2kMCClbi+ArVqV7lkXwy6wL +7DSiS3owgSL4klT0hO+UfW+BFogsi+NWgfUeacl4wSB0TwurK977RVjRLkAFJNLPK3O/r BRh32hiiLujLrLLBAi0i6p1l8jya+Gg= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=J4HpwTYM; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf10.hostedemail.com: domain of chengming.zhou@linux.dev designates 91.218.175.187 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708681591; a=rsa-sha256; cv=none; b=Jyf/kEg7OgD1LfPGJ/ZrzgqkDBl/L7Ptn//NthSxYSCYJ4rF2+xpPUDifC/MQoVbkz1mTS yIGpHc4p++anQTqfsx4P+S4mPsAwyj8AmnI95MgT3QgrrQmwVduICv9KCVYyNB/CCQB5is /WYx1tM9ghnrxiUFhCjKexInQ6Y9ftk= Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1708681589; 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=zUiVr8FrIAV4I+cbYerjVXtjBCfQ4VEZa/T8yi40/2g=; b=J4HpwTYMVOZ8VP7bU1cV1rYmzDonWG/A1zW8q70YrEx0MGtGx9hC/oWrgvqOVCWIPNEqUP g7z9j3eDRshD4UGUyxvxtKfTh8fzCdgMa4sNpcf3H0dteo4DDroTQC3bghf73+zbVR37ly ahRhXlHe5qVS/9GnHQ6jLViigwpBuno= Date: Fri, 23 Feb 2024 17:46:22 +0800 MIME-Version: 1.0 Subject: Re: [PATCH] slub: avoid scanning all partial slabs in get_slabinfo() Content-Language: en-US To: Vlastimil Babka , "Christoph Lameter (Ampere)" Cc: David Rientjes , Jianfeng Wang , penberg@kernel.org, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chengming Zhou References: <20240215211457.32172-1-jianfeng.w.wang@oracle.com> <6b58d81f-8e8f-3732-a5d4-40eece75013b@google.com> <55ccc92a-79fa-42d2-97d8-b514cf00823b@linux.dev> <6daf88a2-84c2-5ba4-853c-c38cca4a03cb@linux.com> <347b870e-a7d5-45df-84ba-4eee37b74ff6@linux.dev> <1a952209-fa22-4439-af27-bf102c7d742b@suse.cz> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: E9CEFC0007 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: mippb6xtmiadcskhms3kobsnukfr7po9 X-HE-Tag: 1708681590-434079 X-HE-Meta: U2FsdGVkX19B5ScEK4UBEnZ4nwNRCHJnzP0ny7l9idDrxvYWIDtrorx8zY0jwhnEBA9LkolLcMrLzgQG2pSIlqz74ak9zczblSuX21wmv7NkgoTlLHCWMyx7KLkQwsbZkUeRo5Xk3dctdeizgVSRSFsfNbDIqmHaDQ5sSqh/76GUnVOQu1kxn9FqY6ohZ0HnljsNvzQTgK2UhwhkyrqIMnBdaJYCrhK4hThAF/hr9/MrYt6A4ggxTpNJr1jrXkUb0KL7sUkuWW3ufH85vvNJQsn4+hoi/xGW0pnY2D76Er/EQRiT20ZruY+ILj8P5Sq4d6Oh/dap7GiBdiuW+cwTm3dDGB+xe1WJgtbzlx9H11H4Kf/qVDhqt/mmGjt16Mh+fgJNG3+8bP/TV50lkbzTii2LUm8dyM6FSMxR8SdHpWBGDDqM6e3EaWm9A6GNUhLm25M9bI+dHMOioczIvoq5pR7TyfivTke8bqgYPvc9Q676JTACnTcMa9LxCNQU/Bx/1uDr/YAz7EVP7/StT1q80+uWbSLEBXmJEUMxSBElxZQVdsI7JIfslgSwCzSxtHxDLskAMyKANbUGJkt5DmVfxZj90pYAHJcFU3C8apUnZ6TiV+uqBsefyQprIV46m2kvnmtIXwc4QTly4Q6fQ9w+LlckaeSUECSrtZwHQJg9HVtsqaOzf1dnlt3iOMSmqBFxxc/+wbtUIQY0W8QC3yJQhyBUOkpu6TauRFUmNVFFzLK/uZkwL6sEn8PXeVM4BGFKAWYMEKa/22CaL2iRuHIwI7TJ9jweYFBPAC7f+EdW4NP1mXPeNXAQ23fbOgYvnYOwi1Bu2c00zKyyeycPS5amgw9OCeVBvKwfYVkssnneRI9W7DwFszVke/Ak8yvpgrk41SH6r5SbWVWMwdTr/ZWgtG9vFQLa9mBoNsuBqc0Hcmo= 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: List-Subscribe: List-Unsubscribe: On 2024/2/23 17:37, Chengming Zhou wrote: > On 2024/2/23 17:24, Vlastimil Babka wrote: >> On 2/23/24 06:00, Chengming Zhou wrote: >>> On 2024/2/23 11:50, Christoph Lameter (Ampere) wrote: >>>> On Fri, 23 Feb 2024, Chengming Zhou wrote: >>>> >>>>>> Can we guestimate the free objects based on the number of partial slabs. That number is available. >>>>> >>>>> Yeah, the number of partial slabs is easy to know, but I can't think of a way to >>>>> estimate the free objects, since __slab_free() is just double cmpxchg in most cases. >>>> >>>> Well a starting point may be half the objects possible in a slab page? >>> >>> Yeah, also a choice. >>> >>>> >>>> >>>>>> How accurate need the accounting be? We also have fuzzy accounting in the VM counters. >>>>> >>>>> Maybe not need to be very accurate, some delay/fuzzy should be acceptable. >>>>> >>>>> Another direction I think is that we don't distinguish slabs on cpu partial list or >>>>> slabs on node partial list anymore (different with current behavior). >>>>> >>>>> Now we have three scopes: >>>>> 1. SL_ALL: include all slabs >>>>> 2. SL_PARTIAL: only include partial slabs on node >>>>> 3. SL_CPU: only include partail slabs on cpu and the using cpu slab >>>>> >>>>> If we change SL_PARTIAL to mean all partial slabs, it maybe simpler. >>>> >>>> Thats not going to work since you would have to scan multiple lists instead of a single list. >>> >>> We have to use percpu counters if we go this way. >>> >>>> >>>> Another approach may be to come up with some way to scan the partial lists without taking locks. That actually would improve the performance of the allocator. It may work with a single linked lists and RCU. >> >> We often remove a slab from the middle of a partial list due to object >> freeing, and this means it has to be double linked, no? > > Right, double linked list. > >> >>>> >>> >>> I think this is a better direction! We can use RCU list if slab can be freed by RCU. >> >> Often we remove slab from the partial list for other purposes than freeing - >> i.e. to become a cpu (partial) slab, and that can't be handled by a rcu >> callback nor can we wait a grace period in such situations. > > IMHO, only free_slab() need to use call_rcu() to delay free the slab, > other paths like taking partial slabs from node partial list don't need > to wait for RCU grace period. > > All we want is safely lockless iterate over the node partial list, right? Ah, I'm wrong, these paths also need to wait for RCU grace period...