Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1769446rda; Tue, 24 Oct 2023 02:44:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELZshcQZrcW6hmRqeNbMQ2gZJBK22outFd/W0Mp4DJDoRPwJameCbisrvhsyeYZmp/OYVd X-Received: by 2002:a05:6358:9d85:b0:168:eaa2:a6c4 with SMTP id d5-20020a0563589d8500b00168eaa2a6c4mr3064620rwo.8.1698140666629; Tue, 24 Oct 2023 02:44:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698140666; cv=none; d=google.com; s=arc-20160816; b=YeSwzLl+VnwMP1x14c4VVMyf25JaUfMSxfSnovSddN/cAwN4pfV92jW6XiZKFhNZyA W8sw6ptAge+YtOyst+8caeJAQF+hAwY39jSaUtU2AhacM6eAFHm8jLSUN31OXjxqzRJe MUiFMc/jWdFWpQG9v/mfULOcEaEuiJ5D8b28lO1YqIMudHKC5piwSHUs8NQAdoj+JqlP rsjFEUGrAjMVfDkxbCMlvjtPxdtWrU9kybEHH6OESpmLZeROCwVzK9erymdr+EMSBxpx zvgnKDsDDGJ1dBMp859hLjezKNwJOpvLGsCehwo/A4yMWnS/R88htuYaMcD9VFmK54fd Pw2g== 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=UijxEztLRTexuc2wmlND22JYjAvU8peNSSAQw8rq2PA=; fh=pb+eBl776ZRvna1F9CtRk2Qy3fEtolZ93e7lS3CUucI=; b=sFHXuAClCkAZiSi4UjevLcy7HK9xlt9kRmTCiFwPZD/p5petI84YXC3z5v4b15jmKj 0NRTIdsFcDsmq119B5n96qCO786juUoHXBpbPa8o6in28bfC6o/9CCaT/0GLS/sSuvvS aPvHB8hMlppY847/LFd8EB6pJF36QWKs17VOaTmHQK/S6hV05QJpE7qrAB4R6OLZG/SF 94Xvb+4BHXy3yxQg8irfROfZ2ZEdFJ88iDldnXp5w/aF8LgodObk+9fkIW6K5Ru6pYA7 96uki2pwjZY/ZLI70BfJkCLjEIkVgOBtOLtS6DNsnINxWx0JZ3K/RoGZui0p8gPckd+M hIQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=gykdRjMa; 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 c16-20020a056a00249000b006beb744c460si8048885pfv.328.2023.10.24.02.44.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 02:44:26 -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=gykdRjMa; 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 788FA80C65D1; Tue, 24 Oct 2023 02:44:25 -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 S234275AbjJXJoP (ORCPT + 99 others); Tue, 24 Oct 2023 05:44:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234554AbjJXJeL (ORCPT ); Tue, 24 Oct 2023 05:34:11 -0400 Received: from out-194.mta0.migadu.com (out-194.mta0.migadu.com [91.218.175.194]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4285E10F5 for ; Tue, 24 Oct 2023 02:34:08 -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=1698140046; 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=UijxEztLRTexuc2wmlND22JYjAvU8peNSSAQw8rq2PA=; b=gykdRjMal5sST/bB2trCR8USAxy2UxFWhSeBpIeqaRzeF5OYDFVsgF9netz4vEDOO1YDYl eTbp0AKHNXuWCACBnN9eOw9UgYy91M8GYL3m9MQgwc5I0MLP0NIaEzdLHE9x29GwvY+Peq YX7cFeuPsGeiRsn56VsLqoroQhjglBc= 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 v3 5/7] slub: Introduce freeze_slab() Date: Tue, 24 Oct 2023 09:33:43 +0000 Message-Id: <20231024093345.3676493-6-chengming.zhou@linux.dev> In-Reply-To: <20231024093345.3676493-1-chengming.zhou@linux.dev> References: <20231024093345.3676493-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, 24 Oct 2023 02:44:25 -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 --- mm/slub.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/mm/slub.c b/mm/slub.c index 7d0234bffad3..5b428648021f 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3079,6 +3079,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.40.1