Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3248945rdg; Tue, 17 Oct 2023 08:46:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGj3PxO+NqEt4DFkI6t9GOuTWIabvyLDW8zid9Knnu+LZnqLnXpXVFxfesCDBNdGuTC8SCS X-Received: by 2002:a05:6358:9da8:b0:135:85ec:a080 with SMTP id d40-20020a0563589da800b0013585eca080mr2866160rwo.32.1697557595365; Tue, 17 Oct 2023 08:46:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697557595; cv=none; d=google.com; s=arc-20160816; b=ZuwbmkEWbtCBYtaZC332RGCnb17/bm5xQarReGuJ46qPUiQQvFj73LMZg0wPixi+Dx uol4k82SmSh+ds9996HFDZkopM1AzQdZqx8fW2KtY9XY+RIvxi2x3oxOYRjYeJf8UDXj 3dMuyW41KWsm2noCmBpfOBlMRneaLAF5qd4kOZQSdz6qskdA84g+xQtwO70bBxtgPsPH BqH8i0cUN1xNleoSr5j4dugaplp433Ho8OThTolu17Udm64D+al5DSb2DL1Lf/UJ7e0S VvTCx4KzwETEzQiZbVp+//T/wBMHf5onazpDctep+7Q49K7tKiV4iPWtFEO+oo2K9PeT Vs+g== 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=uepMlN8KtJ2YuJ4CH70+gbxhj8qnD/tT1k7NrYZtVVI=; fh=pb+eBl776ZRvna1F9CtRk2Qy3fEtolZ93e7lS3CUucI=; b=bnQtDXABQoAbPU9ZbdiSbSOfjebF/HLsGRmC0eOLD7/OgivZSU+84UOu6cW+/gTujn sgbrm6sHiincJaiECvys7wwEj7w3CIBsSitmRaAfZYK3YpEBn4oYoBChb9bbIfPE+3pW mzRUJKyKux8t6o2h/xMUsv/tSgw2+ZINeAEAt3sKHY/AqYx3x5VCZ0rdwZr3pct4Fu6z bh+XQ0cKePTVj7GEDBwXlnuyoBi2gyNy1B7hEQnKshDTlCMFbgIOOnPY/IglUJcgu49G omL4ljBE+JVlca1htM/3+A0mMecaGMQXnB1ROoeES3Ek3dOrt4j0gUQjeAFxtbDFNwbr Inhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=DaAtiZgQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id m11-20020a056a00080b00b0068fcb7125e1si1949242pfk.242.2023.10.17.08.46.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 08:46:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=DaAtiZgQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 9601B8092D9A; Tue, 17 Oct 2023 08:45:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343683AbjJQPp3 (ORCPT + 99 others); Tue, 17 Oct 2023 11:45:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235075AbjJQPp0 (ORCPT ); Tue, 17 Oct 2023 11:45:26 -0400 Received: from out-208.mta1.migadu.com (out-208.mta1.migadu.com [95.215.58.208]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D59D9FA for ; Tue, 17 Oct 2023 08:45:23 -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=1697557522; 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=uepMlN8KtJ2YuJ4CH70+gbxhj8qnD/tT1k7NrYZtVVI=; b=DaAtiZgQCtDa1rxPzHIgjJc4DIjqm3myRMfLOwX9HUwVK+3r/TPToUXQkLJLfTM7KtEz6X P6rFQUmudCXJ4U+y638uzl0+mFMh4ihgvECPrJJA2ZQUJxMrCtLFiczP96D5Kt+GJmG0g9 TeH5WidQi5s+QCvlDqd5nD8QeqE0pNc= From: chengming.zhou@linux.dev To: cl@linux.com, penberg@kernel.org Cc: rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, vbabka@suse.cz, 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 2/5] slub: Don't manipulate slab list when used by cpu Date: Tue, 17 Oct 2023 15:44:36 +0000 Message-Id: <20231017154439.3036608-3-chengming.zhou@linux.dev> In-Reply-To: <20231017154439.3036608-1-chengming.zhou@linux.dev> References: <20231017154439.3036608-1-chengming.zhou@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Tue, 17 Oct 2023 08:45:48 -0700 (PDT) From: Chengming Zhou We will change to don't freeze slab when moving it out of node partial list in the following patch, so we can't rely on the frozen bit to indicate if we should manipulate the slab list or not. This patch use the introduced on_partial() helper, which check the slab->flags that protected by node list_lock, so we can know if the slab is on the node partial list. 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 e5356ad14951..27eac93baa13 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3636,6 +3636,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); @@ -3683,6 +3684,7 @@ static void __slab_free(struct kmem_cache *s, struct slab *slab, */ spin_lock_irqsave(&n->list_lock, flags); + on_node_partial = on_partial(n, slab); } } @@ -3711,6 +3713,15 @@ static void __slab_free(struct kmem_cache *s, struct slab *slab, return; } + /* + * This slab was not on node partial list and not full either, + * in which case we shouldn't manipulate its list, early return. + */ + if (!on_node_partial && prior) { + spin_unlock_irqrestore(&n->list_lock, flags); + return; + } + if (unlikely(!new.inuse && n->nr_partial >= s->min_partial)) goto slab_empty; -- 2.40.1