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 0850FC5478C for ; Fri, 23 Feb 2024 09:37:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 814026B0074; Fri, 23 Feb 2024 04:37:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C2E36B0075; Fri, 23 Feb 2024 04:37:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68B7C6B007B; Fri, 23 Feb 2024 04:37:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 588316B0074 for ; Fri, 23 Feb 2024 04:37:16 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2F4B21A103E for ; Fri, 23 Feb 2024 09:37:16 +0000 (UTC) X-FDA: 81822565272.22.A8ED6CC Received: from out-187.mta0.migadu.com (out-187.mta0.migadu.com [91.218.175.187]) by imf15.hostedemail.com (Postfix) with ESMTP id 53950A002D for ; Fri, 23 Feb 2024 09:37:14 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=jjrYq374; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf15.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=1708681034; a=rsa-sha256; cv=none; b=kX5Z9N/BfGdYdDQWwiD6uLlPzQYT6PqLcEAoOtiI9Rdbbp0jHXKTBU8Ajj3CH7RN/SgMSy 8tKegIPs/EGY9SrRWSaM4dUn3wkPU1bPa9pELYS1+oU49j3WCcVhfSz6saFzxiyeG6d7dB IJF7Uw7lHSCK/J32i7C7XIgXLy+iy+c= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=jjrYq374; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf15.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=1708681034; 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=HzER7OhXDXXtT+kFCtMikAUhc/bsaxZeUNpSwy7ntWI=; b=j4oDMoeGJyAVMcRJjOAwjWEfpMhM5M1ocuJ3newsdo4eAfipSeLwB9e1xUNKbcipwYuadw Ex3shhtSm3Y5LJ0/80kreN+J2RVd0aPSlzEZMS/m0yVrtpqK5b3uJ9pErVdmgfj60Wz2cK SuM2Udi60AjPJhfFuSojUi5B3mvXCfY= Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1708681032; 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=HzER7OhXDXXtT+kFCtMikAUhc/bsaxZeUNpSwy7ntWI=; b=jjrYq374N+kVeUAzk3JTFeEWhyRXyJfb9BEgwTPV2KEi5B+NrBpuaH/R8ml0nU6hsmfUbC V/qqHZszzOPpTdCcCU7i4EJ5NWp96R4+J5YGqP4D6yAr1YvgMOlkT5zaDAauq+Iz9FvKVL 1YmL05olRjW3DyczN6V+8m9pTEzGHpk= Date: Fri, 23 Feb 2024 17:37:03 +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: <1a952209-fa22-4439-af27-bf102c7d742b@suse.cz> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 53950A002D X-Stat-Signature: h4wnt7yj9jp67q4uxinrq86qs6xccwjg X-HE-Tag: 1708681034-68240 X-HE-Meta: U2FsdGVkX1/dtGUpnxxd4VviYeW3rKVaHFLdzK+RxKe/aJ88iHQ+sRGeBaBmth+VWfEHKlXs21TXXWlJ6q0dS5L6OUPJh/M5jHjgFc9htaLFGpfIRjDuJzCHVK6cqOBAMLUhYZaxGWU6G8yE/2KgaTPhvizAX7BVbevl/KfdDm5hEMNAuTbGGTSNxGUWM/1IZ2omrxy6lGZBrMPQxN8id7arvMmYYZ25tV0+bV4MHxo3Q1AoCXwDPehvbYWNQrJhgjE++Q/ANTDFUy0/SJ4fuvwOoNW5gY9MtpK2ivnwOSoCSXNcPSNLmiX62E+59m+Oeeejds/nSr/TsrDYHcW9YY2UviiF1NmLAYfFQwhiUd6Dou0oO6A7KTSUxbzcLoBXdsfAl9Ef2PoNR06ecZwLEviGgEjySD7n7SncQs6UlSDYSUejhcUXEOZBp6UuhUJshcmo3TE1VsaysMYxJb89w/psVF7j5q6tpAPS+n42Tit48kYlNkhSHXS8KtwP65AvA+YR95rQjGIHEFkm/3AyRmLPXrjIIjAUHCXWQ60AhXdCY7felzk0kL8qJaNuOD9VNTglXzYOF0JdbGwsh3Bs7PxQcZwVmsa1tmIR82RAurcAv0zeOWP4AcpJew6NkwvMUiQeF7I2wtH7vsqYvnSw+KMQ4tPsR4lIO7jVHx06SUMChWTE25wse2D2t9FYTEgoJEXgIObRwh99s+I5isTstiQfgb5kMj6j6CUVmlYpz55DKwtlv9uIKE8eszzfVDmgmn8KC7gacwBUQdb2kquBIQH/2YH0jBC+OkuI/0oymNiVBq/89bp6wkMgJAH6u9jxHYcSOQXwxIHcsUhEXcg5Qw6jzkIFsPPMSyQMEUKaVPcZ2RlHJdc43DhvkiuMNYIW782QL6yRaKZ255h5Pch1m6zEnBuwh/CNTxQqYNUaEMY= 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: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? Thanks.