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 709C0C433F5 for ; Thu, 28 Apr 2022 17:24:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A4048D000F; Thu, 28 Apr 2022 13:23:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9531A6B00BC; Thu, 28 Apr 2022 13:23:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F3D98D000F; Thu, 28 Apr 2022 13:23:59 -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 698B56B00BB for ; Thu, 28 Apr 2022 13:23:59 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4AB0421A6A for ; Thu, 28 Apr 2022 17:23:59 +0000 (UTC) X-FDA: 79406960598.03.741B2F7 Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) by imf31.hostedemail.com (Postfix) with ESMTP id A44C220060 for ; Thu, 28 Apr 2022 17:23:48 +0000 (UTC) Received: by mail-qt1-f178.google.com with SMTP id p4so3426470qtq.12 for ; Thu, 28 Apr 2022 10:23:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=9SmhuH9L8EteTfK00zaW2y4ppXf8qMlwYgDRccWGmt8=; b=muYbbgHfo9WGJ1lQRYahawpH/mrMNBfK7mzuL6u28IeAbj+iYGwzrcpKpmnim+KBUZ 5zkJFG9NzPq3+fKpOGZOAOCrXhf1wnatHjmKIAJUsMQs5U0pugjuVBY2Z7AgfvG4w+UV GwUMTlFqZrpnjMRWFeuK056BahnHxRCPKIVERaYT1ttVL6koUM8tI9eLPPI8y6nh9S2h MsMQWashOIjoU1ALQwCGF9oKu1uSxRIMYVl11VzzxDSKsalcUzJEheKrtsHyEtXmJG40 tJ3Xv6dwPjHqkXwnMbRYE8iYiEZDw1H010FE9plnpaCbA12V/gFpErMKMqYXYn3TC5FN UvwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=9SmhuH9L8EteTfK00zaW2y4ppXf8qMlwYgDRccWGmt8=; b=wlfSUWEqHpRjMjrQTkhVSavUzYFqquBfO4vwGstpZdrn+FVyN64KwYf64tQ3OKxn+a A0YlTfK2aMvixPMxg8b+ggeFeGaaDzbwKXXmlKeTCvFrbe7cB6XAl7TDhJ+DL2ZTFFRw CFSTf4F7j/5cEAERGzdlstGHoUz5XVCe309G9054+Bdud49N69vcoIsY6TOw7G/5CwhJ o9nVqzcI1Crl7rAPdB+xZ/qAekLXntHHcaDXav6XVn6z+rvH4OP4bdglmcJEd4q++ZIa UWUZ8KqXr5k3Fm5VlCh937iD+s/Nzx8r7cbehPres1sBCIniZkFfZaAGKXb74EuYlnRo ALAg== X-Gm-Message-State: AOAM533H9SVZ4q1fL/4XcVtKw6Gy0iSP4vIohpYBCKLJb5svcrPcdoGW AfStaLzGoDlKjH+f70combpAbQ== X-Google-Smtp-Source: ABdhPJwPBY/yZrmknEwO4veeRiADb88VVdN+HFu5zetzKWqgqCrSrcG/aNqmjS33EJPEa7e9C7+Xgw== X-Received: by 2002:ac8:6ce:0:b0:2f0:29dd:bbc5 with SMTP id j14-20020ac806ce000000b002f029ddbbc5mr24591969qth.216.1651166637780; Thu, 28 Apr 2022 10:23:57 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:d588]) by smtp.gmail.com with ESMTPSA id y13-20020a05622a164d00b002f1ff52c518sm337931qtj.28.2022.04.28.10.23.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Apr 2022 10:23:57 -0700 (PDT) Date: Thu, 28 Apr 2022 13:23:21 -0400 From: Johannes Weiner To: Minchan Kim 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-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: A44C220060 Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=muYbbgHf; spf=pass (imf31.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.178 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org X-Rspam-User: X-Stat-Signature: 9goj3a57yzz9u1mf6o6tjog4a3qahyiy X-HE-Tag: 1651166628-287691 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 09:59:53AM -0700, Minchan Kim wrote: > On Thu, Apr 28, 2022 at 10:25:59AM -0400, Johannes Weiner wrote: > > On Wed, Apr 27, 2022 at 03:16:48PM -0700, Minchan Kim wrote: > > > On Wed, Apr 27, 2022 at 05:20:29PM -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. > > > > > > Thanks! Please consider ZSWPIN to rename more general term, too. > > > > That doesn't make sense to me. > > > > Zram is a swap backend, its traffic is accounted in PSWPIN/OUT. Zswap > > is a writeback cache on top of the swap backend. It has pages > > entering, refaulting, and being written back to the swap backend > > (PSWPOUT). A zswpout and a zramout are different things. > > Think about that system has two swap devices (storage + zram). > I think it's useful to know how many swap IO comes from zram > and rest of them are storage. Hm, isn't this comparable to having one swap on flash and one swap on a rotating disk? /sys/block/*/stat should be able to tell you how traffic is distributed, no? What I'm more worried about is the fact that in theory you can stack zswap on top of zram. Consider a fast compression cache on top of a higher compression backend. Is somebody doing this now? I doubt it. But as people look into memory tiering more and more, this doesn't sound entirely implausible. If the stacked layers then share the same in/out events, it would be quite confusing. If you think PSWPIN/OUT and per-device stats aren't enough, I'm not opposed to adding zramin/out to /proc/vmstat as well. I think we're less worried there than with /proc/meminfo. I'd just prefer to keep them separate from the zswap events. Does that sound reasonable?