Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1300649iob; Fri, 29 Apr 2022 02:14:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUtAfVUgMu7nxidVrWc7joMBlys1tnziAm8xHKS11G8kdjXuH8Ux5wgwl0Z50sDrR1P8aM X-Received: by 2002:a2e:80d1:0:b0:24f:77a:c7c6 with SMTP id r17-20020a2e80d1000000b0024f077ac7c6mr19335327ljg.200.1651223673202; Fri, 29 Apr 2022 02:14:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651223673; cv=none; d=google.com; s=arc-20160816; b=c2WE/U7FSSqJoqxjxjcqpS2KH08Bdwy9ENt6GDTYhJ9F+ut3oEb3EYY0Uzkub8HXvz kgRj2OS0tUZAbAF+4JTbGIRVS8TmpQrDmXQbHvnK446pkb/pWtEFC8VQryqq0sAKbr4T arp6PgSabsiv9BHhrFindz6FjlVsdWTEB6Qtx14vXLy9fwEv++OPTUDSQGgZrX3rVocu T+gnOGh5om8IxKP5B03BJqOk0lJyhb+v3ledegBKSw81lDrhzmE8FqDPXQWTSiqHMk1W e/8a157RXmJHrJ1+P5Yi/zKRVHFTMP8sxrra58Ag0sY7yUsSDiP3zZSSaRyhVMdLHd8N oOSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=1sufCTYCLbGKk0BAZFmsNvzFa0UhjdUJOvJQoQRI648=; b=Gr11Y69ihYpc/myjQ564FIMPgUk7fDcmfvnZaEvhdxGc090RXp+VarqaoPsGQSsrjk 78BT8DGYKuQ87JPTTA/MfmZrwRv3SfxxujG3oyYB9435d2QbqqHmZk5LeBRl0aB3Yrkt pEs+miur5JSPPM42S6g9Eq5TtM4M8VES60QYKoNLVour/lZjAitHa5CtHE+hSTDCSLBx juAsEbyLxkrdYRa5ZLvrXteIq+jjyG7IkjHzUzQQf2NQpvd3yZ54soJ7acxQQUR8tfio SmHf1+AGxMGym4BToHSwf2t5RUjuwk/9qLUtHjoRy+4mRCUWqmiittb2TrbVDLlx16Bh UfWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cBQg+ifk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e9-20020a2e9e09000000b0024f0fddf137si6577981ljk.518.2022.04.29.02.14.05; Fri, 29 Apr 2022 02:14:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cBQg+ifk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350446AbiD1RGF (ORCPT + 99 others); Thu, 28 Apr 2022 13:06:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234392AbiD1RGE (ORCPT ); Thu, 28 Apr 2022 13:06:04 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDB8119011; Thu, 28 Apr 2022 10:02:49 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id v10so4455999pgl.11; 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=Sbd0/VmR4NsQD4N20MgFNy4yo8ZIhilwAxOLinfyr7uaXgJ+hhx+hPFmPFbPtvj8ng zzeXXfSCGgSwufK8vnX+vkV9tH1JC1rEdvrUqqJBpRptchybAr/qdJok1BUMPyMGsOhm 56dakRaNavvGXo9WQD5o5FtY2MudNm28zWRmXcchXIAcYrpuxHma14NiyPxt5D36IRbs xq+XhW9zUDkIJneFPnC0mik13CeW2Hs8w/uvdNaeVO917/wZCg8u1i5m0nJrFLfTXuDG o0g930rFu+ni1ZeeEjqRh9lyODzckKYvLU2756g6X4ceGI5ybF0nUF4Shq8N2gkUpVlI uFEg== X-Gm-Message-State: AOAM532FqR6db5qPTMTEJUCWTU0YFgjuce2leGwZm2FmYIfoiD7DCyii XNfQd1FydJEWoAEFD6GpJjCZkAuJxY0= 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) Sender: Minchan Kim 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-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.