Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp302017iob; Thu, 28 Apr 2022 02:44:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqKsxbB991YVFJVGEw5O6UB+bNpb1IJpyo/yQpuRmufaB7OrTVP/wjGiRT0ntSZ9WQ6KdP X-Received: by 2002:a17:90b:314e:b0:1db:ea61:36b5 with SMTP id ip14-20020a17090b314e00b001dbea6136b5mr393473pjb.164.1651139055397; Thu, 28 Apr 2022 02:44:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651139055; cv=none; d=google.com; s=arc-20160816; b=DaFlsIXFhfapRud4hUqPm6tFcTEnRYGO1KUQqTQfFLjM8EY/Ga9AtNJ1evC19rQmsH EP4oK2Xr2VfpY4T7KR3FkHhIRIz1+WjdHvbQ6k3kR4qge+0FYhsyM77nAzxcIpEXtNPH Yljk21WdNF3Rp3siFz/dMixyB1bAiVOYY3AnzjG+U0uooxYRb/pDs+FApzAxjoCm4idZ V8et2bCIV89xwC8LxJfXbyE3TzN1UVaAqLvnzAsZU2/3EXmyzJTdrZoty2qXay9+IFJy s9eGGousVl5rFHYaNTuS82zb8BSjC+4wJBWITJ4dgZcbAe9+wzb4Xmt6X2W+ycBnBRds vwBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=FL5RmqjsnS96RItXhleCXY3INxI4L38U8zTk4H4kbRM=; b=uCSDw55E0cEqKlJ1BKToPBQwk0D6fyez1xqC9TEqjRRIHjIrfEi+wLVFjEbZNR8d0Y oPy0LwBT1AHar70ZnPlMnbLP1dG+F1i1P/Fh8Z8sVuCErEAkRhM1B11ERZue60chU2T0 Q9iHMK+AEnOCICx1ZuJBWPqg+zPwspKFKMwERX7YgXE/9pY57nAK4+WXWLU9UbSa30e8 elI1nRWcf9PtS9lHqyL1GVYmnPMEaRTR5/KLRBZ5Fh9SO9GR5UTdkWy5EQMQYkJe7ZsV MoDy7JXib8wNIm1ZeHRkc58PL8Ri24o36MxhA/IBlB7evnsx+PTsWI9m0JnjnM+ZGyn+ GljQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Fnjww4kT; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u24-20020a63f658000000b003aa6755ffb3si4246444pgj.574.2022.04.28.02.43.49; Thu, 28 Apr 2022 02:44:15 -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=@google.com header.s=20210112 header.b=Fnjww4kT; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229842AbiD0Xjv (ORCPT + 99 others); Wed, 27 Apr 2022 19:39:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229969AbiD0Xju (ORCPT ); Wed, 27 Apr 2022 19:39:50 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFC0F49266 for ; Wed, 27 Apr 2022 16:36:33 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id i62so2603041pgd.6 for ; Wed, 27 Apr 2022 16:36:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FL5RmqjsnS96RItXhleCXY3INxI4L38U8zTk4H4kbRM=; b=Fnjww4kTfxvDYxU1OPnCUQ05Dg7DEB2VNmgBa3iIVs1YziXLL5NPY22PxqWXh7lRlB 8vuXugqSz74/dVRL6IV85uoBkg1Axric6AIQ3KCnilEj1X6Rj1CCpiY1X8QSqFEDtLjL x0EE+oQBe8Dvrs0rULZGjGplV+5cDIqQ7DQh2uofwdi1gqfXibZiQZSWhIX6812SQDV0 ooiysKmKTdtVuGN7sNGxHt52RH6aaUff+q46TbfeovpbaLTjLAzpyfjWwLcRjtDoU3Za xFMGzikPBEx43dvuCJzWa0IU2IwO8irzQo5Ik4kcOU1/KW/jP+bE1ULp+1XD6wXL12nD 7wHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FL5RmqjsnS96RItXhleCXY3INxI4L38U8zTk4H4kbRM=; b=d+SmtSNGfFmh37McKvPtvS5mwnDn7TheQ2M9ddLrXvXoiZRRQUa/rtvPJqRuqgR5Ex bcRbQiKOoFaM13rpnw5Y5Z5TA/fkYE9frWykrsyi2/yJOHBZ6v7tJD5K1qDAnO/1W2GW QKtrL0XVHqnPO+a0zM4PFUOz/G+j/62gRTUG1pVxf5uFrLCaxQAUOJIsO2hBp8f7WyVM jErtSMwny8YGwGZx0WjxAmvtJ456psaJHTnXnEOouVkpSv040cOY13zKfXaAcsZORBo9 E+sraRsk/GejC7PJVhHZDTwTHND7prN/yipoX7+GwvAxYlbbrSIg5oSkAbLwyCPyYEGc sCoA== X-Gm-Message-State: AOAM532fX4kwRY9PceAgDgv85rr1H9zXFxQX5tzBUeiPkuG6yeBLuIby GwVoJXuM1QIdPhrnBzTdvUen/brzjwiDSa/DG9IXg0x87M4= X-Received: by 2002:a63:9502:0:b0:386:3916:ca8e with SMTP id p2-20020a639502000000b003863916ca8emr25446320pgd.357.1651102592948; Wed, 27 Apr 2022 16:36:32 -0700 (PDT) MIME-Version: 1.0 References: <20220427160016.144237-1-hannes@cmpxchg.org> <20220427160016.144237-5-hannes@cmpxchg.org> In-Reply-To: From: Shakeel Butt Date: Wed, 27 Apr 2022 16:36:22 -0700 Message-ID: Subject: Re: [PATCH 4/5] mm: zswap: add basic meminfo and vmstat coverage To: Johannes Weiner Cc: Minchan Kim , Andrew Morton , Michal Hocko , Roman Gushchin , Seth Jennings , Dan Streetman , Linux MM , Cgroups , LKML , Kernel Team Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 Wed, Apr 27, 2022 at 3:32 PM 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. > > Could you shed some light? > I can shed light on the datacenter workloads. We use cgroup (still on v1) and zswap. For the workloads/applications, the swap (or zswap) is transparent in the sense that they are charged exactly the same irrespective of how much their memory is zswapped-out. Basically the applications see the same usage which is actually v1's memsw.usage_in_bytes. We dynamically increase the swap size if it is low, so we are not really worried about one job hogging the swap space. Regarding stats we actually do have them internally representing compressed size and number of pages in zswap. The compressed size is actually used for OOM victim selection. The memsw or v2's swap usage in the presence of compression based swap does not actually tell how much memory can potentially be released by evicting a job. For example if there are two jobs 'A' and 'B'. Both of them have 100 pages compressed but A's 100 pages are compressed to let's say 10 pages while B's 100 pages are compressed to 70 pages. It is preferable to kill B as that will release 70 pages. (This is a very simplified explanation of what we actually do).