Message ID | 20221121171202.22080-1-vbabka@suse.cz |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1716804wrr; Mon, 21 Nov 2022 09:12:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf6+xL9cU+cswh16q/OzPiVFLyODoXGMEoopqHBci6hwI9CVVR//diuiiPpvp4VVwrDbOoNv X-Received: by 2002:a62:6205:0:b0:56c:14a5:2245 with SMTP id w5-20020a626205000000b0056c14a52245mr2495692pfb.12.1669050778590; Mon, 21 Nov 2022 09:12:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669050778; cv=none; d=google.com; s=arc-20160816; b=bQPAPO1TnIwet+zNM1fPjVrQtFn1dqLTvktMrZnykVBucbwMLotPPEB+u1d23nVddn TpmwCWBQiRaZAY/kH4/09nTOnFIEKe2kcpS9rnDNYFZbY6pd3SIoGx7b0MRlj89Sj674 rt6vSXizvEQkLnMc9FbfYcfaf0o27KdyrhK9PJ330cqaFJvEXY02SJDfV9sY59Z0UFKu Kk9VV7UacVZr4EeYmKgICOmA9XudbV/1hhKzAdTIH2svHPmyg6/G4IAZXi3bBa0yuf2X g6Soy1Ygp8t5n+PZvB7CfeBQYl8BtHfHDbNUpqtHhrnAGDf4yQ26pOa1GYQGuTGBAdgj FDFg== 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 :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=DZnidYhlob4wYa4haMFdTT34ayZpbbmwklQkgFc8Awk=; b=hfltwlDK9Ogs0P5Idw+eYRuHPzjUEs5dRsXAnhwyTOCw9cIP9OXe1u9MwEBD68LCko j2XUXtkPt6ckbHsFkg9Ob/wEu0fQOGNzOl49nIXqaaPzwzJFcjDQI86T5X7HVADjsOIJ YP+FH+moP1+ugl+CuGISIh/CQw8pxlD2C1xgH2fmzCtMPr48VUA6XEpbFN1qg0CSyO/O iAVc/1Z7SXqO7P/1uiUQLUuAQRpIfmlBGbl5DTRhTfnBXzoXfGol4miCzzboHS9qLy2F A+byBeOOVIs1mHDHe/sYbrDeniWKP7l9ykEKSwkkok4X/yzWyc+2QwClpRbKOtwt62k1 0Pmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=igSelbSq; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=9DPAJO6v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oo6-20020a17090b1c8600b0021406fde039si12281387pjb.156.2022.11.21.09.12.40; Mon, 21 Nov 2022 09:12:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=igSelbSq; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=9DPAJO6v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230521AbiKURMZ (ORCPT <rfc822;cjcooper78@gmail.com> + 99 others); Mon, 21 Nov 2022 12:12:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230440AbiKURMP (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 21 Nov 2022 12:12:15 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 832DACB9FF; Mon, 21 Nov 2022 09:12: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 7BA8521ED7; Mon, 21 Nov 2022 17:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1669050730; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=DZnidYhlob4wYa4haMFdTT34ayZpbbmwklQkgFc8Awk=; b=igSelbSqFd3w5BzmX0A298SdSKeA17HOh2pkXAxBvORbNrOVcERZdte79/CIP7kyZ9OEQc qGTUwmDBZupXek/Pmhfp3udI5D94Oj0RJVsjFfgjZC+pWWslxUZg2BB5qo/PzH90NPa33a kz5FoQyCzMhgnlT8dzZH2qs2wVTkhV8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1669050730; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=DZnidYhlob4wYa4haMFdTT34ayZpbbmwklQkgFc8Awk=; b=9DPAJO6vdbpnXuxOCWq1ear04Z0+sgJIIyVq6GX4W7oxMG//ydLJqKKD/AnzraAic+kNFl ixgzkrl3OEeOHpBw== 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 12F081377F; Mon, 21 Nov 2022 17:12:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uQP0A2qxe2MQeQAAMHmgww (envelope-from <vbabka@suse.cz>); Mon, 21 Nov 2022 17:12:10 +0000 From: Vlastimil Babka <vbabka@suse.cz> To: Christoph Lameter <cl@linux.com>, David Rientjes <rientjes@google.com>, Joonsoo Kim <iamjoonsoo.kim@lge.com>, Pekka Enberg <penberg@kernel.org> Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, Roman Gushchin <roman.gushchin@linux.dev>, Andrew Morton <akpm@linux-foundation.org>, Linus Torvalds <torvalds@linux-foundation.org>, Matthew Wilcox <willy@infradead.org>, patches@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Vlastimil Babka <vbabka@suse.cz>, Aaro Koskinen <aaro.koskinen@iki.fi>, Arnd Bergmann <arnd@arndb.de>, Christophe Leroy <christophe.leroy@csgroup.eu>, Conor Dooley <conor@kernel.org>, Damien Le Moal <damien.lemoal@opensource.wdc.com>, Geert Uytterhoeven <geert@linux-m68k.org>, Janusz Krzysztofik <jmkrzyszt@gmail.com>, Jonas Bonn <jonas@southpole.se>, Josh Triplett <josh@joshtriplett.org>, Kees Cook <keescook@chromium.org>, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, openrisc@lists.librecores.org, Rich Felker <dalias@libc.org>, Russell King <linux@armlinux.org.uk>, Stafford Horne <shorne@gmail.com>, Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>, Tony Lindgren <tony@atomide.com>, Yoshinori Sato <ysato@users.sourceforge.jp> Subject: [PATCH 00/12] Introduce CONFIG_SLUB_TINY and deprecate SLOB Date: Mon, 21 Nov 2022 18:11:50 +0100 Message-Id: <20221121171202.22080-1-vbabka@suse.cz> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750126589137050716?= X-GMAIL-MSGID: =?utf-8?q?1750126589137050716?= |
Series |
Introduce CONFIG_SLUB_TINY and deprecate SLOB
|
|
Message
Vlastimil Babka
Nov. 21, 2022, 5:11 p.m. UTC
Hi, this continues the discussion from [1]. Reasons to remove SLOB are outlined there and no-one has objected so far. The last patch of this series therefore deprecates CONFIG_SLOB and updates all the defconfigs using CONFIG_SLOB=y in the tree. There is a k210 board with 8MB RAM where switching to SLUB caused issues [2] and the lkp bot wasn't also happy about code bloat [3]. To address both, this series introduces CONFIG_SLUB_TINY to perform some rather low-hanging fruit modifications to SLUB to reduce its memory overhead. This seems to have been successful at least in the k210 case [4]. I consider this as an acceptable tradeoff for getting rid of SLOB. The series is also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/vbabka/linux.git/log/?h=slub-tiny-v1r2 [1] https://lore.kernel.org/all/b35c3f82-f67b-2103-7d82-7a7ba7521439@suse.cz/ [2] https://lore.kernel.org/all/a5bba3ca-da19-293c-c01b-a28291533466@opensource.wdc.com/ [3] https://lore.kernel.org/all/Y25E9cJbhDAKi1vd@99bb1221be19/ [4] https://lore.kernel.org/all/6a1883c4-4c3f-545a-90e8-2cd805bcf4ae@opensource.wdc.com/ Vlastimil Babka (12): mm, slab: ignore hardened usercopy parameters when disabled mm, slub: add CONFIG_SLUB_TINY mm, slub: disable SYSFS support with CONFIG_SLUB_TINY mm, slub: retain no free slabs on partial list with CONFIG_SLUB_TINY mm, slub: lower the default slub_max_order with CONFIG_SLUB_TINY mm, slub: don't create kmalloc-rcl caches with CONFIG_SLUB_TINY mm, slab: ignore SLAB_RECLAIM_ACCOUNT with CONFIG_SLUB_TINY mm, slub: refactor free debug processing mm, slub: split out allocations from pre/post hooks mm, slub: remove percpu slabs with CONFIG_SLUB_TINY mm, slub: don't aggressively inline with CONFIG_SLUB_TINY mm, slob: rename CONFIG_SLOB to CONFIG_SLOB_DEPRECATED arch/arm/configs/clps711x_defconfig | 3 +- arch/arm/configs/collie_defconfig | 3 +- arch/arm/configs/multi_v4t_defconfig | 3 +- arch/arm/configs/omap1_defconfig | 3 +- arch/arm/configs/pxa_defconfig | 3 +- arch/arm/configs/tct_hammer_defconfig | 3 +- arch/arm/configs/xcep_defconfig | 3 +- arch/openrisc/configs/or1ksim_defconfig | 3 +- arch/openrisc/configs/simple_smp_defconfig | 3 +- arch/riscv/configs/nommu_k210_defconfig | 3 +- .../riscv/configs/nommu_k210_sdcard_defconfig | 3 +- arch/riscv/configs/nommu_virt_defconfig | 3 +- arch/sh/configs/rsk7201_defconfig | 3 +- arch/sh/configs/rsk7203_defconfig | 3 +- arch/sh/configs/se7206_defconfig | 3 +- arch/sh/configs/shmin_defconfig | 3 +- arch/sh/configs/shx3_defconfig | 3 +- include/linux/slab.h | 8 + include/linux/slub_def.h | 6 +- kernel/configs/tiny.config | 5 +- mm/Kconfig | 38 +- mm/Kconfig.debug | 2 +- mm/slab_common.c | 16 +- mm/slub.c | 415 ++++++++++++------ 24 files changed, 377 insertions(+), 164 deletions(-)
Comments
On Mon, Nov 21, 2022, at 18:11, Vlastimil Babka wrote: > > this continues the discussion from [1]. Reasons to remove SLOB are > outlined there and no-one has objected so far. The last patch of this > series therefore deprecates CONFIG_SLOB and updates all the defconfigs > using CONFIG_SLOB=y in the tree. > > There is a k210 board with 8MB RAM where switching to SLUB caused issues > [2] and the lkp bot wasn't also happy about code bloat [3]. To address > both, this series introduces CONFIG_SLUB_TINY to perform some rather > low-hanging fruit modifications to SLUB to reduce its memory overhead. > This seems to have been successful at least in the k210 case [4]. I > consider this as an acceptable tradeoff for getting rid of SLOB. I agree that this is a great success for replacing SLOB on the smallest machines that have 32MB or less and have to run a a highly customized kernel, and this is probably enough to have a drop-in replacement without making any currently working system worse. On the other hand, I have the feeling that we may want something a bit less aggressive than this for machines that are slightly less constrained, in particular when a single kernel needs to scale from 64MB to 512MB, which can happen e.g. on OpenWRT. I have seen a number of reports over the years that suggest that new kernels handle fragmentation and low memory worse than old ones, and it would be great to improve that again. I can imagine those machines wanting to use sysfs in general but not for the slab caches, so having a separate knob to configure out the sysfs stuff could be useful without having to go all the way to SLUB_TINY. For the options that trade off performance against lower fragmentation (MIN/MAX_PARTIAL, KMALLOC_RECLAIM, percpu slabs), I wonder if it's possible to have a boot time default based on the amount of RAM per CPU to have a better tuned system on most cases, rather than having to go to one extreme or the other at compile time. Arnd https://openwrt.org/toh/views/toh_standard_all?datasrt=target&dataflt%5B0%5D=availability_%3DAvailable%202021
On 11/22/22 17:33, Arnd Bergmann wrote: > On Mon, Nov 21, 2022, at 18:11, Vlastimil Babka wrote: >> >> this continues the discussion from [1]. Reasons to remove SLOB are >> outlined there and no-one has objected so far. The last patch of this >> series therefore deprecates CONFIG_SLOB and updates all the defconfigs >> using CONFIG_SLOB=y in the tree. >> >> There is a k210 board with 8MB RAM where switching to SLUB caused issues >> [2] and the lkp bot wasn't also happy about code bloat [3]. To address >> both, this series introduces CONFIG_SLUB_TINY to perform some rather >> low-hanging fruit modifications to SLUB to reduce its memory overhead. >> This seems to have been successful at least in the k210 case [4]. I >> consider this as an acceptable tradeoff for getting rid of SLOB. > > I agree that this is a great success for replacing SLOB on the > smallest machines that have 32MB or less and have to run a > a highly customized kernel, and this is probably enough to > have a drop-in replacement without making any currently working > system worse. > > On the other hand, I have the feeling that we may want something > a bit less aggressive than this for machines that are slightly > less constrained, in particular when a single kernel needs to > scale from 64MB to 512MB, which can happen e.g. on OpenWRT. > I have seen a number of reports over the years that suggest > that new kernels handle fragmentation and low memory worse than > old ones, and it would be great to improve that again. I see. That would need to study such reports and see if the problem there is actually SLUB, or the page allocator or something else entirely. > I can imagine those machines wanting to use sysfs in general > but not for the slab caches, so having a separate knob to > configure out the sysfs stuff could be useful without having > to go all the way to SLUB_TINY. Right, but AFAIK that wouldn't save much except some text size and kobjects, so probably negligible for >32MB? > For the options that trade off performance against lower > fragmentation (MIN/MAX_PARTIAL, KMALLOC_RECLAIM, percpu > slabs), I wonder if it's possible to have a boot time > default based on the amount of RAM per CPU to have a better > tuned system on most cases, rather than having to go > to one extreme or the other at compile time. Possible for some of these things, but for others that brings us back to the question what are the actual observed issues. If it's low memory in absolute number of pages, these can help, but if it's fragmentation (and the kind if RAM sizes should have page grouping by mobility enabled), ditching e.g. the KMALLOC_RECLAIM could make it worse. Unfortunately some of these tradeoffs can be rather unpredictable. Thanks, Vlastimil > Arnd > > https://openwrt.org/toh/views/toh_standard_all?datasrt=target&dataflt%5B0%5D=availability_%3DAvailable%202021
On Tue, Nov 22, 2022, at 17:59, Vlastimil Babka wrote: > On 11/22/22 17:33, Arnd Bergmann wrote: >> On Mon, Nov 21, 2022, at 18:11, Vlastimil Babka wrote: >> I can imagine those machines wanting to use sysfs in general >> but not for the slab caches, so having a separate knob to >> configure out the sysfs stuff could be useful without having >> to go all the way to SLUB_TINY. > > Right, but AFAIK that wouldn't save much except some text size and kobjects, > so probably negligible for >32MB? Makes sense, I assume you have a better idea of how much this could save. I'm not at all worried about the .text size, but my initial guess was that the metadata for sysfs would be noticeable. >> For the options that trade off performance against lower >> fragmentation (MIN/MAX_PARTIAL, KMALLOC_RECLAIM, percpu >> slabs), I wonder if it's possible to have a boot time >> default based on the amount of RAM per CPU to have a better >> tuned system on most cases, rather than having to go >> to one extreme or the other at compile time. > > Possible for some of these things, but for others that brings us back to the > question what are the actual observed issues. If it's low memory in absolute > number of pages, these can help, but if it's fragmentation (and the kind if > RAM sizes should have page grouping by mobility enabled), ditching e.g. the > KMALLOC_RECLAIM could make it worse. Unfortunately some of these tradeoffs > can be rather unpredictable. Are there any obvious wins on memory uage? I would guess that it would be safe to e.g. ditch percpu slabs when running with less 128MB per CPU, and the MIN/MAX_PARTIAL values could easily be a function of the number of pages in total or per cpu, whichever makes most sense. As a side-effect, those could also grow slightly larger on huge systems by scaling them with log2(totalpages). Arnd
On Mon, Nov 21, 2022 at 06:11:50PM +0100, Vlastimil Babka wrote: > Hi, > > this continues the discussion from [1]. Reasons to remove SLOB are > outlined there and no-one has objected so far. The last patch of this > series therefore deprecates CONFIG_SLOB and updates all the defconfigs > using CONFIG_SLOB=y in the tree. > > There is a k210 board with 8MB RAM where switching to SLUB caused issues > [2] and the lkp bot wasn't also happy about code bloat [3]. To address > both, this series introduces CONFIG_SLUB_TINY to perform some rather > low-hanging fruit modifications to SLUB to reduce its memory overhead. > This seems to have been successful at least in the k210 case [4]. I > consider this as an acceptable tradeoff for getting rid of SLOB. > > The series is also available in git: > https://git.kernel.org/pub/scm/linux/kernel/git/vbabka/linux.git/log/?h=slub-tiny-v1r2 > > [1] https://lore.kernel.org/all/b35c3f82-f67b-2103-7d82-7a7ba7521439@suse.cz/ > [2] https://lore.kernel.org/all/a5bba3ca-da19-293c-c01b-a28291533466@opensource.wdc.com/ > [3] https://lore.kernel.org/all/Y25E9cJbhDAKi1vd@99bb1221be19/ > [4] https://lore.kernel.org/all/6a1883c4-4c3f-545a-90e8-2cd805bcf4ae@opensource.wdc.com/ > > Vlastimil Babka (12): > mm, slab: ignore hardened usercopy parameters when disabled > mm, slub: add CONFIG_SLUB_TINY > mm, slub: disable SYSFS support with CONFIG_SLUB_TINY > mm, slub: retain no free slabs on partial list with CONFIG_SLUB_TINY > mm, slub: lower the default slub_max_order with CONFIG_SLUB_TINY > mm, slub: don't create kmalloc-rcl caches with CONFIG_SLUB_TINY > mm, slab: ignore SLAB_RECLAIM_ACCOUNT with CONFIG_SLUB_TINY > mm, slub: refactor free debug processing > mm, slub: split out allocations from pre/post hooks > mm, slub: remove percpu slabs with CONFIG_SLUB_TINY > mm, slub: don't aggressively inline with CONFIG_SLUB_TINY > mm, slob: rename CONFIG_SLOB to CONFIG_SLOB_DEPRECATED > > arch/arm/configs/clps711x_defconfig | 3 +- > arch/arm/configs/collie_defconfig | 3 +- > arch/arm/configs/multi_v4t_defconfig | 3 +- > arch/arm/configs/omap1_defconfig | 3 +- > arch/arm/configs/pxa_defconfig | 3 +- > arch/arm/configs/tct_hammer_defconfig | 3 +- > arch/arm/configs/xcep_defconfig | 3 +- > arch/openrisc/configs/or1ksim_defconfig | 3 +- > arch/openrisc/configs/simple_smp_defconfig | 3 +- > arch/riscv/configs/nommu_k210_defconfig | 3 +- > .../riscv/configs/nommu_k210_sdcard_defconfig | 3 +- > arch/riscv/configs/nommu_virt_defconfig | 3 +- > arch/sh/configs/rsk7201_defconfig | 3 +- > arch/sh/configs/rsk7203_defconfig | 3 +- > arch/sh/configs/se7206_defconfig | 3 +- > arch/sh/configs/shmin_defconfig | 3 +- > arch/sh/configs/shx3_defconfig | 3 +- > include/linux/slab.h | 8 + > include/linux/slub_def.h | 6 +- > kernel/configs/tiny.config | 5 +- > mm/Kconfig | 38 +- > mm/Kconfig.debug | 2 +- > mm/slab_common.c | 16 +- > mm/slub.c | 415 ++++++++++++------ > 24 files changed, 377 insertions(+), 164 deletions(-) For the series Acked-by: Mike Rapoport <rppt@linux.ibm.com>