Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2914200rdh; Mon, 30 Oct 2023 11:11:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2wMmaq2/qX5d8L5FiInqO0izveA27WdZ9SW16+xQ+cSOxFi+Ad/grtv/0Jtb8vZdZsY/V X-Received: by 2002:a17:90a:310:b0:280:b11:f882 with SMTP id 16-20020a17090a031000b002800b11f882mr7488910pje.1.1698689499210; Mon, 30 Oct 2023 11:11:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698689499; cv=none; d=google.com; s=arc-20160816; b=UF5FSNakxO5Bph+qoPoTccsTE5azyNZ5U56VteK32+vGHdRaZ3hZjTxEPXS2ggy5b5 jVU6JwLvMThnkGutilG0V73TfAPJMfkZplnfN1h/ssXjG3f2jIHFQJZB6uE7JcdxtOGE Ylh5nM1c28OOOCwuh7YEB9ItQAppyiPPzpn5tmfFNtCgKRea++zFljj0yTgBbgQJblUW FR3CQR6iKLbnvSQUu9KJ72pCWKgAzxzDrpODGJoIj1jekkA8hjeKL1PHLazkHV/7jUEC DSF5cuHLILp8KKDOw3pUYA1lfxmLHA/JliB8Gik5crZeHm6mbxC+IYUKwrEvgsvt1gQM Mi2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=8gKDFOEPmhqeqgEnPsJX/gtAMRMS09FFpFfsCT7nylw=; fh=1dQjqMUTvvD26NH9CfxdSSnKd3i2/7wAguBb1AyGjPU=; b=Rimh4Np6Al0DQT2MtjGozYIegNrG6lwnkz8tzcPJFDODLVCCVOR1jBgZ6wFyye4Qlk 8QCSlZDPHLevT9m/+wCfSQQFicVSjZ7aOVElvzDHnX/YSgX6eH5o7Cg7ZOT6sbDL21RO ZTEvImAZC2uYXW2XSRVsNKTf8jAyGEBHBYMAhic3xchXqxJ6RlQusOxzloGioWWIzYc5 bf3ury4zyAcXjEaxRStFRBcWCZBfpxaEKA1KqZs5eqTLkm7BCZYEINdnyNu8Ow+JdsZ5 qKY9ID/wQhNysjOw8nvM40USJiZ4k/KlME2/chxdkhR5GCYn95YJwz2cR2y6KEYyAZNw iLSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=PPa94rF6; dkim=neutral (no key) header.i=@suse.cz header.b="1/23uOzt"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id ay1-20020a17090b030100b00258996c09e4si2911983pjb.22.2023.10.30.11.11.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 11:11:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=PPa94rF6; dkim=neutral (no key) header.i=@suse.cz header.b="1/23uOzt"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 886BB802C8D4; Mon, 30 Oct 2023 11:11:30 -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 S233034AbjJ3SLM (ORCPT + 99 others); Mon, 30 Oct 2023 14:11:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229952AbjJ3SLL (ORCPT ); Mon, 30 Oct 2023 14:11:11 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA37CC0 for ; Mon, 30 Oct 2023 11:11:04 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 713D41F38C; Mon, 30 Oct 2023 18:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1698689463; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8gKDFOEPmhqeqgEnPsJX/gtAMRMS09FFpFfsCT7nylw=; b=PPa94rF6SmntBiDNKBoLhVuSW02pU+ugAPhNI0SSzoz/akaOf6kPGuS5UhxYuavBqT/jqb gbqfXsbQClZbed5V0YjeAoKZsisK3Hpn7hDbCULivUtzrGE3e1NJE2JlBHXyCtPr9cIyOg sd1A5LPcEMM7acMrJi7PX4nYIdKOj2s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1698689463; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8gKDFOEPmhqeqgEnPsJX/gtAMRMS09FFpFfsCT7nylw=; b=1/23uOztM2hXq3WV635Bl+sEZlxQEbb01b6Kr47P21pm/8MiQru2RBDzL3OdDwbXtm2t5J l1I2riomtpEJygBA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4570E138EF; Mon, 30 Oct 2023 18:11:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id zrNOELfxP2WHRgAAMHmgww (envelope-from ); Mon, 30 Oct 2023 18:11:03 +0000 Message-ID: Date: Mon, 30 Oct 2023 19:11:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [RFC PATCH v3 5/7] slub: Introduce freeze_slab() Content-Language: en-US To: chengming.zhou@linux.dev, 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 References: <20231024093345.3676493-1-chengming.zhou@linux.dev> <20231024093345.3676493-6-chengming.zhou@linux.dev> From: Vlastimil Babka In-Reply-To: <20231024093345.3676493-6-chengming.zhou@linux.dev> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL 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]); Mon, 30 Oct 2023 11:11:30 -0700 (PDT) On 10/24/23 11:33, chengming.zhou@linux.dev wrote: > 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 As you noted, we'll need slab_update_freelist(). Otherwise, Reviewed-by: Vlastimil Babka > --- > 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.