Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp270901rdb; Tue, 31 Oct 2023 07:09:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJWqJSUoXEZvzYx6n8vfYOXQgIR9gKtCi9db6rFrlj2qt3sRtl31SbRGOOX38xfLsCM7jM X-Received: by 2002:a05:6a21:3d83:b0:17f:cf8e:241e with SMTP id bj3-20020a056a213d8300b0017fcf8e241emr8486688pzc.41.1698761386502; Tue, 31 Oct 2023 07:09:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698761386; cv=none; d=google.com; s=arc-20160816; b=aPKwvEDZqVbtF/7MoQOd/4zfA2SZWnOsNJ7RYv8u8C2+DvamoVbGtekuYaokbGHpGy vvD2TiugcjV2R54dL4xZIhTRO6SfmyMI+FiMfsWJ+YOeNpBI1HDwhrD+WZfsE3CIZ/A7 O4ysRtRlkDztEDRxdEHg7xzyNidYO/6LV6mDXLI/oja9k9c9+n/PVb17a0g4YoV/5yiv +VK52pdoPnUZkQxn1askaypOe+xkNmV26dCbmxvrKCMZGJ/2qYkCnlO34iw16ycUabNy jnkxVow8+L6Yhn047fYLDCnf7UPEBvyKQ41y6+TkoBJHdTQcIuEr3Z03O30HRpVmbCRP xR3w== 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=DSV2hJzhN1EMBaKNKe5GTqHBigf8Oik9SH9kDO4tfhs=; fh=1GJaSiew/4nhYvae+yJYXPcARWi0PNZhXd1mB5ASXRg=; b=FZeY0HTE90m2lkqMam/r/+8byAUYwjziHvmmo4nwsM82QsjsbZOCLFWKdJtQdj6PPC IB2SgpGu+/7377iNzsBtKrhzfBImoofWftvqHDyrNT0PgQijYvG0t/fgDFdvGBU1cGrB YQTRT4HiRbStJ7NZSsMWvlcaHQliBAjVsJaVa5pY4EkWxJdZD0FidPrKdL9BaSqTs77B fTz9k8wqhp2IXt7qVDcfQDeOc+rsU7o3ShyQjRgsmUW6Ay5yme+NA0DFOXhlz/UYtblh h2uyiDoZxycvcFaB5sorIVeTUClTUwUEA5tKTLItkeAZCJPDjgkQzI4FFcamp66S99CO JQrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=WHMjfXAw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id u14-20020a62790e000000b006b7e321c0aesi1041448pfc.40.2023.10.31.07.09.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 07:09:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=WHMjfXAw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 31FC58021318; Tue, 31 Oct 2023 07:09:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229889AbjJaOJY (ORCPT + 99 others); Tue, 31 Oct 2023 10:09:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233536AbjJaOJQ (ORCPT ); Tue, 31 Oct 2023 10:09:16 -0400 Received: from out-182.mta1.migadu.com (out-182.mta1.migadu.com [95.215.58.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14BA0125 for ; Tue, 31 Oct 2023 07:09:13 -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=1698761352; 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=DSV2hJzhN1EMBaKNKe5GTqHBigf8Oik9SH9kDO4tfhs=; b=WHMjfXAw75r95lcc5nFUiMN89Tof/YlZMyVPqZKNOdvO1yteE6uHCrbGBMOqY7xCBTII+D bv4O0JIZHkzqYTy9jSpAEEAubWuuo1+LX71TrqtSTlbNRuljW0aerBJZZx3KeiAGfHntFE 9WQV2XL6SGskdWaTT/AwR5nu7UHQO8I= 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 5/9] slub: Introduce freeze_slab() Date: Tue, 31 Oct 2023 14:07:37 +0000 Message-Id: <20231031140741.79387-6-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 fry.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 (fry.vger.email [0.0.0.0]); Tue, 31 Oct 2023 07:09: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 --- 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