From patchwork Tue May 10 15:28:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 12845158 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 B8640C433EF for ; Tue, 10 May 2022 15:29:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D17836B0071; Tue, 10 May 2022 11:29:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CC5DD6B0073; Tue, 10 May 2022 11:29:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B66166B0074; Tue, 10 May 2022 11:29:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A244B6B0071 for ; Tue, 10 May 2022 11:29:49 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 7F0A8617C8 for ; Tue, 10 May 2022 15:29:49 +0000 (UTC) X-FDA: 79450218498.31.50D19AC Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) by imf11.hostedemail.com (Postfix) with ESMTP id 1118340096 for ; Tue, 10 May 2022 15:29:43 +0000 (UTC) Received: by mail-qk1-f176.google.com with SMTP id k8so8300685qki.8 for ; Tue, 10 May 2022 08:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=FOe0QpIsq707T7oDbRf/pCSk/0RB38He1yJY5ChwDp8=; b=aIpZsyJf5arHu4Vr+y4gUngRQHnYs8ayU/4r6iHRz9x7KLZYtVJa7rzJAZVGmnN4Z3 fYqgefyNWghW0QllgfeEfAYaJuJVbjjrbIfAvLTM4KICsEiX8VT2m1BDJ8eqgfANQddd 1SS/KGzOfRACH29I2AkLAFUy9+7ibARRraCxVzuWayfHm0AhiyPNOL5p7+fFQSkziMaw BZjovDcs3K6cvmWvNL+GRHlhtldCWF65/b1GyAeIX0vlNUFoIWQUAfKs9JOeCPMCv7SX fy8df3gGpt6SG3JJ1yFO8DlhdGXLeMqt/Rawi0Dv+Z0qXe4nlEgaBobxeUeHzK86LEh/ NJoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=FOe0QpIsq707T7oDbRf/pCSk/0RB38He1yJY5ChwDp8=; b=jOt9pXtm/x+X4HLMoY28IugzK9lip3KvO/wLd7LdAZkF4YLDlMoTZoRuKCkEQ2d+r+ qutV+35C2w6+NFSnHtYJtz0rnO8NDAClF+55Uu/Y8ndocXafD6u5SuEEJMJoEhdFCAiA Q4vmeQ1A0Yqva3yHE398ziGSoM0kSmHIgl8yC07ZtCGSiH3n3alWBbx1atwLFyHz+1G7 3OvIjwbQINM9BKCU20sXJ5jbnsEe56Iu8kUkIgcQW1gkkEfwBO8N5gbysGbbHxlFAMBz NOtFrN3fOuYUolL5YwsB91ms+LHZPcT94BRKEgczDJoqLKAnTWFqAo/jnAZWjyj+EK8w JHPg== X-Gm-Message-State: AOAM532PHb64RaNnDVp5pbKzekHj+XItyazIu0b+iMgmX6QjAmBNW1jO W86gQfUWNBd9pglzfMikzbXtvA== X-Google-Smtp-Source: ABdhPJz7P4w38kJJscJ6fsGKxsfaMwr8NNE5cJTqRO1jGuOjYPzOH30aSGiRTwfV4Gye4m4oDorByg== X-Received: by 2002:a05:620a:cd7:b0:69f:b1a7:d1eb with SMTP id b23-20020a05620a0cd700b0069fb1a7d1ebmr15562058qkj.5.1652196588031; Tue, 10 May 2022 08:29:48 -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 l1-20020ae9f001000000b0069fd35d2abcsm8811440qkg.112.2022.05.10.08.29.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 08:29:47 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: Michal Hocko , Roman Gushchin , Shakeel Butt , Seth Jennings , Dan Streetman , Minchan Kim , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 0/6] zswap: accounting & cgroup control Date: Tue, 10 May 2022 11:28:41 -0400 Message-Id: <20220510152847.230957-1-hannes@cmpxchg.org> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Stat-Signature: mzg359f5y93g5xz1378racsx4kqh4tcd Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=aIpZsyJf; spf=pass (imf11.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.176 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 1118340096 X-HE-Tag: 1652196583-803157 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: Changelog - Refresh and update meminfo documentation (Andrew) - Discussions around stat sharing opportunities with zram. But agreed that zswap is a cache and zram a backend that could theoretically be stacked, so they need to be understandable separately. (Minchan) Overview Zswap can consume nearly a quarter of RAM in the default configuration, yet it's neither listed in /proc/meminfo, nor is it accounted and manageable on a per-cgroup basis. This makes reasoning about the memory situation on a host in general rather difficult. On shared/cgrouped hosts, the consequences are worse. First, workloads can escape memory containment and cause resource priority inversions: a lo-pri group can fill the global zswap pool and force a hi-pri group out to disk. Second, not all workloads benefit from zswap equally. Some even suffer when memory contents compress poorly, and are better off going to disk swap directly. On a host with mixed workloads, it's currently not possible to enable zswap for one workload but not for the other. This series implements the missing global accounting as well as cgroup tracking & control for zswap backing memory: - Patch 1 refreshes the very out-of-date meminfo documentation in Documentation/filesystems/proc.rst. - Patches 2-4 clean up related and adjacent options in Kconfig. Not actual dependencies, just things I noticed during development. - Patch 5 adds meminfo and vmstat coverage for zswap consumption and activity. - Patch 6 implements per-cgroup tracking & control of zswap memory. Based on v5.18-rc4-mmots-2022-04-26-19-34-5-g5e1fdb02de7a. Documentation/admin-guide/cgroup-v2.rst | 21 ++ Documentation/filesystems/proc.rst | 161 +++++---- drivers/block/zram/Kconfig | 3 +- fs/proc/meminfo.c | 7 + include/linux/memcontrol.h | 54 +++ include/linux/swap.h | 5 + include/linux/vm_event_item.h | 4 + init/Kconfig | 123 ------- mm/Kconfig | 523 +++++++++++++++++++----------- mm/memcontrol.c | 196 ++++++++++- mm/vmstat.c | 4 + mm/zswap.c | 50 ++- 12 files changed, 753 insertions(+), 398 deletions(-)