From patchwork Thu Aug 19 19:55:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 12447909 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22DB2C4338F for ; Thu, 19 Aug 2021 19:53:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7D0B160720 for ; Thu, 19 Aug 2021 19:53:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7D0B160720 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 092586B006C; Thu, 19 Aug 2021 15:53:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 042AB8D0001; Thu, 19 Aug 2021 15:53:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E73F56B0072; Thu, 19 Aug 2021 15:53:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0127.hostedemail.com [216.40.44.127]) by kanga.kvack.org (Postfix) with ESMTP id CD8EF6B006C for ; Thu, 19 Aug 2021 15:53:56 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 7B794824C43E for ; Thu, 19 Aug 2021 19:53:56 +0000 (UTC) X-FDA: 78492880872.22.43BCC14 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) by imf15.hostedemail.com (Postfix) with ESMTP id DEECED000099 for ; Thu, 19 Aug 2021 19:53:55 +0000 (UTC) Received: by mail-qk1-f176.google.com with SMTP id p22so8432505qki.10 for ; Thu, 19 Aug 2021 12:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=f0Vyo5Zpb/uKT9dTj3UDP38gz9wGa8FmLTe57ROUr0k=; b=nQwyYmzJ8Le7zMUt1HvjgRtMrGeHPynrZFZ0AGdDTvQ8sacbnNjxT4kbWrvN3vqlqc E7egmJZfZ0BuNIYc1+L59p+csI2/9saKxmtGVrf96I3Ii4Dq9kwqY3f6HZMkcztVSmYV ALfQ330+kUdEDUz+JV/wU7C29qYiagfkGZTxcpQlzRhAiYH6fxPaJAMq5yd4HbDTfgL1 blKs5koPh7juPKSjT0AwDo0+rwCv/cLgbBvxV2/M0M+XiUZE3Il5SPwL/EZRQW9rnlRY jai9LWOMhrhKRJ9p15RyGey3TP55vuHUkh/VM91jw7ELErAJr4Zf2Z0IJ/kYToSoss54 zjhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=f0Vyo5Zpb/uKT9dTj3UDP38gz9wGa8FmLTe57ROUr0k=; b=SsTRuFix8cMVkxt5fqX44vjFR0JbmNfQAuVnQzHNun/E2Jvoc2FHw9f5wb1B5r3X+H dB9Gkdt5PtO+yN2Ko9L+oCjMayorWnakJC+QkDaLNl0MRBOfI71eDR1r9aVXO4o/uxzP 9PwY8whRFpZ9MXSk4qN4ZLisrAVDH5ql6iQF7miKg2aW/Z6bjzX8QkWwYwt18ekWq7vV jzuqeuXGq1rXjoyKDVV6ltuakn1FhHaVZgCnvzCgtfl6muGTSvXVtl8/Be0u+wbQV7px Ax0HHro3YIadC5IDaVKuNiELwkYlZC0FKEnKiR8tQVguOq7W9knHinSDQDmubWH8jfiD 3OhQ== X-Gm-Message-State: AOAM531kH6aW0c0MfEFFrGwzo2PcZuWGlcWbnQj+U9rIuQSfqES1s1pn 9KWI1h8hjg2uViJLFWATwVZ6qw== X-Google-Smtp-Source: ABdhPJy9zvg5l8XB1C6E0TAARsBwSXIkC5w/HxVKpgjx9112FX0dad/lmtNVJavK/KExC9nNqqwVkg== X-Received: by 2002:a05:620a:1a14:: with SMTP id bk20mr5196856qkb.481.1629402835079; Thu, 19 Aug 2021 12:53:55 -0700 (PDT) Received: from localhost (cpe-98-15-154-102.hvc.res.rr.com. [98.15.154.102]) by smtp.gmail.com with ESMTPSA id bm7sm2014304qkb.79.2021.08.19.12.53.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 12:53:54 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 1/4] mm: Kconfig: move swap and slab config options to the MM section Date: Thu, 19 Aug 2021 15:55:30 -0400 Message-Id: <20210819195533.211756-1-hannes@cmpxchg.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=nQwyYmzJ; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf15.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.176 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org X-Stat-Signature: m5wqdji5wj1rgrpi9ik4m97uwfa8az75 X-Rspamd-Queue-Id: DEECED000099 X-Rspamd-Server: rspam01 X-HE-Tag: 1629402835-660521 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: These are currently under General Setup. MM seems like a better fit. Signed-off-by: Johannes Weiner Acked-by: Vlastimil Babka --- init/Kconfig | 120 --------------------------------------------------- mm/Kconfig | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 120 deletions(-) diff --git a/init/Kconfig b/init/Kconfig index a61c92066c2e..a2358cd5498a 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -331,23 +331,6 @@ config DEFAULT_HOSTNAME but you may wish to use a different default here to make a minimal system more usable with less configuration. -# -# For some reason microblaze and nios2 hard code SWAP=n. Hopefully we can -# add proper SWAP support to them, in which case this can be remove. -# -config ARCH_NO_SWAP - bool - -config SWAP - bool "Support for paging of anonymous memory (swap)" - depends on MMU && BLOCK && !ARCH_NO_SWAP - default y - help - This option allows you to choose whether you want to have support - for so called swap devices or swap files in your kernel that are - used to provide more virtual memory than the actual RAM present - in your computer. If unsure say Y. - config SYSVIPC bool "System V IPC" help @@ -1862,109 +1845,6 @@ config COMPAT_BRK On non-ancient distros (post-2000 ones) N is usually a safe choice. -choice - prompt "Choose SLAB allocator" - default SLUB - help - This option allows to select a slab allocator. - -config SLAB - bool "SLAB" - select HAVE_HARDENED_USERCOPY_ALLOCATOR - help - The regular slab allocator that is established and known to work - well in all environments. It organizes cache hot objects in - per cpu and per node queues. - -config SLUB - bool "SLUB (Unqueued Allocator)" - select HAVE_HARDENED_USERCOPY_ALLOCATOR - help - SLUB is a slab allocator that minimizes cache line usage - instead of managing queues of cached objects (SLAB approach). - Per cpu caching is realized using slabs of objects instead - of queues of objects. SLUB can use memory efficiently - and has enhanced diagnostics. SLUB is the default choice for - a slab allocator. - -config SLOB - depends on EXPERT - bool "SLOB (Simple Allocator)" - help - SLOB replaces the stock allocator with a drastically simpler - allocator. SLOB is generally more space efficient but - does not perform as well on large systems. - -endchoice - -config SLAB_MERGE_DEFAULT - bool "Allow slab caches to be merged" - default y - help - For reduced kernel memory fragmentation, slab caches can be - merged when they share the same size and other characteristics. - This carries a risk of kernel heap overflows being able to - overwrite objects from merged caches (and more easily control - cache layout), which makes such heap attacks easier to exploit - by attackers. By keeping caches unmerged, these kinds of exploits - can usually only damage objects in the same cache. To disable - merging at runtime, "slab_nomerge" can be passed on the kernel - command line. - -config SLAB_FREELIST_RANDOM - bool "Randomize slab freelist" - depends on SLAB || SLUB - help - Randomizes the freelist order used on creating new pages. This - security feature reduces the predictability of the kernel slab - allocator against heap overflows. - -config SLAB_FREELIST_HARDENED - bool "Harden slab freelist metadata" - depends on SLAB || SLUB - help - Many kernel heap attacks try to target slab cache metadata and - other infrastructure. This options makes minor performance - sacrifices to harden the kernel slab allocator against common - freelist exploit methods. Some slab implementations have more - sanity-checking than others. This option is most effective with - CONFIG_SLUB. - -config SHUFFLE_PAGE_ALLOCATOR - bool "Page allocator randomization" - default SLAB_FREELIST_RANDOM && ACPI_NUMA - help - Randomization of the page allocator improves the average - utilization of a direct-mapped memory-side-cache. See section - 5.2.27 Heterogeneous Memory Attribute Table (HMAT) in the ACPI - 6.2a specification for an example of how a platform advertises - the presence of a memory-side-cache. There are also incidental - security benefits as it reduces the predictability of page - allocations to compliment SLAB_FREELIST_RANDOM, but the - default granularity of shuffling on the "MAX_ORDER - 1" i.e, - 10th order of pages is selected based on cache utilization - benefits on x86. - - While the randomization improves cache utilization it may - negatively impact workloads on platforms without a cache. For - this reason, by default, the randomization is enabled only - after runtime detection of a direct-mapped memory-side-cache. - Otherwise, the randomization may be force enabled with the - 'page_alloc.shuffle' kernel command line parameter. - - Say Y if unsure. - -config SLUB_CPU_PARTIAL - default y - depends on SLUB && SMP - bool "SLUB per cpu partial cache" - help - Per cpu partial caches accelerate objects allocation and freeing - that is local to a processor at the price of more indeterminism - in the latency of the free. On overflow these caches will be cleared - which requires the taking of locks that may cause latency spikes. - Typically one would choose no for a realtime system. - config MMAP_ALLOW_UNINITIALIZED bool "Allow mmapped anonymous memory to be uninitialized" depends on EXPERT && !MMU diff --git a/mm/Kconfig b/mm/Kconfig index 02d44e3420f5..894858536e7f 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -2,6 +2,126 @@ menu "Memory Management options" +# +# For some reason microblaze and nios2 hard code SWAP=n. Hopefully we can +# add proper SWAP support to them, in which case this can be remove. +# +config ARCH_NO_SWAP + bool + +config SWAP + bool "Support for paging of anonymous memory (swap)" + depends on MMU && BLOCK && !ARCH_NO_SWAP + default y + help + This option allows you to choose whether you want to have support + for so called swap devices or swap files in your kernel that are + used to provide more virtual memory than the actual RAM present + in your computer. If unsure say Y. + +choice + prompt "Choose SLAB allocator" + default SLUB + help + This option allows to select a slab allocator. + +config SLAB + bool "SLAB" + select HAVE_HARDENED_USERCOPY_ALLOCATOR + help + The regular slab allocator that is established and known to work + well in all environments. It organizes cache hot objects in + per cpu and per node queues. + +config SLUB + bool "SLUB (Unqueued Allocator)" + select HAVE_HARDENED_USERCOPY_ALLOCATOR + help + SLUB is a slab allocator that minimizes cache line usage + instead of managing queues of cached objects (SLAB approach). + Per cpu caching is realized using slabs of objects instead + of queues of objects. SLUB can use memory efficiently + and has enhanced diagnostics. SLUB is the default choice for + a slab allocator. + +config SLOB + depends on EXPERT + bool "SLOB (Simple Allocator)" + help + SLOB replaces the stock allocator with a drastically simpler + allocator. SLOB is generally more space efficient but + does not perform as well on large systems. + +endchoice + +config SLAB_MERGE_DEFAULT + bool "Allow slab caches to be merged" + default y + help + For reduced kernel memory fragmentation, slab caches can be + merged when they share the same size and other characteristics. + This carries a risk of kernel heap overflows being able to + overwrite objects from merged caches (and more easily control + cache layout), which makes such heap attacks easier to exploit + by attackers. By keeping caches unmerged, these kinds of exploits + can usually only damage objects in the same cache. To disable + merging at runtime, "slab_nomerge" can be passed on the kernel + command line. + +config SLAB_FREELIST_RANDOM + bool "Randomize slab freelist" + depends on SLAB || SLUB + help + Randomizes the freelist order used on creating new pages. This + security feature reduces the predictability of the kernel slab + allocator against heap overflows. + +config SLAB_FREELIST_HARDENED + bool "Harden slab freelist metadata" + depends on SLAB || SLUB + help + Many kernel heap attacks try to target slab cache metadata and + other infrastructure. This options makes minor performance + sacrifices to harden the kernel slab allocator against common + freelist exploit methods. Some slab implementations have more + sanity-checking than others. This option is most effective with + CONFIG_SLUB. + +config SHUFFLE_PAGE_ALLOCATOR + bool "Page allocator randomization" + default SLAB_FREELIST_RANDOM && ACPI_NUMA + help + Randomization of the page allocator improves the average + utilization of a direct-mapped memory-side-cache. See section + 5.2.27 Heterogeneous Memory Attribute Table (HMAT) in the ACPI + 6.2a specification for an example of how a platform advertises + the presence of a memory-side-cache. There are also incidental + security benefits as it reduces the predictability of page + allocations to compliment SLAB_FREELIST_RANDOM, but the + default granularity of shuffling on the "MAX_ORDER - 1" i.e, + 10th order of pages is selected based on cache utilization + benefits on x86. + + While the randomization improves cache utilization it may + negatively impact workloads on platforms without a cache. For + this reason, by default, the randomization is enabled only + after runtime detection of a direct-mapped memory-side-cache. + Otherwise, the randomization may be force enabled with the + 'page_alloc.shuffle' kernel command line parameter. + + Say Y if unsure. + +config SLUB_CPU_PARTIAL + default y + depends on SLUB && SMP + bool "SLUB per cpu partial cache" + help + Per cpu partial caches accelerate objects allocation and freeing + that is local to a processor at the price of more indeterminism + in the latency of the free. On overflow these caches will be cleared + which requires the taking of locks that may cause latency spikes. + Typically one would choose no for a realtime system. + config SELECT_MEMORY_MODEL def_bool y depends on ARCH_SELECT_MEMORY_MODEL From patchwork Thu Aug 19 19:55:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 12447913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63919C4320E for ; Thu, 19 Aug 2021 19:53:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BD884610CF for ; Thu, 19 Aug 2021 19:53:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BD884610CF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 59F1C6B0071; Thu, 19 Aug 2021 15:53:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D9998D0001; Thu, 19 Aug 2021 15:53:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 329F76B0073; Thu, 19 Aug 2021 15:53:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0214.hostedemail.com [216.40.44.214]) by kanga.kvack.org (Postfix) with ESMTP id 105286B0071 for ; Thu, 19 Aug 2021 15:53:58 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id ADF1818041D1A for ; Thu, 19 Aug 2021 19:53:57 +0000 (UTC) X-FDA: 78492880914.04.F20A2B5 Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by imf14.hostedemail.com (Postfix) with ESMTP id 3C3136001980 for ; Thu, 19 Aug 2021 19:53:57 +0000 (UTC) Received: by mail-qt1-f173.google.com with SMTP id l24so5590587qtj.4 for ; Thu, 19 Aug 2021 12:53:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MVVGLw1r7yJ/rcgAC7V6ll4qt4izuftp3UCKThI0BB0=; b=DnCSFPBbDIw8zdsCdzkAkJLB8ZFRmXOdAP1jB0gYzj9NAmP8EJAp1BnCtzXZBQ1Tly ccsckeGPiQ11wrYq8VSdSqSqCHK8YV/2/Jwu7PZzlJyggNoxCcjm9Kc7DqUp40pSrPv2 NrFo9ZNXvx1iY/7LSfxdxbUx+reKT1+I8/90aymlTN9wyvjzbTyqX1UieU9yIzsqBrVv BL2HUtRWdOB/CuQOYW4wJ1oYnDbfH8ZIh3NR7COZe+ujvmqCt16sCH0c+OroCm+r6OON ux/eg8RhpRWOyxC1oMcWrYSs5lnUrX/tBD7EWjoQ8yWZPTeqcESDkAeEjdTZH627sh1U B94A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MVVGLw1r7yJ/rcgAC7V6ll4qt4izuftp3UCKThI0BB0=; b=rGkN0crnXXUxjKGd8JgNnm3YkruhrZXQUt/jzpOjjvnci4JgoyPWjFKgL4KxmlngIC 8AAlM7fXVsb3vOojzF06JU04Y8hwFJjUtOOzAfOvUGtOz3guyNnYgBZ5MSxovATaOhuB mIHAS7DI6nu4sk5mantJfcmFeOrlyPzzbkZup6BntoUwLjDXTyySKxJsqK4E9XOe1QAY js/kbpZuCf9lHMBlVWQuWCqAZ18FOHDgj4ds76GQ+fK7Obw8voFCfU0+axCFVI0M18/T n3UkkJLE4FwHg3cAvB7BoXtiEZDSc7B7I+koUw0TUffWyKEi5l2Hsc9N5AZ+Jr45Q6L+ MPjQ== X-Gm-Message-State: AOAM530DbKPj5Sw38RAyvfu2JMfw/ppN0t9V0HD6iCBv+nLmosImEVFZ ttv3iFiCZz2lC2SvgyPm9v6FxA== X-Google-Smtp-Source: ABdhPJzOevSBrQZwGK+wFMGGkmMmQPwYOJYH3IgFv+7rB+u+3zA41R1tJMZzTZfKWaL85xfCO7P6yA== X-Received: by 2002:a05:622a:2cc:: with SMTP id a12mr14288496qtx.115.1629402836481; Thu, 19 Aug 2021 12:53:56 -0700 (PDT) Received: from localhost (cpe-98-15-154-102.hvc.res.rr.com. [98.15.154.102]) by smtp.gmail.com with ESMTPSA id j185sm2168388qkf.28.2021.08.19.12.53.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 12:53:55 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 2/4] mm: Kconfig: group swap, slab, hotplug and thp options into submenus Date: Thu, 19 Aug 2021 15:55:31 -0400 Message-Id: <20210819195533.211756-2-hannes@cmpxchg.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210819195533.211756-1-hannes@cmpxchg.org> References: <20210819195533.211756-1-hannes@cmpxchg.org> MIME-Version: 1.0 Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=DnCSFPBb; spf=pass (imf14.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.173 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 3C3136001980 X-Stat-Signature: c16rrrshunw1ecgxqrntouzy5sn4rfzq X-HE-Tag: 1629402837-669563 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: There are several clusters of related config options spread throughout the mostly flat MM submenu. Group them together and put specialization options into further subdirectories to make the MM section a bit more organized and easier to navigate. Signed-off-by: Johannes Weiner Acked-by: Vlastimil Babka --- mm/Kconfig | 428 +++++++++++++++++++++++++++-------------------------- 1 file changed, 222 insertions(+), 206 deletions(-) diff --git a/mm/Kconfig b/mm/Kconfig index 894858536e7f..dbceaa2a04a4 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -9,7 +9,7 @@ menu "Memory Management options" config ARCH_NO_SWAP bool -config SWAP +menuconfig SWAP bool "Support for paging of anonymous memory (swap)" depends on MMU && BLOCK && !ARCH_NO_SWAP default y @@ -19,6 +19,192 @@ config SWAP used to provide more virtual memory than the actual RAM present in your computer. If unsure say Y. +if SWAP + +config ZSWAP + bool "Compressed cache for swap pages (EXPERIMENTAL)" + depends on FRONTSWAP && CRYPTO=y + select ZPOOL + help + A lightweight compressed cache for swap pages. It takes + pages that are in the process of being swapped out and attempts to + compress them into a dynamically allocated RAM-based memory pool. + This can result in a significant I/O reduction on swap device and, + in the case where decompressing from RAM is faster that swap device + reads, can also improve workload performance. + + This is marked experimental because it is a new feature (as of + v3.11) that interacts heavily with memory reclaim. While these + interactions don't cause any known issues on simple memory setups, + they have not be fully explored on the large set of potential + configurations and workloads that exist. + +choice + prompt "Compressed cache for swap pages default compressor" + depends on ZSWAP + default ZSWAP_COMPRESSOR_DEFAULT_LZO + help + Selects the default compression algorithm for the compressed cache + for swap pages. + + For an overview what kind of performance can be expected from + a particular compression algorithm please refer to the benchmarks + available at the following LWN page: + https://lwn.net/Articles/751795/ + + If in doubt, select 'LZO'. + + The selection made here can be overridden by using the kernel + command line 'zswap.compressor=' option. + +config ZSWAP_COMPRESSOR_DEFAULT_DEFLATE + bool "Deflate" + select CRYPTO_DEFLATE + help + Use the Deflate algorithm as the default compression algorithm. + +config ZSWAP_COMPRESSOR_DEFAULT_LZO + bool "LZO" + select CRYPTO_LZO + help + Use the LZO algorithm as the default compression algorithm. + +config ZSWAP_COMPRESSOR_DEFAULT_842 + bool "842" + select CRYPTO_842 + help + Use the 842 algorithm as the default compression algorithm. + +config ZSWAP_COMPRESSOR_DEFAULT_LZ4 + bool "LZ4" + select CRYPTO_LZ4 + help + Use the LZ4 algorithm as the default compression algorithm. + +config ZSWAP_COMPRESSOR_DEFAULT_LZ4HC + bool "LZ4HC" + select CRYPTO_LZ4HC + help + Use the LZ4HC algorithm as the default compression algorithm. + +config ZSWAP_COMPRESSOR_DEFAULT_ZSTD + bool "zstd" + select CRYPTO_ZSTD + help + Use the zstd algorithm as the default compression algorithm. +endchoice + +config ZSWAP_COMPRESSOR_DEFAULT + string + depends on ZSWAP + default "deflate" if ZSWAP_COMPRESSOR_DEFAULT_DEFLATE + default "lzo" if ZSWAP_COMPRESSOR_DEFAULT_LZO + default "842" if ZSWAP_COMPRESSOR_DEFAULT_842 + default "lz4" if ZSWAP_COMPRESSOR_DEFAULT_LZ4 + default "lz4hc" if ZSWAP_COMPRESSOR_DEFAULT_LZ4HC + default "zstd" if ZSWAP_COMPRESSOR_DEFAULT_ZSTD + default "" + +choice + prompt "Compressed cache for swap pages default allocator" + depends on ZSWAP + default ZSWAP_ZPOOL_DEFAULT_ZBUD + help + Selects the default allocator for the compressed cache for + swap pages. + The default is 'zbud' for compatibility, however please do + read the description of each of the allocators below before + making a right choice. + + The selection made here can be overridden by using the kernel + command line 'zswap.zpool=' option. + +config ZSWAP_ZPOOL_DEFAULT_ZBUD + bool "zbud" + select ZBUD + help + Use the zbud allocator as the default allocator. + +config ZSWAP_ZPOOL_DEFAULT_Z3FOLD + bool "z3fold" + select Z3FOLD + help + Use the z3fold allocator as the default allocator. + +config ZSWAP_ZPOOL_DEFAULT_ZSMALLOC + bool "zsmalloc" + select ZSMALLOC + help + Use the zsmalloc allocator as the default allocator. +endchoice + +config ZSWAP_ZPOOL_DEFAULT + string + depends on ZSWAP + default "zbud" if ZSWAP_ZPOOL_DEFAULT_ZBUD + default "z3fold" if ZSWAP_ZPOOL_DEFAULT_Z3FOLD + default "zsmalloc" if ZSWAP_ZPOOL_DEFAULT_ZSMALLOC + default "" + +config ZSWAP_DEFAULT_ON + bool "Enable the compressed cache for swap pages by default" + depends on ZSWAP + help + If selected, the compressed cache for swap pages will be enabled + at boot, otherwise it will be disabled. + + The selection made here can be overridden by using the kernel + command line 'zswap.enabled=' option. + +config ZPOOL + tristate "Common API for compressed memory storage" + help + Compressed memory storage API. This allows using either zbud or + zsmalloc. + +config ZBUD + tristate "Low (Up to 2x) density storage for compressed pages" + help + A special purpose allocator for storing compressed pages. + It is designed to store up to two compressed pages per physical + page. While this design limits storage density, it has simple and + deterministic reclaim properties that make it preferable to a higher + density approach when reclaim will be used. + +config Z3FOLD + tristate "Up to 3x density storage for compressed pages" + depends on ZPOOL + help + A special purpose allocator for storing compressed pages. + It is designed to store up to three compressed pages per physical + page. It is a ZBUD derivative so the simplicity and determinism are + still there. + +config ZSMALLOC + tristate "Memory allocator for compressed pages" + depends on MMU + help + zsmalloc is a slab-based memory allocator designed to store + compressed RAM pages. zsmalloc uses virtual memory mapping + in order to reduce fragmentation. However, this results in a + non-standard allocator interface where a handle, not a pointer, is + returned by an alloc(). This handle must be mapped in order to + access the allocated space. + +config ZSMALLOC_STAT + bool "Export zsmalloc statistics" + depends on ZSMALLOC + select DEBUG_FS + help + This option enables code in the zsmalloc to collect various + statistics about what's happening in zsmalloc and exports that + information to userspace via debugfs. + If unsure, say N. + +endif # SWAP + +menu "SLAB allocator options" + choice prompt "Choose SLAB allocator" default SLUB @@ -87,6 +273,19 @@ config SLAB_FREELIST_HARDENED sanity-checking than others. This option is most effective with CONFIG_SLUB. +config SLUB_CPU_PARTIAL + default y + depends on SLUB && SMP + bool "SLUB per cpu partial cache" + help + Per cpu partial caches accelerate objects allocation and freeing + that is local to a processor at the price of more indeterminism + in the latency of the free. On overflow these caches will be cleared + which requires the taking of locks that may cause latency spikes. + Typically one would choose no for a realtime system. + +endmenu # SLAB allocator options + config SHUFFLE_PAGE_ALLOCATOR bool "Page allocator randomization" default SLAB_FREELIST_RANDOM && ACPI_NUMA @@ -111,17 +310,6 @@ config SHUFFLE_PAGE_ALLOCATOR Say Y if unsure. -config SLUB_CPU_PARTIAL - default y - depends on SLUB && SMP - bool "SLUB per cpu partial cache" - help - Per cpu partial caches accelerate objects allocation and freeing - that is local to a processor at the price of more indeterminism - in the latency of the free. On overflow these caches will be cleared - which requires the taking of locks that may cause latency spikes. - Typically one would choose no for a realtime system. - config SELECT_MEMORY_MODEL def_bool y depends on ARCH_SELECT_MEMORY_MODEL @@ -272,14 +460,16 @@ config ARCH_ENABLE_MEMORY_HOTPLUG bool # eventually, we can have this option just 'select SPARSEMEM' -config MEMORY_HOTPLUG - bool "Allow for memory hot-add" +menuconfig MEMORY_HOTPLUG + bool "Memory hotplug" select MEMORY_ISOLATION depends on SPARSEMEM || X86_64_ACPI_NUMA depends on ARCH_ENABLE_MEMORY_HOTPLUG depends on 64BIT || BROKEN select NUMA_KEEP_MEMINFO if NUMA +if MEMORY_HOTPLUG + config MEMORY_HOTPLUG_SPARSE def_bool y depends on SPARSEMEM && MEMORY_HOTPLUG @@ -313,6 +503,8 @@ config MHP_MEMMAP_ON_MEMORY depends on MEMORY_HOTPLUG && SPARSEMEM_VMEMMAP depends on ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE +endif # MEMORY_HOTPLUG + # Heavily threaded applications may benefit from splitting the mm-wide # page_table_lock, so that faults on different parts of the user address # space can be handled with less contention: split it at this NR_CPUS. @@ -521,7 +713,7 @@ config NOMMU_INITIAL_TRIM_EXCESS See Documentation/admin-guide/mm/nommu-mmap.rst for more information. -config TRANSPARENT_HUGEPAGE +menuconfig TRANSPARENT_HUGEPAGE bool "Transparent Hugepage Support" depends on HAVE_ARCH_TRANSPARENT_HUGEPAGE select COMPACTION @@ -536,6 +728,8 @@ config TRANSPARENT_HUGEPAGE If memory constrained on embedded, you may want to say N. +if TRANSPARENT_HUGEPAGE + choice prompt "Transparent Hugepage Support sysfs defaults" depends on TRANSPARENT_HUGEPAGE @@ -573,6 +767,19 @@ config THP_SWAP For selection by architectures with reasonable THP sizes. +config READ_ONLY_THP_FOR_FS + bool "Read-only THP for filesystems (EXPERIMENTAL)" + depends on TRANSPARENT_HUGEPAGE && SHMEM + + help + Allow khugepaged to put read-only file-backed pages in THP. + + This is marked experimental because it is a new feature. Write + support of file THPs will be developed in the next few release + cycles. + +endif # TRANSPARENT_HUGEPAGE + # # UP and nommu archs use km based percpu allocator # @@ -680,186 +887,6 @@ config MEM_SOFT_DIRTY See Documentation/admin-guide/mm/soft-dirty.rst for more details. -config ZSWAP - bool "Compressed cache for swap pages (EXPERIMENTAL)" - depends on FRONTSWAP && CRYPTO=y - select ZPOOL - help - A lightweight compressed cache for swap pages. It takes - pages that are in the process of being swapped out and attempts to - compress them into a dynamically allocated RAM-based memory pool. - This can result in a significant I/O reduction on swap device and, - in the case where decompressing from RAM is faster that swap device - reads, can also improve workload performance. - - This is marked experimental because it is a new feature (as of - v3.11) that interacts heavily with memory reclaim. While these - interactions don't cause any known issues on simple memory setups, - they have not be fully explored on the large set of potential - configurations and workloads that exist. - -choice - prompt "Compressed cache for swap pages default compressor" - depends on ZSWAP - default ZSWAP_COMPRESSOR_DEFAULT_LZO - help - Selects the default compression algorithm for the compressed cache - for swap pages. - - For an overview what kind of performance can be expected from - a particular compression algorithm please refer to the benchmarks - available at the following LWN page: - https://lwn.net/Articles/751795/ - - If in doubt, select 'LZO'. - - The selection made here can be overridden by using the kernel - command line 'zswap.compressor=' option. - -config ZSWAP_COMPRESSOR_DEFAULT_DEFLATE - bool "Deflate" - select CRYPTO_DEFLATE - help - Use the Deflate algorithm as the default compression algorithm. - -config ZSWAP_COMPRESSOR_DEFAULT_LZO - bool "LZO" - select CRYPTO_LZO - help - Use the LZO algorithm as the default compression algorithm. - -config ZSWAP_COMPRESSOR_DEFAULT_842 - bool "842" - select CRYPTO_842 - help - Use the 842 algorithm as the default compression algorithm. - -config ZSWAP_COMPRESSOR_DEFAULT_LZ4 - bool "LZ4" - select CRYPTO_LZ4 - help - Use the LZ4 algorithm as the default compression algorithm. - -config ZSWAP_COMPRESSOR_DEFAULT_LZ4HC - bool "LZ4HC" - select CRYPTO_LZ4HC - help - Use the LZ4HC algorithm as the default compression algorithm. - -config ZSWAP_COMPRESSOR_DEFAULT_ZSTD - bool "zstd" - select CRYPTO_ZSTD - help - Use the zstd algorithm as the default compression algorithm. -endchoice - -config ZSWAP_COMPRESSOR_DEFAULT - string - depends on ZSWAP - default "deflate" if ZSWAP_COMPRESSOR_DEFAULT_DEFLATE - default "lzo" if ZSWAP_COMPRESSOR_DEFAULT_LZO - default "842" if ZSWAP_COMPRESSOR_DEFAULT_842 - default "lz4" if ZSWAP_COMPRESSOR_DEFAULT_LZ4 - default "lz4hc" if ZSWAP_COMPRESSOR_DEFAULT_LZ4HC - default "zstd" if ZSWAP_COMPRESSOR_DEFAULT_ZSTD - default "" - -choice - prompt "Compressed cache for swap pages default allocator" - depends on ZSWAP - default ZSWAP_ZPOOL_DEFAULT_ZBUD - help - Selects the default allocator for the compressed cache for - swap pages. - The default is 'zbud' for compatibility, however please do - read the description of each of the allocators below before - making a right choice. - - The selection made here can be overridden by using the kernel - command line 'zswap.zpool=' option. - -config ZSWAP_ZPOOL_DEFAULT_ZBUD - bool "zbud" - select ZBUD - help - Use the zbud allocator as the default allocator. - -config ZSWAP_ZPOOL_DEFAULT_Z3FOLD - bool "z3fold" - select Z3FOLD - help - Use the z3fold allocator as the default allocator. - -config ZSWAP_ZPOOL_DEFAULT_ZSMALLOC - bool "zsmalloc" - select ZSMALLOC - help - Use the zsmalloc allocator as the default allocator. -endchoice - -config ZSWAP_ZPOOL_DEFAULT - string - depends on ZSWAP - default "zbud" if ZSWAP_ZPOOL_DEFAULT_ZBUD - default "z3fold" if ZSWAP_ZPOOL_DEFAULT_Z3FOLD - default "zsmalloc" if ZSWAP_ZPOOL_DEFAULT_ZSMALLOC - default "" - -config ZSWAP_DEFAULT_ON - bool "Enable the compressed cache for swap pages by default" - depends on ZSWAP - help - If selected, the compressed cache for swap pages will be enabled - at boot, otherwise it will be disabled. - - The selection made here can be overridden by using the kernel - command line 'zswap.enabled=' option. - -config ZPOOL - tristate "Common API for compressed memory storage" - help - Compressed memory storage API. This allows using either zbud or - zsmalloc. - -config ZBUD - tristate "Low (Up to 2x) density storage for compressed pages" - help - A special purpose allocator for storing compressed pages. - It is designed to store up to two compressed pages per physical - page. While this design limits storage density, it has simple and - deterministic reclaim properties that make it preferable to a higher - density approach when reclaim will be used. - -config Z3FOLD - tristate "Up to 3x density storage for compressed pages" - depends on ZPOOL - help - A special purpose allocator for storing compressed pages. - It is designed to store up to three compressed pages per physical - page. It is a ZBUD derivative so the simplicity and determinism are - still there. - -config ZSMALLOC - tristate "Memory allocator for compressed pages" - depends on MMU - help - zsmalloc is a slab-based memory allocator designed to store - compressed RAM pages. zsmalloc uses virtual memory mapping - in order to reduce fragmentation. However, this results in a - non-standard allocator interface where a handle, not a pointer, is - returned by an alloc(). This handle must be mapped in order to - access the allocated space. - -config ZSMALLOC_STAT - bool "Export zsmalloc statistics" - depends on ZSMALLOC - select DEBUG_FS - help - This option enables code in the zsmalloc to collect various - statistics about what's happening in zsmalloc and exports that - information to userspace via debugfs. - If unsure, say N. - config GENERIC_EARLY_IOREMAP bool @@ -988,17 +1015,6 @@ comment "GUP_TEST needs to have DEBUG_FS enabled" config GUP_GET_PTE_LOW_HIGH bool -config READ_ONLY_THP_FOR_FS - bool "Read-only THP for filesystems (EXPERIMENTAL)" - depends on TRANSPARENT_HUGEPAGE && SHMEM - - help - Allow khugepaged to put read-only file-backed pages in THP. - - This is marked experimental because it is a new feature. Write - support of file THPs will be developed in the next few release - cycles. - config ARCH_HAS_PTE_SPECIAL bool From patchwork Thu Aug 19 19:55:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 12447911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39F34C43216 for ; Thu, 19 Aug 2021 19:54:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CA3DE60720 for ; Thu, 19 Aug 2021 19:54:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CA3DE60720 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 4D9136B0072; Thu, 19 Aug 2021 15:53:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 489858D0001; Thu, 19 Aug 2021 15:53:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 305086B0074; Thu, 19 Aug 2021 15:53:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0101.hostedemail.com [216.40.44.101]) by kanga.kvack.org (Postfix) with ESMTP id 0A0B16B0072 for ; Thu, 19 Aug 2021 15:53:59 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A0ECD2A4AD for ; Thu, 19 Aug 2021 19:53:58 +0000 (UTC) X-FDA: 78492880956.23.8BFE092 Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) by imf20.hostedemail.com (Postfix) with ESMTP id 69DAED0000B1 for ; Thu, 19 Aug 2021 19:53:58 +0000 (UTC) Received: by mail-qk1-f175.google.com with SMTP id az7so8453735qkb.5 for ; Thu, 19 Aug 2021 12:53:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Te7Vtbwf1FWH0SUwrKII1C36E9Z2yXd6HJrJnQpoc3k=; b=FP0ANrLl3UD45GmhfienmSCRtF1dYHDlsGkhvNovLGbUXVXLv34pEYocAPQWTm65TM ZeO0tgubrtGYvnYOgpRZSxJzsdGLl0wmE7bX28IGFK6gHCq7/43IwsXAfuvAY81RqLlX c6Zx98qId4RchnRxj0eo9l09M6qnk6vpUfnbcjxgSpauzo/xxqw0xffzmh0PKPswvgal cQJzy9HCPoNlRNjJpGJBL1khs8rgEdMNaI5/PYf4x93D0xoPj1lyu5odPT8tbueCRHiL SqoqsnTa/+yjV4Io40TGguPNrM0vx0ILBq+kC8lfX/CPK97jKxnAPzs7It1228Lxw+ds 6nxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Te7Vtbwf1FWH0SUwrKII1C36E9Z2yXd6HJrJnQpoc3k=; b=jQ6aOIqYi+XW/ESgE4PtRnfBgQ/F0JBDSPso8N6b+ZrNOdUZPyW7tf42aoEVSBSfSZ LF+c2isWOCbqfwkqWq46RzlRqmqBr/4wgoKQE/vzaR4euUa4G9vRqm1K+EYxY1CggXms ujX9yz9OwRZ1Fm/CLM9sWbsVvNU9QpxRTyMqjPgCS4piVNarWOR4ju0NFT7/6NgWRXfu wg3bIZ7AHMr9gDRwzXA5zvcbByacNp1wRNZ3Omr+9UMVkVmQu41CnSfsALdzNOeDC3aD 5epM+g+Ow0e6cOBzqq3LUVzOZlNQJNfCNut9T81CKib2p9u/0O7idXCzypIho3j+eJDR N7LQ== X-Gm-Message-State: AOAM531paAA/CuZ9JM9/DvaMFwIt+pfoHnbUFqQ+vZq6wROqPXlfN4p6 IkuS2A2xbI5auzBHJJem7rp0SA== X-Google-Smtp-Source: ABdhPJxu3u/NfH1mWdipGRolH4jKp7zgO23gRqOeKD0UyirhOewQ0ol8nkW0R5p1CKnRHg+8dbLtxQ== X-Received: by 2002:a37:c94:: with SMTP id 142mr5381982qkm.78.1629402837838; Thu, 19 Aug 2021 12:53:57 -0700 (PDT) Received: from localhost (cpe-98-15-154-102.hvc.res.rr.com. [98.15.154.102]) by smtp.gmail.com with ESMTPSA id x8sm1649604qts.69.2021.08.19.12.53.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 12:53:57 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 3/4] mm: Kconfig: simplify zswap configuration Date: Thu, 19 Aug 2021 15:55:32 -0400 Message-Id: <20210819195533.211756-3-hannes@cmpxchg.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210819195533.211756-1-hannes@cmpxchg.org> References: <20210819195533.211756-1-hannes@cmpxchg.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 69DAED0000B1 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=FP0ANrLl; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf20.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.175 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org X-Rspamd-Server: rspam04 X-Stat-Signature: x7uhukdngyn7pyhhoh1457fureaipzqt X-HE-Tag: 1629402838-794042 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: Clean up option ordering; make prompts and help text more concise and actionable for non-developers; turn depends into selects where possible, so that users can simply select the functionality they want without having to chase down obscure code dependencies. Signed-off-by: Johannes Weiner --- drivers/block/zram/Kconfig | 3 ++- mm/Kconfig | 53 ++++++++++++++++++-------------------- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/drivers/block/zram/Kconfig b/drivers/block/zram/Kconfig index 668c6bf2554d..e4163d4b936b 100644 --- a/drivers/block/zram/Kconfig +++ b/drivers/block/zram/Kconfig @@ -1,8 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 config ZRAM tristate "Compressed RAM block device support" - depends on BLOCK && SYSFS && ZSMALLOC && CRYPTO + depends on BLOCK && SYSFS depends on CRYPTO_LZO || CRYPTO_ZSTD || CRYPTO_LZ4 || CRYPTO_LZ4HC || CRYPTO_842 + select ZSMALLOC help Creates virtual block devices called /dev/zramX (X = 0, 1, ...). Pages written to these disks are compressed and stored in memory diff --git a/mm/Kconfig b/mm/Kconfig index dbceaa2a04a4..62c6e6092a0a 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -21,9 +21,13 @@ menuconfig SWAP if SWAP +config ZPOOL + bool + config ZSWAP bool "Compressed cache for swap pages (EXPERIMENTAL)" - depends on FRONTSWAP && CRYPTO=y + select FRONTSWAP + select CRYPTO select ZPOOL help A lightweight compressed cache for swap pages. It takes @@ -39,8 +43,18 @@ config ZSWAP they have not be fully explored on the large set of potential configurations and workloads that exist. +config ZSWAP_DEFAULT_ON + bool "Enable the compressed cache for swap pages by default" + depends on ZSWAP + help + If selected, the compressed cache for swap pages will be enabled + at boot, otherwise it will be disabled. + + The selection made here can be overridden by using the kernel + command line 'zswap.enabled=' option. + choice - prompt "Compressed cache for swap pages default compressor" + prompt "Default compressor" depends on ZSWAP default ZSWAP_COMPRESSOR_DEFAULT_LZO help @@ -106,7 +120,7 @@ config ZSWAP_COMPRESSOR_DEFAULT default "" choice - prompt "Compressed cache for swap pages default allocator" + prompt "Default allocator" depends on ZSWAP default ZSWAP_ZPOOL_DEFAULT_ZBUD help @@ -146,24 +160,9 @@ config ZSWAP_ZPOOL_DEFAULT default "zsmalloc" if ZSWAP_ZPOOL_DEFAULT_ZSMALLOC default "" -config ZSWAP_DEFAULT_ON - bool "Enable the compressed cache for swap pages by default" - depends on ZSWAP - help - If selected, the compressed cache for swap pages will be enabled - at boot, otherwise it will be disabled. - - The selection made here can be overridden by using the kernel - command line 'zswap.enabled=' option. - -config ZPOOL - tristate "Common API for compressed memory storage" - help - Compressed memory storage API. This allows using either zbud or - zsmalloc. - config ZBUD - tristate "Low (Up to 2x) density storage for compressed pages" + tristate "2:1 compression allocator (zbud)" + depends on ZSWAP help A special purpose allocator for storing compressed pages. It is designed to store up to two compressed pages per physical @@ -172,8 +171,8 @@ config ZBUD density approach when reclaim will be used. config Z3FOLD - tristate "Up to 3x density storage for compressed pages" - depends on ZPOOL + tristate "3:1 compression allocator (z3fold)" + depends on ZSWAP help A special purpose allocator for storing compressed pages. It is designed to store up to three compressed pages per physical @@ -181,15 +180,13 @@ config Z3FOLD still there. config ZSMALLOC - tristate "Memory allocator for compressed pages" + tristate + prompt "N:1 compression allocator (zsmalloc)" if ZSWAP depends on MMU help zsmalloc is a slab-based memory allocator designed to store - compressed RAM pages. zsmalloc uses virtual memory mapping - in order to reduce fragmentation. However, this results in a - non-standard allocator interface where a handle, not a pointer, is - returned by an alloc(). This handle must be mapped in order to - access the allocated space. + pages of various compression levels efficiently. It achieves + the highest storage density with the least amount of fragmentation. config ZSMALLOC_STAT bool "Export zsmalloc statistics" From patchwork Thu Aug 19 19:55:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 12447915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C099C43214 for ; Thu, 19 Aug 2021 19:54:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0CAE060720 for ; Thu, 19 Aug 2021 19:54:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0CAE060720 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id BE0886B0073; Thu, 19 Aug 2021 15:54:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B40CB6B0074; Thu, 19 Aug 2021 15:54:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A07526B0075; Thu, 19 Aug 2021 15:54:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0149.hostedemail.com [216.40.44.149]) by kanga.kvack.org (Postfix) with ESMTP id 866FB6B0073 for ; Thu, 19 Aug 2021 15:54:00 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 1E6371801C1A6 for ; Thu, 19 Aug 2021 19:54:00 +0000 (UTC) X-FDA: 78492881040.16.2F3F2BA Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) by imf26.hostedemail.com (Postfix) with ESMTP id C632E20019C4 for ; Thu, 19 Aug 2021 19:53:59 +0000 (UTC) Received: by mail-qv1-f44.google.com with SMTP id q6so4256994qvs.12 for ; Thu, 19 Aug 2021 12:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8+UhPfvB4V7hB7D/Na/kzqHbrTzZZtUZNRqqvxGPOUU=; b=K0GYs6I/N/DQa4Q/WBxWRF15jR9c4tavLgSYprqqRx8sBXLmwecuXtr0ZktuI+aA56 fRP3qbALBqYGJL1cNqigf9watu8Lky+IsjBKMPjmAKfmitE0ykqdFm3AtqU//7+01RVz F0l0xvl7/hdOt7vjIiLI6C7r5fk4g9Cf5KGx95pp2EMnTGNYVezI+8f2wQ/T1XRvrGHI CyvOnGgAbyhjouRzgIyOpv3qnJFnoDprs/RbZUvn123LJppNO2yO/RISOh1gOepQU2j0 EuQqrVW8kd2yOVH90bTVnpOMDiPw1Dy8qBmaUYi7Di8/ZJygsovkDayuQCeZRRDnTnye Y6sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8+UhPfvB4V7hB7D/Na/kzqHbrTzZZtUZNRqqvxGPOUU=; b=CqK6LD7tNFC/E0tf+XJ5WvBj6GtqNtJfhMcweoDjczV44BWl6kJLXQlDgSYDntB3Gq cbYMPeoqYrBWFM/PXy45cguAFbgd8QwHItMJepV5EOICZarniN0haEmL76tLgXLIKJLW qqUhBdiRE4TBXBaAZe74gjzbBCMNyR5xwL8pgJsEwYJWdDJDhjrg3a9feJUW18tYY7j8 fKOV2qt3B+tZp6FSwlpUVs5JPET09HR45Maxd25eVI9LuMz65b6OLpNqCjRgrTZLhfmQ BK8uapBO7JlEHrshsrFH34TjB0T27Msgl+XWtUkO2vipZLe3r7kCLuaDeuOhX7YCE5+M bDaA== X-Gm-Message-State: AOAM531CgQUaZdk3nUHRiiNWwPKiO+EKEHlwDM8Rk1FUeVxfQ19GkDgp vEqM5SPF6Q4oNlrCzAtMOU7G0w== X-Google-Smtp-Source: ABdhPJyGrl6h+vXHMzNA02B4FcCZPgSeu/NJ4nBm+YlvcMFckMlp5WMer3tqpLgdavYnAW1XKwWjlQ== X-Received: by 2002:a05:6214:3ca:: with SMTP id ce10mr16219837qvb.42.1629402839186; Thu, 19 Aug 2021 12:53:59 -0700 (PDT) Received: from localhost (cpe-98-15-154-102.hvc.res.rr.com. [98.15.154.102]) by smtp.gmail.com with ESMTPSA id a17sm1688738qtp.61.2021.08.19.12.53.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 12:53:58 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 4/4] mm: zswap: add basic meminfo and vmstat coverage Date: Thu, 19 Aug 2021 15:55:33 -0400 Message-Id: <20210819195533.211756-4-hannes@cmpxchg.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210819195533.211756-1-hannes@cmpxchg.org> References: <20210819195533.211756-1-hannes@cmpxchg.org> MIME-Version: 1.0 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b="K0GYs6I/"; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf26.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.219.44 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org X-Stat-Signature: ycg9pid1k7znzb6yzair4cksiu8fsqdm X-Rspamd-Queue-Id: C632E20019C4 X-Rspamd-Server: rspam05 X-HE-Tag: 1629402839-54744 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: Currently it requires poking at debugfs to figure out the size of the zswap cache size on a host. There are no counters for reads and writes against the cache. This makes it difficult to understand behavior on production systems. Print zswap memory consumption in /proc/meminfo, count zswapouts and zswapins in /proc/vmstat. Signed-off-by: Johannes Weiner Reported-by: kernel test robot --- fs/proc/meminfo.c | 4 ++++ include/linux/swap.h | 4 ++++ include/linux/vm_event_item.h | 4 ++++ mm/vmstat.c | 4 ++++ mm/zswap.c | 11 +++++------ 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c index 6fa761c9cc78..2dc474940691 100644 --- a/fs/proc/meminfo.c +++ b/fs/proc/meminfo.c @@ -86,6 +86,10 @@ static int meminfo_proc_show(struct seq_file *m, void *v) show_val_kb(m, "SwapTotal: ", i.totalswap); show_val_kb(m, "SwapFree: ", i.freeswap); +#ifdef CONFIG_ZSWAP + seq_printf(m, "Zswap: %8lu kB\n", + (unsigned long)(zswap_pool_total_size >> 10)); +#endif show_val_kb(m, "Dirty: ", global_node_page_state(NR_FILE_DIRTY)); show_val_kb(m, "Writeback: ", diff --git a/include/linux/swap.h b/include/linux/swap.h index 144727041e78..3b23c88b6a8d 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -696,6 +696,10 @@ static inline int mem_cgroup_swappiness(struct mem_cgroup *mem) } #endif +#ifdef CONFIG_ZSWAP +extern u64 zswap_pool_total_size; +#endif + #if defined(CONFIG_SWAP) && defined(CONFIG_MEMCG) && defined(CONFIG_BLK_CGROUP) extern void cgroup_throttle_swaprate(struct page *page, gfp_t gfp_mask); #else diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index ae0dd1948c2b..9dbebea09c69 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -125,6 +125,10 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, SWAP_RA, SWAP_RA_HIT, #endif +#ifdef CONFIG_ZSWAP + ZSWPIN, + ZSWPOUT, +#endif #ifdef CONFIG_X86 DIRECT_MAP_LEVEL2_SPLIT, DIRECT_MAP_LEVEL3_SPLIT, diff --git a/mm/vmstat.c b/mm/vmstat.c index cccee36b289c..31aada15c571 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1369,6 +1369,10 @@ const char * const vmstat_text[] = { "swap_ra", "swap_ra_hit", #endif +#ifdef CONFIG_ZSWAP + "zswpin", + "zswpout", +#endif #ifdef CONFIG_X86 "direct_map_level2_splits", "direct_map_level3_splits", diff --git a/mm/zswap.c b/mm/zswap.c index 20763267a219..f93a7c715f76 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -40,7 +40,7 @@ * statistics **********************************/ /* Total bytes used by the compressed storage */ -static u64 zswap_pool_total_size; +u64 zswap_pool_total_size; /* The number of compressed pages currently stored in zswap */ static atomic_t zswap_stored_pages = ATOMIC_INIT(0); /* The number of same-value filled pages currently stored in zswap */ @@ -1231,6 +1231,7 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset, /* update stats */ atomic_inc(&zswap_stored_pages); zswap_update_total_size(); + count_vm_event(ZSWAPOUT); return 0; @@ -1273,11 +1274,10 @@ static int zswap_frontswap_load(unsigned type, pgoff_t offset, zswap_fill_page(dst, entry->value); kunmap_atomic(dst); ret = 0; - goto freeentry; + goto stats; } if (!zpool_can_sleep_mapped(entry->pool->zpool)) { - tmp = kmalloc(entry->length, GFP_ATOMIC); if (!tmp) { ret = -ENOMEM; @@ -1292,10 +1292,8 @@ static int zswap_frontswap_load(unsigned type, pgoff_t offset, src += sizeof(struct zswap_header); if (!zpool_can_sleep_mapped(entry->pool->zpool)) { - memcpy(tmp, src, entry->length); src = tmp; - zpool_unmap_handle(entry->pool->zpool, entry->handle); } @@ -1314,7 +1312,8 @@ static int zswap_frontswap_load(unsigned type, pgoff_t offset, kfree(tmp); BUG_ON(ret); - +stats: + count_vm_event(ZSWAPIN); freeentry: spin_lock(&tree->lock); zswap_entry_put(tree, entry);