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 E9F5CC433F5 for ; Thu, 28 Apr 2022 17:02:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 74A938D0013; Thu, 28 Apr 2022 13:02:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F9A48D000F; Thu, 28 Apr 2022 13:02:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 59A3C8D0013; Thu, 28 Apr 2022 13:02:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 4A3DB8D000F for ; Thu, 28 Apr 2022 13:02:51 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E043F62B91 for ; Thu, 28 Apr 2022 17:02:50 +0000 (UTC) X-FDA: 79406907342.11.F744C3F Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by imf29.hostedemail.com (Postfix) with ESMTP id 138AB120082 for ; Thu, 28 Apr 2022 17:02:46 +0000 (UTC) Received: by mail-pg1-f174.google.com with SMTP id q12so4450376pgj.13 for ; Thu, 28 Apr 2022 10:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=1sufCTYCLbGKk0BAZFmsNvzFa0UhjdUJOvJQoQRI648=; b=cBQg+ifk+oeqvEyzYXxBdQYlVT+tzlR+9BrZGKEuW1gu6RNFA0OdJ8627DwDqOCV+R LEXmub0Ru5JIlBhic3IoSI4y8nuQOP/KMm3LvUpqpunN4KyxQDjHkzK4RrOgh1JIgKl7 /cCyYzWluaoh0m+ZSve3a1+DQtZkMFgAWT4ULTeHiYGhrRGIQ3vDV1kUkSIyt/0dWcyC FznWnfA5GRq83HqEa+fyH9AOB5a6bD02zK6CIPbQBFxYTxj3iQWSRE0rmUDZeV2LRBeT juJpoPlOkxgcljlhz+BwZLgRoLIKhH6chNAvGHTiJHljY5fV3BosUyyGoNLO75lL5+Vx fXrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=1sufCTYCLbGKk0BAZFmsNvzFa0UhjdUJOvJQoQRI648=; b=NyqsYl9TLTgJgue2XhAVosKMGhaDcbm9+FlnB6oqCsY73YVT+c4WDsMnwWUR5R5YiG iPgV47shcFqCqfKZ3eHKr0bsxCzCyzuye7NRwT4V1DH0gRywtHu9ntrQDxhguRojj53z +o67ApaAhvw+qqUp6cjBzBHeqEpJjyqWS79F0MyayUo7p5RM6yKQMWpRfJ/uD0bffKUL d/PRhlTk6E9Vthm0iM6iDpH8EzwdKlWo/tsHy0wgEyu5x7UzOCiQ+sfnx+BSuG7E9oaz DC6F4S3Uns1L+lCEeMRRIubVnalOVqrai5kjVJQii6/BPiHxrGFNPNWa5SnCeJzCzQUS nXKg== X-Gm-Message-State: AOAM530Xo193Hjz3dvLb9arQXbydmYKf+XvOhP3uQKzMCNzkzqtO2stz j2vy+ga1/LmoartAPLXf2bY= X-Google-Smtp-Source: ABdhPJwbDxlnYtnl8vL56MtbmsRjUBKiRSOhIqzNEUzjC44cNYgYGSeTeWJ+M3Qory86KG5Ni1+fsQ== X-Received: by 2002:a63:f058:0:b0:3c1:42e9:eb40 with SMTP id s24-20020a63f058000000b003c142e9eb40mr8323765pgj.236.1651165369227; Thu, 28 Apr 2022 10:02:49 -0700 (PDT) Received: from google.com ([2620:15c:211:201:dc95:713b:f72c:4ad4]) by smtp.gmail.com with ESMTPSA id y3-20020a17090abd0300b001cd630f301fsm11132285pjr.36.2022.04.28.10.02.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Apr 2022 10:02:48 -0700 (PDT) Date: Thu, 28 Apr 2022 10:02:46 -0700 From: Minchan Kim To: Johannes Weiner Cc: Andrew Morton , Michal Hocko , Roman Gushchin , Shakeel Butt , Seth Jennings , Dan Streetman , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH 4/5] mm: zswap: add basic meminfo and vmstat coverage Message-ID: References: <20220427160016.144237-1-hannes@cmpxchg.org> <20220427160016.144237-5-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: 6g6khatfimpjow53sozfwmxbfe83659y Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=cBQg+ifk; spf=pass (imf29.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 138AB120082 X-HE-Tag: 1651165366-379008 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 Thu, Apr 28, 2022 at 10:05:13AM -0400, Johannes Weiner wrote: > On Wed, Apr 27, 2022 at 03:12:17PM -0700, Minchan Kim wrote: > > On Wed, Apr 27, 2022 at 05:36:26PM -0400, Johannes Weiner wrote: > > > On Wed, Apr 27, 2022 at 05:20:31PM -0400, Johannes Weiner wrote: > > > > On Wed, Apr 27, 2022 at 01:29:34PM -0700, Minchan Kim wrote: > > > > > Hi Johannes, > > > > > > > > > > On Wed, Apr 27, 2022 at 12:00:15PM -0400, Johannes Weiner wrote: > > > > > > Currently it requires poking at debugfs to figure out the size and > > > > > > population of the zswap cache on a host. There are no counters for > > > > > > reads and writes against the cache. As a result, it's difficult to > > > > > > understand zswap behavior on production systems. > > > > > > > > > > > > Print zswap memory consumption and how many pages are zswapped out in > > > > > > /proc/meminfo. Count zswapouts and zswapins in /proc/vmstat. > > > > > > > > > > > > Signed-off-by: Johannes Weiner > > > > > > --- > > > > > > fs/proc/meminfo.c | 7 +++++++ > > > > > > include/linux/swap.h | 5 +++++ > > > > > > include/linux/vm_event_item.h | 4 ++++ > > > > > > mm/vmstat.c | 4 ++++ > > > > > > mm/zswap.c | 13 ++++++------- > > > > > > 5 files changed, 26 insertions(+), 7 deletions(-) > > > > > > > > > > > > diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c > > > > > > index 6fa761c9cc78..6e89f0e2fd20 100644 > > > > > > --- a/fs/proc/meminfo.c > > > > > > +++ b/fs/proc/meminfo.c > > > > > > @@ -86,6 +86,13 @@ 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)); > > > > > > + seq_printf(m, "Zswapped: %8lu kB\n", > > > > > > + (unsigned long)atomic_read(&zswap_stored_pages) << > > > > > > + (PAGE_SHIFT - 10)); > > > > > > +#endif > > > > > > > > > > I agree it would be very handy to have the memory consumption in meminfo > > > > > > > > > > https://lore.kernel.org/all/YYwZXrL3Fu8%2FvLZw@google.com/ > > > > > > > > > > If we really go this Zswap only metric instead of general term > > > > > "Compressed", I'd like to post maybe "Zram:" with same reason > > > > > in this patchset. Do you think that's better idea instead of > > > > > introducing general term like "Compressed:" or something else? > > > > > > > > I'm fine with changing it to Compressed. If somebody cares about a > > > > more detailed breakdown, we can add Zswap, Zram subsets as needed. > > > > > > It does raise the question what to do about cgroup, though. Should the > > > control files (memory.zswap.current & memory.zswap.max) apply to zram > > > in the future? If so, we should rename them, too. > > > > > > I'm not too familiar with zram, maybe you can provide some > > > background. AFAIU, Google uses zram quite widely; all the more > > > confusing why there is no container support for it yet. > > > > My usecase with zram is Android which doesn't use memcg. > > Ok. > > After more thought, my take is that in the future it could make sense > to track zram pages in a cgroup's memory.current. But it should NOT be > included in the dedicated memory.zswap.* files. Zswap is an in-kernel > writeback cache, and those files allow userspace to tune writeback > thresholds depending on the composition of the workload's > workingset. This doesn't translate to zram: the wb facility that it > has is triggered by hand, based on criteria such as idle pages and > compression rate. It's not based on size. From a cgroup POV, it's a > memory consumer that should be subject to memory.max, nothing more. > > This distinction applies to meminfo as well, though. While I think it > makes sense to have a combined "Compressed" counter for zram and > zswap, it's still important to understand zswap behavior on its own to > tune the system-wide writeback threshold in max_pool_percent. (And > again, while zram can also be limited, it's not a writeback threshold, > it's just a red line for returning -ENOMEM). > > So I'm going to keep the Zswap and Zswapped items and retract the > delta patch for renaming it to Compressed. > > But I'd ack a patch that adds a combined "Compressed" counter for zram > + zswap if you send it, Minchan. If we really want to go separate stat for zswap and zram, it would be better to use direct name "Zram: " instead of comrpessed.