Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1290699rdb; Wed, 20 Sep 2023 05:24:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHBiKEjIOs3KfKoU8KPTsKt7N6XEIGZVhrBVsLCGKgHtZlzOKX7LeugHCbmPq56PILLs7cP X-Received: by 2002:a05:6870:c085:b0:1bb:cb02:7b97 with SMTP id c5-20020a056870c08500b001bbcb027b97mr2526754oad.37.1695212663880; Wed, 20 Sep 2023 05:24:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695212663; cv=none; d=google.com; s=arc-20160816; b=OT4YAQErF1ePYHbYIPUJFMk1YvKA5tz1EVfUhm8KAvAfu9SvXhAzbIMeAIUXZHHR6Q /q6T2RP5Xuhcz/+s49XNEz4LrJGYYZ8Jegyki2NJh9UVgjTAdVBtnCNaTB/2qnc6kQrw dfupboKnhiEkDkdsCCuS9h3nQc1WCIzxuttLGPF1KWGJYgQhUR6evuxPFv36dGrk5t8A fkSISwqLZzlWny4eUSLbolLPQ6paTowmU8LuZGCVTNSeBrfJETVhVsDZL7L9yHZ9/msp DT9AC+gNhuAfWQXeQpe5XKDtmTVNOnt7uGNU+j6wbOPLczUJb/Z1LHqOOJBsFrF0NheU XLhQ== 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:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature; bh=kxkQ4+wBOTwkXTk8BbRT0PH/v1p4CUyHigmCVxQwZR0=; fh=Yt0UCCud3HOEwOFEom6kVqk/3lmLcWO8A7U2VT7wQTM=; b=P5tDYLhpnddZd/9Ec5XLQJkWvYBb+OKhRfj0irSSD5F9Bnp2N+/4jiVyLDDo7mh8nC XlCFsG3gMtwvsvLoIpSRtxJmNmO6nrgORf5AxGSdgadEGHI90lpQXCExA/DoJm0jkQp3 D3Oi5HIKy58w4VI8R6baghcnk53IagsjFjic4BPV5iATt7WOQmdTT2siFAUUjFhk6K3u T1DXh4EAb+va5VC25W4bCvgZ0gQtMsTUxEoRtqDAwKYVdqaT2YgurXra+k0jLLs6lYQW ORdnj2Y58sGkRkpn8vp0S1PhdcDsfj1jo5K5h5nj3DJcAWRB0wg4y/0wIJrLlxbnecuy fmuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=jSu2tOJN; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id s21-20020a63e815000000b005775a0cd009si11692619pgh.331.2023.09.20.05.24.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 05:24:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=jSu2tOJN; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 810D4803F139; Wed, 20 Sep 2023 02:26:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233999AbjITJ0X (ORCPT + 99 others); Wed, 20 Sep 2023 05:26:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233968AbjITJ0W (ORCPT ); Wed, 20 Sep 2023 05:26:22 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 836BE12E for ; Wed, 20 Sep 2023 02:25:47 -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 2673F1FE69; Wed, 20 Sep 2023 09:25:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1695201946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kxkQ4+wBOTwkXTk8BbRT0PH/v1p4CUyHigmCVxQwZR0=; b=jSu2tOJNw4XVBaM+Wbuv4u8eTxnqs0bFgJIBBkPkpAkFxrrcey8Vy6MDoHEnySk1jimpEw PJSrsmdaVdrP/w8FfgFcD0TcRLBv2h0EJg82+kXMe/opBAnPtSQmTVFu3xI31+ccOMH8UA hMzgCIqc0HSDAJuJbWEehuub8eZlLlM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1695201946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kxkQ4+wBOTwkXTk8BbRT0PH/v1p4CUyHigmCVxQwZR0=; b=5l44mGML64eFxRVyCE0NOQnoMb9XfEGpgVZ2MsA6e9i50UmBlvsAWkPG2qVFFyFO363Ujw gyqFyPdjPk9QPVBw== 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 002521333E; Wed, 20 Sep 2023 09:25:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id rAv/Opm6CmXKdAAAMHmgww (envelope-from ); Wed, 20 Sep 2023 09:25:45 +0000 Message-ID: Date: Wed, 20 Sep 2023 11:25:45 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH] mm/slub: add sanity check for slub_min/max_order cmdline setup Content-Language: en-US To: Feng Tang , Christoph Lameter , Andrew Morton , Pekka Enberg , David Rientjes , Joonsoo Kim , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20230920074413.1361547-1-feng.tang@intel.com> From: Vlastimil Babka In-Reply-To: <20230920074413.1361547-1-feng.tang@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 20 Sep 2023 02:26:26 -0700 (PDT) On 9/20/23 09:44, Feng Tang wrote: > Currently there are 2 parameters could be setup from kernel cmdline: > slub_min_order and slub_max_order. It's possible that the user > configured slub_min_order is bigger than the default slub_max_order > [1], which can still take effect, as calculate_oder() will use MAX_ORDER > as a fallback to check against, but has some downsides: > > * the kernel message about SLUB will be strange in showing min/max > orders: > > SLUB: HWalign=64, Order=9-3, MinObjects=0, CPUs=16, Nodes=1 > > * in calculate_order() called by each slab, the 2 loops of > calc_slab_order() will all be meaningless due to slub_min_order > is bigger than slub_max_order > > * prevent future code cleanup like in [2]. > > Fix it by adding some sanity check to enforce the min/max semantics. > > [1]. https://lore.kernel.org/lkml/21a0ba8b-bf05-0799-7c78-2a35f8c8d52a@os.amperecomputing.com/ > [2]. https://lore.kernel.org/lkml/20230908145302.30320-7-vbabka@suse.cz/ > Signed-off-by: Feng Tang Thanks, applied! > --- > mm/slub.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/mm/slub.c b/mm/slub.c > index f7940048138c..b36e5eb0ccb7 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -4711,6 +4711,9 @@ static int __init setup_slub_min_order(char *str) > { > get_option(&str, (int *)&slub_min_order); > > + if (slub_min_order > slub_max_order) > + slub_max_order = slub_min_order; > + > return 1; > } > > @@ -4721,6 +4724,9 @@ static int __init setup_slub_max_order(char *str) > get_option(&str, (int *)&slub_max_order); > slub_max_order = min_t(unsigned int, slub_max_order, MAX_ORDER); > > + if (slub_min_order > slub_max_order) > + slub_min_order = slub_max_order; > + > return 1; > } >