Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp270817rdb; Tue, 31 Oct 2023 07:09:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELgDBsT9xokgU52YdKxFvrucSr0hgLjSMSZg2YEj+RCJoFEaWn8qqLVJwkBWU4cSJ9aBHz X-Received: by 2002:a05:6a21:789c:b0:13a:59b1:c884 with SMTP id bf28-20020a056a21789c00b0013a59b1c884mr16719591pzc.40.1698761379333; Tue, 31 Oct 2023 07:09:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698761379; cv=none; d=google.com; s=arc-20160816; b=jIGWmokz2Grs20IY8NT18W/XZx1z9jOqaa2gnW92yrgsJ63uBta6LpLw1R2BW5YGr6 hc5kGT+iP2GT0iyp4Wl+dICZ/D7RagKkNC/qRAq2P9bcQhDRs8rhBN2GSEAi+kQRV+f/ Ohnu6Nz00R7pnEk1bAU+nGmY+DJYYBUb7BXUIwLla2LUJ8IfZHIT2kRVSgbzpFxAJdT2 q9IGCo3EwAI83+KedVx8yuaEV4x7SqDfhDVq1P2IJUbAjMLDm6+ZxZJ9HhdN1C4wWXad JsbLpXmKkG2O6itBhZqnVs4G4JR+F1HXfeyno6qLZzLufAJEdq0NhjPtjXGzlYB7F/Ot ixTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=v/W13f1yvwrCHZgH+TSl+cdWReIuGoRVTB5psVe8An4=; fh=1GJaSiew/4nhYvae+yJYXPcARWi0PNZhXd1mB5ASXRg=; b=kitofonmTNE88/SS/eQ8g6bXCiL7b3xUmw/Fz6p2qF9fs4YJoMQYwJ7MbeTo3bVLdb e2AaSfNsLoH0o/1BGTMeFZSqcuJqQ9ViNIxGLrGgRSDH+7SIUKzFeje1+CrdxwjwxY+z SWa/O9nYO3XINFzTj81NU6rdyfu3g9Dw/Raj5uSq/AQTk9IxdfjSS67RSOTSxnzVOfVP q+QhmVBxYAk72Nz7KyuyX3rbfFBa7lSPnERf6J77/58XOKRFgmwzhTaKr6qzd6EfHP3G m7aNZxG7muoVN8Qt/WRvdgkuksBPWW6qRGrDddIeoq2bcyM7iIq+kXa+MyGBXNfU4+rm Hd7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=wNIpzakv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id k35-20020a634b63000000b005b92edaa151si1092814pgl.739.2023.10.31.07.09.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 07:09:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=wNIpzakv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 6CC6E802F720; Tue, 31 Oct 2023 07:09:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233397AbjJaOJQ (ORCPT + 99 others); Tue, 31 Oct 2023 10:09:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233719AbjJaOJO (ORCPT ); Tue, 31 Oct 2023 10:09:14 -0400 Received: from out-185.mta1.migadu.com (out-185.mta1.migadu.com [95.215.58.185]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39D9D115 for ; Tue, 31 Oct 2023 07:09:11 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 31 Oct 2023 07:09:36 -0700 (PDT) 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 --- 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; -- 2.20.1