From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 201EACE79AD for ; Wed, 20 Sep 2023 06:38:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F39A6B011F; Wed, 20 Sep 2023 02:38:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A3886B0120; Wed, 20 Sep 2023 02:38:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76AD46B0121; Wed, 20 Sep 2023 02:38:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 66C346B011F for ; Wed, 20 Sep 2023 02:38:10 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 35B47A111A for ; Wed, 20 Sep 2023 06:38:10 +0000 (UTC) X-FDA: 81256021140.29.BEE1952 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf04.hostedemail.com (Postfix) with ESMTP id 0B5324000A for ; Wed, 20 Sep 2023 06:38:07 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=mO+y89IK; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=AGZq26ZM; spf=pass (imf04.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695191888; h=from:from:sender:reply-to:subject:subject: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:dkim-signature; bh=YezYBQ1zDqyBKiujkdR1sa0QaGIAFcnQoX6o2DR4Zfk=; b=fJlXdPtwQgTJK/ejv9S/yFvGxluYifaAsuHYHAK3wGQZguXECuk3fqAQNFyGwEQk5VJjgZ +njssNqFcamuL9RYHys1LR2Kluc6J0K9Ax/rcK/seiFFLq8ZQc0SBbl5UT9gXzq4QQQbv1 Gf41Hafvk4L7sa/5cedNjzpdRLxJvSk= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=mO+y89IK; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=AGZq26ZM; spf=pass (imf04.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695191888; a=rsa-sha256; cv=none; b=ktk6ntDxCrcj14cVWBdC7+7716ve1lIqq1UGNAvjDcvh4mWlSpYnPyNJOuxdphArd+dGQV u2VRvlq5fbOWJgnl56v1ojM1bcS6Bz1xyPFTY/9Rz+4+7fBdy3sgPXYQeC6PV3CpOZyoV2 qoQZLAtFXzLy3/f1oHelIu0+nn0Kn5I= 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 069761F45B; Wed, 20 Sep 2023 06:38:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1695191886; 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=YezYBQ1zDqyBKiujkdR1sa0QaGIAFcnQoX6o2DR4Zfk=; b=mO+y89IKVJp2Ve0tZI8BE8fc6PzPRMHzP43J3bNj6Tk6byaIS6a8MVAmTIBxIKdxRSUHK7 E3Ci/ykK7jqJ8PTuvJ+z6p5f/caPXhAfiPbGkEHbxnPJ3B9Oq+mXkZxXuOhcLUPGJhxffw 8Vvn4chmVeDeDQX3XQcrSXk2ZdHI/pw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1695191886; 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=YezYBQ1zDqyBKiujkdR1sa0QaGIAFcnQoX6o2DR4Zfk=; b=AGZq26ZMKrknwaS6Ii6+YpktlkH8CeK0QOrcOM8u+OzfH5syy9HPPboVgsXbdua07sGepI yjAmZ3vi4jWX+qDA== 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 CBB331333E; Wed, 20 Sep 2023 06:38:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 1o0BMU2TCmUWGQAAMHmgww (envelope-from ); Wed, 20 Sep 2023 06:38:05 +0000 Message-ID: <9f0ac6a5-7b13-7ce0-ead3-03746a31040e@suse.cz> Date: Wed, 20 Sep 2023 08:38:05 +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 1/4] mm/slub: simplify the last resort slab order calculation Content-Language: en-US To: Feng Tang Cc: David Rientjes , Christoph Lameter , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Jay Patel , Roman Gushchin , Pekka Enberg , Joonsoo Kim , "linux-mm@kvack.org" , "patches@lists.linux.dev" , "linux-kernel@vger.kernel.org" References: <20230908145302.30320-6-vbabka@suse.cz> <20230908145302.30320-7-vbabka@suse.cz> From: Vlastimil Babka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 0B5324000A X-Rspam-User: X-Stat-Signature: yiwqegu35iaketxffaa4rsjggy3cmjih X-Rspamd-Server: rspam01 X-HE-Tag: 1695191887-129994 X-HE-Meta: U2FsdGVkX1+lUbrtBzdKh1NA6C6LtMJ/4m3G722jwhL/A8D+qIEMCWZZPtIjslVH8uYuV53XjBiwcQogsr8/s0vHIgdNx/fTKdgAzmXwe2+3LTX/HvRKeWivVC4zv+VZyMwWrP55oleLn9qqRkZXnL9Hjuqm0VcvtmgfphyZBb2mzuiyuWFXaa0tA2YmkEWKBTrBcNOxM1cGGDp7BKAKYbjWg0YyvQ9XYLDoDe+KNV4dJU5gB/VcfaXcOboU/61D6qcT5Namg7y9stGWKgMEQJFIB7fyl2gem79pooA5hHGYRKQSkEL1FcUhcJr9Chc39iADvX5z44ontgRsYXWCrEGj8i+ev4ahFzkNc/TvcuFnt5ApyvAjPAW/icTs6zmjWPuoZEAuupy5FOIuOzZqGo4Lig6UdP67puM/bFlKVB03W1iu0mHdsDkp0IbESvt/5kQ6JulwWR4cpne5v/8+CcIHnixaMMuP/SYWl3LYtgmRgohjlbE5KsYcijobXC84FX0g84drvfl8patzhL8Wf/Rzp1Vokbjv1u+SyaphEPs+DeMT5Ln5wBb4NeOEybmKhErzFnS9PKtxmhBtvhFF05K82NKtMDTrXYbqOwm5Qyv68ySa1m36iGCy9cUTjn4AV58v/h0Rae6T3oBwTfHuHY8t86QyablWS8jiNSxArUV/JPwRl9Jv8xSohl5VnLw8XFjptBN95ft1UCZWugFd1wsJtloRK+nzpL5cqu1Vek2AMSkSB5ot+nGWRVOCihQScQykQod0k/yHH1+Gk7Oymz+zM/oImV9Y5yGzaVQ9UVXVg06EGol8gsRGRYce8daJglQslxpUtMSazyp6+XjBpeh+a1xilINMWl278GRm6vLoSQwE7nK9zSQuzy4ehLSfUeU6gnTWRIalgk/Liu2dPcjQxfl8CVbAFJ6ZMiljrENsDm2XK5JRy9Jvj+gm4s7hzZm89gcdM3BKQu74kVi z7erCiW6 YbrQ9jIVOnbfkaNram4yi9sGj1gsj0ytVikCEQwr6MHreUv++8sbXINugt9H1GFD8hEaHlUt2mKyP5XkvHzqAv1bsQCkVBUvZQepH/e+NA3My+0wxgma+l/8V41rfipuoYhfgOPblBLd8pL2Ouzl/UCcHplDo3X7LlfVkQ7lzkmk/kqgDKjkFByQGJ2HWfOPNKG4asINPlCszi1ru8aYSJGQtcya0u1/GL6W4cyjCq/mEgpux4MHHFsbal7GTRRZV9cignl0aeVt4DsX+xObDsgpkOIvWiZHaP3qZgA/zgjy5Y1LRDCH354r/SpPK58aCg4hMvrtHRm6FVwW/oMLKivLGOM4WZm7DH+SagiLdmRDRCnI8BKqAkaVfsQOL80ILHVKN4kej9sk8ivP74ES4vJN3lTSyyx9sIQK2GVFvMGkskMM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 9/19/23 09:56, Feng Tang wrote: > Hi Vlastimil, > > On Fri, Sep 08, 2023 at 10:53:04PM +0800, Vlastimil Babka wrote: >> If calculate_order() can't fit even a single large object within >> slub_max_order, it will try using the smallest necessary order that may >> exceed slub_max_order but not MAX_ORDER. >> >> Currently this is done with a call to calc_slab_order() which is >> unecessary. We can simply use get_order(size). No functional change. >> >> Signed-off-by: Vlastimil Babka >> --- >> mm/slub.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/mm/slub.c b/mm/slub.c >> index f7940048138c..c6e694cb17b9 100644 >> --- a/mm/slub.c >> +++ b/mm/slub.c >> @@ -4193,7 +4193,7 @@ static inline int calculate_order(unsigned int size) >> /* >> * Doh this slab cannot be placed using slub_max_order. >> */ >> - order = calc_slab_order(size, 1, MAX_ORDER, 1); >> + order = get_order(size); > > > This patchset is a nice cleanup, and my previous test all looked fine. > And one 'slub_min_order' setup reminded by Christopher [1] doesn't > work as not taking affect with this 1/4 patch. Hmm I see. Well the trick should keep working if you pass both slab_min_order=9 slab_max_order=9 ? Maybe Christopher actually does that, but didn't type it fully in the mail. > The root cause seems to be, in current kernel, the 'slub_max_order' > is not ajusted accordingly with 'slub_min_order', so there is case > that 'slub_min_order' is bigger than the default 'slub_max_order' (3). > > And it could be fixed by the below patch > > diff --git a/mm/slub.c b/mm/slub.c > index 1c91f72c7239..dbe950783105 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -4702,6 +4702,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; > } Sounds like a good idea. Would also do analogous thing in setup_slub_max_order. > Though the formal fix may also need to cover case like this kind of > crazy setting "slub_min_order=6 slub_max_order=5" Doing both should cover even this, and AFAICS how param processing works the last one passed would "win" so it would set min=max=5 in that case. That's probably the most sane way we can handle such scenarios. Want to set a full patch or should I finalize it? I would put it as a new 1/5 before the rest. Thanks! > [1]. https://lore.kernel.org/lkml/21a0ba8b-bf05-0799-7c78-2a35f8c8d52a@os.amperecomputing.com/ > > Thanks, > Feng > >> if (order <= MAX_ORDER) >> return order; >> return -ENOSYS; >> -- >> 2.42.0 >> >>