From patchwork Mon Nov 21 17:11:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13051388 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 D73FAC433FE for ; Mon, 21 Nov 2022 17:12:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BC186B0073; Mon, 21 Nov 2022 12:12:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2955E6B0075; Mon, 21 Nov 2022 12:12:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E85E6B0074; Mon, 21 Nov 2022 12:12:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 00CEE6B0072 for ; Mon, 21 Nov 2022 12:12:12 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id CA6E340BDC for ; Mon, 21 Nov 2022 17:12:12 +0000 (UTC) X-FDA: 80158092504.30.3778249 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf03.hostedemail.com (Postfix) with ESMTP id 34C9F2000A for ; Mon, 21 Nov 2022 17:12:11 +0000 (UTC) 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 DAF4E220BD; 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: in-reply-to:in-reply-to:references:references; bh=LiNIx3D+Vcqg/oY9PQmVLgvvCSLDF2Y8YpP6qaxgdmQ=; b=LPKd/io8qKI9K8EVw1r7vw2cy1PMA7Kwg6zn0iDq6kJHW5T8swTh27ag8LKyXvwjda1rbG ltPXt0gGx55SaIlg+ElNJXJWohazAtUZvWqniSm5gZt5gX6895aJRDMgb8ydR8k+o8nja+ MzbKnQSYnFGrW9m2Iy81tDRhhu7a5Dk= 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: in-reply-to:in-reply-to:references:references; bh=LiNIx3D+Vcqg/oY9PQmVLgvvCSLDF2Y8YpP6qaxgdmQ=; b=vV+8DIg+0WjsTwBQs+6XsipNzWjMdZc2I2kHsyMeo4zoE2ygokXewN4JweFLNzXHAo0Su2 CavHWb6InA0DkQBQ== 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 B0CAC1377F; 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 cC6MKmqxe2MQeQAAMHmgww (envelope-from ); Mon, 21 Nov 2022 17:12:10 +0000 From: Vlastimil Babka To: Christoph Lameter , David Rientjes , Joonsoo Kim , Pekka Enberg Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, Roman Gushchin , Andrew Morton , Linus Torvalds , Matthew Wilcox , patches@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Vlastimil Babka Subject: [PATCH 02/12] mm, slub: add CONFIG_SLUB_TINY Date: Mon, 21 Nov 2022 18:11:52 +0100 Message-Id: <20221121171202.22080-3-vbabka@suse.cz> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221121171202.22080-1-vbabka@suse.cz> References: <20221121171202.22080-1-vbabka@suse.cz> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669050732; a=rsa-sha256; cv=none; b=uAYRTjqgOMUwv1neMNs6B7acmAgBCugsz4bBLl946ojixU5qoZC83hvKBzYNPrhOc75srD P8K81wzoOUqcZP2ZCrnc6PLrlX/zHRv662E4I54vCY4J/fQBxdh/A4XluSsNj+gM17psrh uVLu4J4wPqOARaLP1t2EpM8yNYsnf0I= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="LPKd/io8"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=vV+8DIg+; spf=pass (imf03.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 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=1669050732; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LiNIx3D+Vcqg/oY9PQmVLgvvCSLDF2Y8YpP6qaxgdmQ=; b=k/85ViL+zzByLZ60MQK34K1YLZ+ncUDKobkgsQlURp8Vd3tNk94s0CLIlSEo68ALPaT0Cf zEeF1oB3oPdmqsQVUTBhvmkWJnfTrvq9+wxTHM5nYBZ3bq/JNqg9u0vimICKSov18bWRMu APz/GxfGvdDvJJbQXOUo7NT7gJjURyI= X-Stat-Signature: u1pfihchjmq4ghn48mjw5efh3nko1zww X-Rspamd-Queue-Id: 34C9F2000A X-Rspam-User: Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="LPKd/io8"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=vV+8DIg+; spf=pass (imf03.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-Rspamd-Server: rspam02 X-HE-Tag: 1669050731-969993 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: For tiny systems that have used SLOB until now, SLUB might be impractical due to its higher memory usage. To help with that, introduce an option CONFIG_SLUB_TINY that modifies SLUB to use less memory. This is done by sacrificing scalability, security and debugging features, therefore not recommended for any system with more than 16MB RAM. This commit introduces the option and uses it to set other related options in a way that reduces memory usage. Signed-off-by: Vlastimil Babka Acked-by: Roman Gushchin Acked-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/Kconfig | 21 +++++++++++++++++---- mm/Kconfig.debug | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/mm/Kconfig b/mm/Kconfig index 57e1d8c5b505..5941cb34e30d 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -230,6 +230,19 @@ config SLOB endchoice +config SLUB_TINY + bool "Configure SLUB for minimal memory footprint" + depends on SLUB && EXPERT + select SLAB_MERGE_DEFAULT + help + Configures the SLUB allocator in a way to achieve minimal memory + footprint, sacrificing scalability, debugging and other features. + This is intended only for the smallest system that had used the + SLOB allocator and is not recommended for systems with more than + 16MB RAM. + + If unsure, say N. + config SLAB_MERGE_DEFAULT bool "Allow slab caches to be merged" default y @@ -247,7 +260,7 @@ config SLAB_MERGE_DEFAULT config SLAB_FREELIST_RANDOM bool "Randomize slab freelist" - depends on SLAB || SLUB + depends on SLAB || SLUB && !SLUB_TINY help Randomizes the freelist order used on creating new pages. This security feature reduces the predictability of the kernel slab @@ -255,7 +268,7 @@ config SLAB_FREELIST_RANDOM config SLAB_FREELIST_HARDENED bool "Harden slab freelist metadata" - depends on SLAB || SLUB + depends on SLAB || SLUB && !SLUB_TINY help Many kernel heap attacks try to target slab cache metadata and other infrastructure. This options makes minor performance @@ -267,7 +280,7 @@ config SLAB_FREELIST_HARDENED config SLUB_STATS default n bool "Enable SLUB performance statistics" - depends on SLUB && SYSFS + depends on SLUB && SYSFS && !SLUB_TINY help SLUB statistics are useful to debug SLUBs allocation behavior in order find ways to optimize the allocator. This should never be @@ -279,7 +292,7 @@ config SLUB_STATS config SLUB_CPU_PARTIAL default y - depends on SLUB && SMP + depends on SLUB && SMP && !SLUB_TINY bool "SLUB per cpu partial cache" help Per cpu partial caches accelerate objects allocation and freeing diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug index ce8dded36de9..fca699ad1fb0 100644 --- a/mm/Kconfig.debug +++ b/mm/Kconfig.debug @@ -56,7 +56,7 @@ config DEBUG_SLAB config SLUB_DEBUG default y bool "Enable SLUB debugging support" if EXPERT - depends on SLUB && SYSFS + depends on SLUB && SYSFS && !SLUB_TINY select STACKDEPOT if STACKTRACE_SUPPORT help SLUB has extensive debug support features. Disabling these can