From patchwork Tue Oct 31 14:07:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 13441578 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 AAFBFC4167B for ; Tue, 31 Oct 2023 14:09:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B2A46B0305; Tue, 31 Oct 2023 10:09:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 43B376B0306; Tue, 31 Oct 2023 10:09:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DB8B6B0307; Tue, 31 Oct 2023 10:09:13 -0400 (EDT) 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 1A3CE6B0305 for ; Tue, 31 Oct 2023 10:09:13 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DD2FE1CAD17 for ; Tue, 31 Oct 2023 14:09:12 +0000 (UTC) X-FDA: 81405938544.21.66D6547 Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [95.215.58.171]) by imf03.hostedemail.com (Postfix) with ESMTP id F315220008 for ; Tue, 31 Oct 2023 14:09:10 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=wNIpzakv; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf03.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.171 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698761351; a=rsa-sha256; cv=none; b=ekrfja1F3HlVFtsnPW4eYECJ4ZM9icR4ubINhFsP0Y3m+6VygpPGmqufaDJzZqfLkJ+es7 bzAJcLVRCc3KzRGCkY63R0JrffVgMB6BDJ8YR0AZdEB9BaNBlwe7EVAVPNA5uoO5fWOlJ7 Q1NZra+HvOWYNhT9sICTE0CPn+tzv/g= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=wNIpzakv; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf03.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.171 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=1698761351; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=v/W13f1yvwrCHZgH+TSl+cdWReIuGoRVTB5psVe8An4=; b=q/P/Ruziz+6Ot9QebNsZ3UG3ySsiLARDBqmoS2GKiTDdIGDqFGMZxVY+M2VdhfLq+NTpG0 PYJkzqPfjCyWWjcb+94Uwqk85cvZ42YEsjy4gDLsUYcuMwqii3RGlp732vguqTz3Nq7qNz ZCdcgWU6MjA5VrXn5Cnw83JFap+7iA8= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1698761349; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v/W13f1yvwrCHZgH+TSl+cdWReIuGoRVTB5psVe8An4=; b=wNIpzakvsd93W80vtkHwQf555uZ1X7UCHSu5UZdhAwR+WInzzIHY0wg3MqdVqIXyuFrveg zfUzHrnr02/YVCm2lpOuVKjDOu31IpZFnrJaagZexEAqG5577/evBuPT6k6264Mc9xVBB2 K4yu/KTcypElGi304xzyFujmguhhPdg= From: chengming.zhou@linux.dev To: vbabka@suse.cz, cl@linux.com, penberg@kernel.org, willy@infradead.org Cc: rientjes@google.com, 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@linux.dev, Chengming Zhou Subject: [RFC PATCH v4 4/9] slub: Prepare __slab_free() for unfrozen partial slab out of node partial list Date: Tue, 31 Oct 2023 14:07:36 +0000 Message-Id: <20231031140741.79387-5-chengming.zhou@linux.dev> In-Reply-To: <20231031140741.79387-1-chengming.zhou@linux.dev> References: <20231031140741.79387-1-chengming.zhou@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: F315220008 X-Stat-Signature: edtzqmj4fcfa6ygg4fqdzfitotha9hbm X-HE-Tag: 1698761350-506226 X-HE-Meta: U2FsdGVkX19EBe4tDRw7e3jEuEMzZKLBwTBRioMqoQey4ml+BO4RWueXDbAC0c/cOgMlNAJ/qp3e+MTeJWQyafK2M/4O4xECxamlQu6SxMLV4thDF5Yml0UqZabwNzl1ecy0jslC4cJ2ikRPn/EJfiG7/BcF6RuDkoQGhdGa2Qkmat1mBbGMVauc1tvn1Rg301Er9zXR85Jk4w8QJUif03UgsiY9LobMjLeJH5ZyNqua1ElXaEDaLN+KKEbH86/TYo4N8WyiWi2BGVd2HkG/wkzkOAm6bVWFKui3rkS2E+Wl/1oW9lBhJxBSyJbddZRzDnEZb1z7NEIzFfH7bvdNsEjSmbsIs1xqcb77eM477aWY0nFZW241SJLm6p1bt1uJn5X4H/R9KBMJ90Yw0zwHhttX4Kwv07PsnnGhOASWWRSzEeDiI/yq2+MTBdeSdDfZzsnB13kbdUSJP2ubgz9Cl8WEltnNmuVd8mjnx/ua73b8Grco0/O5xnZsg7Xt4+jGlsr931Jjn/uKA1fNtMXhmTLgAOksnionUqF1tUSMt3Y1ZW5yxq/gzJtu6md6Y0eOfkKXXEVYFUB09mlm1ash78RdFikszIrgbzbCMl2xQgHENysb42sFRmoJ5pIEA5bpgz+lOjF8qoFqHTJUHPHD1xuWhJRO/22kxiPoTha5fTdLmhBTCVMnGXthUnBiccY4woei0PVyf7EiCc0Bpre0aDYwNeXyDOW5STKpQ13lLqVTk9ZQm5E3poRbra5bRHKcahjDiN4xlWxbu7QkhSDhxwtP00yVZq5u1cMQUK8YWB5ODHuDJdD12/2ebvROY3JDSxKl1FyNwIl24vET8tZ8Yl0R9GYPgcjioKL/DQPeWthq7WrZueY2qxE27RxTWnoH23ySSiV/GWyLe9zBetkjjCoKd+mTJkT90AmySBy51yGJKjFDXOgdw0wv+mlVYwJPXXPvexGNH/8YRjSlU3S tCqovKh1 DtzcWmEClg56snuaviD/96Q45pKs0NLOwiLm2/bHAcCE4eCisKJD/u4MPAzPpJ6KVht8MwwmWR8BBiSE04M4eP9MUrLn4QlXk5S0/8Hc/qaKoCPe15sCWiT6+KbyFdIxJaRiXOHJwEoTtu9p0KTHn9P6gEDAOsumQH6Uz2Vipyinrv/2dbBQ8rUrKIHib1dY54WRjfaOLSXV1oWkmShsVCprUrke5+CTakMw6hYtIQ2GCz4F20ymR20i6YQ0Y79sOqCEZ 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: From: Chengming Zhou Now the partially empty slub will be frozen when taken out of node partial list, so the __slab_free() will know from "was_frozen" that the partially empty slab is not on node partial list and is a cpu or cpu partial slab of some cpu. But we will change this, make partial slabs leave the node partial list with unfrozen state, so we need to change __slab_free() to use the new slab_test_node_partial() we just introduced. Signed-off-by: Chengming Zhou Reviewed-by: Vlastimil Babka --- mm/slub.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mm/slub.c b/mm/slub.c index eed8ae0dbaf9..1880b483350e 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3631,6 +3631,7 @@ static void __slab_free(struct kmem_cache *s, struct slab *slab, unsigned long counters; struct kmem_cache_node *n = NULL; unsigned long flags; + bool on_node_partial; stat(s, FREE_SLOWPATH); @@ -3678,6 +3679,7 @@ static void __slab_free(struct kmem_cache *s, struct slab *slab, */ spin_lock_irqsave(&n->list_lock, flags); + on_node_partial = slab_test_node_partial(slab); } } @@ -3706,6 +3708,15 @@ static void __slab_free(struct kmem_cache *s, struct slab *slab, return; } + /* + * This slab was partially empty but not on the per-node partial list, + * in which case we shouldn't manipulate its list, just return. + */ + if (prior && !on_node_partial) { + spin_unlock_irqrestore(&n->list_lock, flags); + return; + } + if (unlikely(!new.inuse && n->nr_partial >= s->min_partial)) goto slab_empty;