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 A6196C48BF6 for ; Mon, 26 Feb 2024 17:38:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 11E9E44018C; Mon, 26 Feb 2024 12:38:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0CE8144017F; Mon, 26 Feb 2024 12:38:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EFFA544018C; Mon, 26 Feb 2024 12:38:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id DDD4744017F for ; Mon, 26 Feb 2024 12:38:20 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id AD9A7407F0 for ; Mon, 26 Feb 2024 17:38:20 +0000 (UTC) X-FDA: 81834663960.08.BB9D913 Received: from gentwo.org (gentwo.org [62.72.0.81]) by imf01.hostedemail.com (Postfix) with ESMTP id 27F7D40020 for ; Mon, 26 Feb 2024 17:38:18 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=linux.com (policy=none); spf=softfail (imf01.hostedemail.com: 62.72.0.81 is neither permitted nor denied by domain of cl@linux.com) smtp.mailfrom=cl@linux.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708969099; 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: in-reply-to:in-reply-to:references:references; bh=tnoapE6PudbLdsieZeiuzTfYx22Q1QZa9SB7dpd4COQ=; b=vY/ELc78ezJLDwpKRILu2JYPwmxeoSLLOxHllKVqP+AlSNHv1k6z4eltau5YvO6rmkUB1/ URMw7nMrCncjVPGDJlMzcQhDgrSbr8WiOi+H8eSWgLm0QrXP3HYVNXiKXeWSEhcXHMzXzh ej3AXRpkmlkw/a2Q+6E7BP5nYxSQjwI= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=linux.com (policy=none); spf=softfail (imf01.hostedemail.com: 62.72.0.81 is neither permitted nor denied by domain of cl@linux.com) smtp.mailfrom=cl@linux.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708969099; a=rsa-sha256; cv=none; b=3PWECgAwAeTc4FNwuSf8S0gDlykBVMNe/yFxQtMerT56/ZAiHIO3esEsLHklMzDwxVoT3Q P1eXh5kEx9xjzi+ykV8qcfJzvzZj38BLjfIG5jUmjGeRQG+GDIYaQ5LhFxfXdSDU41EgPS hBWlUHAtMmjgswqSm0y/wTlR3XmID1g= Received: by gentwo.org (Postfix, from userid 1003) id E16F640A97; Mon, 26 Feb 2024 09:38:17 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by gentwo.org (Postfix) with ESMTP id E0A684093E; Mon, 26 Feb 2024 09:38:17 -0800 (PST) Date: Mon, 26 Feb 2024 09:38:17 -0800 (PST) From: "Christoph Lameter (Ampere)" To: Vlastimil Babka cc: Chengming Zhou , 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 Subject: Re: [PATCH] slub: avoid scanning all partial slabs in get_slabinfo() In-Reply-To: <2744dd57-e76e-4d80-851a-02898f87f9be@suse.cz> Message-ID: <036f2bb4-b086-2988-e46d-86d399405687@linux.com> 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> <2744dd57-e76e-4d80-851a-02898f87f9be@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Rspamd-Queue-Id: 27F7D40020 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: wtg1ftud3ikcxk4n6bz3dh14ukie5a93 X-HE-Tag: 1708969098-203399 X-HE-Meta: U2FsdGVkX18NQvirhHiX2y6Lwbg2EkUYYo4CsRDLcMDlJoGllczx/LjCReL9S0ggMVB+Vq6EfFnkNAqRcw8vsUuZVh5IwpyquKQGt+W38JYoq5IDnHAf8iWoxzSd5naY+StW4Bp2bRu4pIhpTtT7+VIOxmREBaAUuQONms52xpQCQVg+ZzHYKvQYoliLydGbdSCNHxbohK1LNz+Jv8sFEW3csb6fVnat3nX7a95FJ5Kwl/rO5Z1BRoOX892DoAZ4UmDIAkwxnb+P3AF/DaxJnvttoKnDhDzWpG9yTvPuwfZ3ABGrWfVcwCKqkHfhXfPVaiKFtbu/PyAakbrfPdflrUhXrIyRBu9TyN277Gt9KQXkCOBCmrkcZBAsp0A20ZZEjf4CMqC/wZ24Y4GFwTt+jErh/b+K3zwVTnrx16dhevf9i5QDaCIhSq3lunpIBiOm8/73G85YHHZZ3cP+4F8ztrXOLKnNMnh63qs2SIk6rZ7/LiLAhtypSYBTr2PT2E7JL4WO1PjecqCLChSf6iBV59qVMrFDWO09ygeADl6N8Pdx8+mtRiom0pv6EjEPhGzKLpmQz2oXMCWgWT34CmqK/ADA7h6ivs2xABQBN10DUwqpgN790KNEmR0NyeNWcAgeeAsH52iuLyaNED+WMP8h2AjnRIaR7RFvZT40aDbChVnVy8DAQzEtY6/UuJ4GJg8KFjQn/SRbP+jkgWKG84uQj1TM4HkvuuTnEOP0FN1Rlofmu9FLZ+44ik4R85MfOvev6LllIHJdEb8yT8qYqkuT0b14B2TLarsGTe1wtLcTQIjS5w7kaDa4paVSmCnSy5Bm7UDkCV84gRuTyMxA8Vek4pK+mVMHHbiv6u1D0DJQ6e7vT80Tw39ptVUYbZWC+c7ilDkagksr1ZFP3dU3Cpf+6jKANxAjC9uVPthHhfbOISqY7K/ToECvGdi6eyGQK/Y93v3WCCIGr3I= 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 Fri, 23 Feb 2024, Vlastimil Babka wrote: > On 2/23/24 10:37, Chengming Zhou wrote: >> On 2024/2/23 17:24, Vlastimil Babka wrote: >>> >>>>> >>>> >>>> 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? > > Yes, and for that there's the "list_head slab_list", which is in union with > "struct slab *next" and "int slabs" for the cpu partial list. So if we > remove a slab from the partial list and rewrite the list_head for the > partial list purposes, it will break the lockless iterators, right? We would > have to wait a grace period between unlinking the slab from partial list (so > no new iterators can reach it), and reusing the list_head (so we are sure > the existing iterators stopped looking at our slab). We could mark the state change (list ownership) in the slab metadata and then abort the scan if the state mismatches the list. > Maybe there's more advanced rcu tricks but this is my basic understanding > how this works. This could get tricky but we already do similar things with RCU slabs objects/metadata where we allow the resuse of the object before the RCU period expires and there is an understanding that the user of those objects need to verify the type of object matching expectations when looking for objects.