Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp125770rdb; Wed, 1 Nov 2023 20:26:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IECirF4T0GuO0CSdUph5ePcwqQa98elQk+r2MX9pG+nRmg26nLu4dJMBWHd853j6jq3dnHi X-Received: by 2002:a05:6359:2e07:b0:168:cf8c:7ac8 with SMTP id ro7-20020a0563592e0700b00168cf8c7ac8mr17424151rwb.12.1698895581191; Wed, 01 Nov 2023 20:26:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698895581; cv=none; d=google.com; s=arc-20160816; b=r4RslSIVR/1RH48NSmA5iliLRDQN7j+ELGgRPAh6CmEWvQMRrLZbWR511AQbNEdSFL EvWSvcPJDofWqo+A6FdCbrvyViO+kO+3gW6vimr/5jd2yEehB8W4aaTciWgGyYjKRULq GE+fd4ulMFhwX7vndNWr4NT8NrpKUmm4VNFGq0y/fS9z4uY53eHRbDpT15aQQnOF2f3L hYTpF+jJ60M7yfT/6gTbi86b7wk6/BqX1Wr39W+r9HJ4E2dzQee4ScgNXN2VO3LMKGEm 6WZ9TKntRmt9U0pxCiM7fQ2QTgCwb7YpjK10iamDpg1Q+y0aw7lVMS61FzxqJ7fk0TUq hzGw== 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=Y0gxyVelJQEnoALRuyqBzkeEChILTc95BveKj67/aCg=; fh=Dd5ryTbz4gXtDU9jzXqg2hD87XusQgPqunF08GDmhnA=; b=PtYm1VUHl8vi2LdCN2H998MfdeUAGUmIA0m5RiQkFpk1e7xo2aljhtBRyRqRYbchJk u2oRuAaezudqsC4Vtdx1DAd84rXU6gQZPBGWhUMfwYH2BWxLt+/qa/dmNfI5qgbUl4Gh fS/BHcVIkIYBdRJmsXL7iG0zxi2OzuFsj4LSrEg/WlBnW8GXmIyrbGJyiTPSDHJ23jth 6DlZoGODfPca0/rLxopCj3OOB7CBML9WFeAWEpsfFzvD9wlHwpsapnPF9bA8ffYLbh56 sFRbMx9k3v9SD1gOZiZsjBtqz7paHJrv5gKAjTHfEVN1DZgm+7MXoTpDF0s8TXdwssl9 6YKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=lFfmSKyh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id z23-20020a631917000000b00580e32f778csi59659pgl.506.2023.11.01.20.26.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 20:26:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=lFfmSKyh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id C4446809078A; Wed, 1 Nov 2023 20:25:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348360AbjKBDZN (ORCPT + 99 others); Wed, 1 Nov 2023 23:25:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348415AbjKBDZG (ORCPT ); Wed, 1 Nov 2023 23:25:06 -0400 Received: from out-185.mta1.migadu.com (out-185.mta1.migadu.com [IPv6:2001:41d0:203:375::b9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 973D913E for ; Wed, 1 Nov 2023 20:25:00 -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=1698895498; 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=Y0gxyVelJQEnoALRuyqBzkeEChILTc95BveKj67/aCg=; b=lFfmSKyhGA3gVCpgOxB6Id7LBL0rMpEGl5gAgGZuLLsAnnTy6no1BEn+SeD5u7+7EuXT02 tiwcrE0IU15hQr17N0/O6wDqFW8ovwBIDEs0JU6KOd0J6sBKfSBYsgMLgyQ2qyobNj/QlF NFtNE/LIi0zdnMrItnwzeHEGbAdss+8= From: chengming.zhou@linux.dev To: vbabka@suse.cz, cl@linux.com, penberg@kernel.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: [PATCH v5 5/9] slub: Introduce freeze_slab() Date: Thu, 2 Nov 2023 03:23:26 +0000 Message-Id: <20231102032330.1036151-6-chengming.zhou@linux.dev> In-Reply-To: <20231102032330.1036151-1-chengming.zhou@linux.dev> References: <20231102032330.1036151-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,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 01 Nov 2023 20:25:43 -0700 (PDT) From: Chengming Zhou We will have unfrozen slabs out of the node partial list later, so we need a freeze_slab() function to freeze the partial slab and get its freelist. Signed-off-by: Chengming Zhou Reviewed-by: Vlastimil Babka Tested-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/slub.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/mm/slub.c b/mm/slub.c index 1880b483350e..edf567971679 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3098,6 +3098,33 @@ static inline void *get_freelist(struct kmem_cache *s, struct slab *slab) return freelist; } +/* + * Freeze the partial slab and return the pointer to the freelist. + */ +static inline void *freeze_slab(struct kmem_cache *s, struct slab *slab) +{ + struct slab new; + unsigned long counters; + void *freelist; + + do { + freelist = slab->freelist; + counters = slab->counters; + + new.counters = counters; + VM_BUG_ON(new.frozen); + + new.inuse = slab->objects; + new.frozen = 1; + + } while (!slab_update_freelist(s, slab, + freelist, counters, + NULL, new.counters, + "freeze_slab")); + + return freelist; +} + /* * Slow path. The lockless freelist is empty or we need to perform * debugging duties. -- 2.20.1