Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2192214pxm; Fri, 4 Mar 2022 11:04:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfZqrSZ+UB/J17DMfVAGcs4vJlINP5H0fi1ChhHiGBtsss5Dn8Id1AN9fJE3jDMcK63kA/ X-Received: by 2002:a63:6e8d:0:b0:378:a525:6ee5 with SMTP id j135-20020a636e8d000000b00378a5256ee5mr21996227pgc.9.1646420681035; Fri, 04 Mar 2022 11:04:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646420681; cv=none; d=google.com; s=arc-20160816; b=hQZsrttbKTNFw1tvUmuoM3DcA4qsoWX+dUvMfnHsj0Ur05syCxxmpCnESByamegfSk EUEsCkywXUeV+QTHgqjdMKhSr+pcY2++lext7dGf6j8TqiyKEQlXjzXt6V419ijSwKIe EPogtpBIBMW5opqG7A85kj7fwjVvNV0QW7dCrDInOypxo6/tywAQJjC3WHVdnbCjSgnO 2IWVO587/0yPwkNZWaJHMpoCZy3XkUdmyFwRw5COmCh3zWA4BTdM6gwlUzZEnobAofHY rO925Zg+fvgP//IKpY07VxOGy2LLvUcIX31sONrzigObMpiSluGDPNo0/pLFDGtoBAI7 JQxQ== 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=gJnCxkBq7SDkx56n/I8CCu4Rod5CPYjuSp+zNXS2bSA=; b=XDqSlmvfuf21qXvjeNn6/aaLqnefLW5GIzTb80mXxdPlfqDPxSzkqh6+j6/HGrYDVG KUTjC2Kc2dd+xkpxohtcAjkzAdGzpcifQJP8+vhkASN83Fd1mULIVGXOFyfELeN3ju3r pfCNzq3jD4rTA+2fitXt/tfbyrBls4X8SBQps1+nmK8NfQ2dGiZSksKVCg4sPRfjnyHL WdezO0DF3J7TC/VuL0v4bUHGUHTkXPjyVXs1yQb3KE+CuCcrDyxdsGfTkZMX9vIPrIkg UiuiEg79/ZnHIfjC90o/FBSVJd61FTcCHSPjdBTCASTTMRArhYPbtV4N49Wjv5lsKh6C ZuKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=t3fzROUo; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l185-20020a6391c2000000b0037ed37fb375si1330544pge.717.2022.03.04.11.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 11:04:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=t3fzROUo; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 26F2C1DAC7F; Fri, 4 Mar 2022 11:02:13 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234429AbiCDSeX (ORCPT + 99 others); Fri, 4 Mar 2022 13:34:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241796AbiCDSeL (ORCPT ); Fri, 4 Mar 2022 13:34:11 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18A4A15AF39 for ; Fri, 4 Mar 2022 10:33:12 -0800 (PST) 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-out1.suse.de (Postfix) with ESMTPS id AAD6B21136; Fri, 4 Mar 2022 18:33:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1646418790; 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=gJnCxkBq7SDkx56n/I8CCu4Rod5CPYjuSp+zNXS2bSA=; b=t3fzROUoQfIORgMlNQfrmE24E4i5w4V9gbKbCg0gPcmdp3VuViPQc4JNMG+bVKLDiTBB7n 9XoCWe+WZcoAhWSfiaLr9mUJNiDILJMTiuGI70n3vGmP8/9WRQgc22s2eiaby99v+9Q8pB lNEKjwVp7zaK8Ni8JfC7mm4qrnuEPMk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1646418790; 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=gJnCxkBq7SDkx56n/I8CCu4Rod5CPYjuSp+zNXS2bSA=; b=xarTsfu/8RTPI5FgQc2k8FfN4wFIS5J8JYlLKVqYVeXyhHwx2vz5Zdu77qvw2XIv1lLYZU Fvbpw/mxnngYHoDw== 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 7C7C313B70; Fri, 4 Mar 2022 18:33:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id RPkmHWZbImLdBAAAMHmgww (envelope-from ); Fri, 04 Mar 2022 18:33:10 +0000 Message-ID: Date: Fri, 4 Mar 2022 19:33:10 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v2 4/5] mm/slub: limit number of node partial slabs only in cache creation Content-Language: en-US To: Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Marco Elver , Matthew WilCox , Roman Gushchin , linux-kernel@vger.kernel.org References: <20220304063427.372145-1-42.hyeyoo@gmail.com> <20220304063427.372145-5-42.hyeyoo@gmail.com> From: Vlastimil Babka In-Reply-To: <20220304063427.372145-5-42.hyeyoo@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no 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 On 3/4/22 07:34, Hyeonggon Yoo wrote: > SLUB sets number of minimum partial slabs for node (min_partial) > using set_min_partial(). SLUB holds at least min_partial slabs even if > they're empty to avoid excessive use of page allocator. > > set_min_partial() limits value of min_partial limits value of > min_partial MIN_PARTIAL and MAX_PARTIAL. As set_min_partial() can be > called by min_partial_store() too, Only limit value of min_partial > in kmem_cache_open() so that it can be changed to value that a user wants. > > [ rientjes@google.com: Fold set_min_partial() into its callers ] > > Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Vlastimil Babka > --- > mm/slub.c | 14 +++----------- > 1 file changed, 3 insertions(+), 11 deletions(-) > > diff --git a/mm/slub.c b/mm/slub.c > index 6f0ebadd8f30..f9ae983a3dc6 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -3981,15 +3981,6 @@ static int init_kmem_cache_nodes(struct kmem_cache *s) > return 1; > } > > -static void set_min_partial(struct kmem_cache *s, unsigned long min) > -{ > - if (min < MIN_PARTIAL) > - min = MIN_PARTIAL; > - else if (min > MAX_PARTIAL) > - min = MAX_PARTIAL; > - s->min_partial = min; > -} > - > static void set_cpu_partial(struct kmem_cache *s) > { > #ifdef CONFIG_SLUB_CPU_PARTIAL > @@ -4196,7 +4187,8 @@ static int kmem_cache_open(struct kmem_cache *s, slab_flags_t flags) > * The larger the object size is, the more slabs we want on the partial > * list to avoid pounding the page allocator excessively. > */ > - set_min_partial(s, ilog2(s->size) / 2); > + s->min_partial = min_t(unsigned long, MAX_PARTIAL, ilog2(s->size) / 2); > + s->min_partial = max_t(unsigned long, MIN_PARTIAL, s->min_partial); > > set_cpu_partial(s); > > @@ -5361,7 +5353,7 @@ static ssize_t min_partial_store(struct kmem_cache *s, const char *buf, > if (err) > return err; > > - set_min_partial(s, min); > + s->min_partial = min; > return length; > } > SLAB_ATTR(min_partial);