Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3471339rdg; Tue, 17 Oct 2023 16:35:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHKVYpuISyTSsy/KMtdR+M5uWOOoLwd29zlKKtXrZbqYBQbo3au2xOJNmf5FzvDcbcIstyd X-Received: by 2002:a17:903:41d1:b0:1c5:7d49:570e with SMTP id u17-20020a17090341d100b001c57d49570emr4042697ple.29.1697585758502; Tue, 17 Oct 2023 16:35:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697585758; cv=none; d=google.com; s=arc-20160816; b=hCxiX4MjrAvS1u1X0td2GQmYQJ6q0NLh7FpaLV2SF0xY7fDUlUTpBximAUz1ixaKHo GTasqgpAIMw8QX4CEimMRHrc/B84g1yj4BLwW4+R0ndADDCP1nL+NUECPvyhRKi7+NNf IHKC9a+AnWg42/myu4NZly8Nl7W7zt9jYqnCAAbOqQk18yiGCMn9zwXEtlO15KvIuBmc 4Tkltb4Rz9yeL3gWH6hfkrddxOcb9M/MOPJNK4/XCWxwBTa8dXRzd406SiWcpbGWrwdk btv7C6PfaNTOU3ubvYiQ6LyWR/Cl1RoYuvw9trBeFzqKGO1JGNRF4QRNrcn8kkK2e7Ua o+yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=tdTkOsSZlVefGaBdezW5bHhWJDivZZTWywSdxQVCUN4=; fh=ujhzRoGvNYK+acFkUTmqZhWNw+cNDLTLaE+W0yhRAuE=; b=aSa2g8U1Vju2e97ZreW7B2wG9cW+A6X0jOUJ8fYb3e9siFOmSVoTEYMGYM9DrjPzya Mf2/EO9NR/iP77ZgGcN9KbGILDMN0LrngwX5lV9iWEY6K2wSXM1Je67Y0JPwsl1u6O3o RoQt6xdv+p5z4IyYBaJVt2myfbkKYRO0hZ3fbRESOzOGDYJldkyKmbJ//YV4SnUNDw1a UIm8aGfudaR1OiLobyUtV/0Ul0mONNbGXyfoDQsmw0XRXp61BdNJRQE1XqYTkHBz9tEv PsQsbymm7epIfIexQxWl26aa4yzNE+pTNTd6xXbhMedv4DnLuazbYrUuCCVRfAUVf/bB zjtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ClogTTP2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id 21-20020a170902c11500b001bdca6456c3si2590871pli.46.2023.10.17.16.35.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 16:35:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ClogTTP2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 28FE0806A609; Tue, 17 Oct 2023 16:35:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344010AbjJQXfa (ORCPT + 99 others); Tue, 17 Oct 2023 19:35:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234793AbjJQXf2 (ORCPT ); Tue, 17 Oct 2023 19:35:28 -0400 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCD1F92; Tue, 17 Oct 2023 16:35:26 -0700 (PDT) Received: by mail-il1-x12e.google.com with SMTP id e9e14a558f8ab-357a354e616so459015ab.1; Tue, 17 Oct 2023 16:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697585726; x=1698190526; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=tdTkOsSZlVefGaBdezW5bHhWJDivZZTWywSdxQVCUN4=; b=ClogTTP278oipxTPG9O7Cg50jfqHyHDmJ539pX7Qpn8I1sJ+za8PStycD9RJZ0ZxTt S+xgXkPak20IVtZs5+8uQTbQZTZalCkNnK8XlN9Ama67Dtnx+ArUeVFijxtpKwmnCzT/ nqhqVfEfg80t5r1Lze4rdsIjDd30W+d2GTI4Gy7rhB3r4C2VPc2k5XugMy1HmuuXk2fu VZiBWrhFoV/VKZ1w4KnXOG7Ens4kXORVM9vRdaPM0E3ka8OC7UZrlQGuRQHzPTiujj97 6e6uV8bdN4ksFkpRSQ0S733DKpttHGr1zRCnff02xW0TYLrmwa3kVqpXik3QCngoA/HB Njng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697585726; x=1698190526; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tdTkOsSZlVefGaBdezW5bHhWJDivZZTWywSdxQVCUN4=; b=Ib8+16QNMpQE4JDexPBPuebZKtFXOLRImLSTzn4QK6wM3pbClmjcJh0bdilXogsUcE /72Xsfkz9NuAvLrWRkmBLvkvJhAziwwayjCaDqW0Uqf8C7Ma34glISrzaLJBVelNUpK5 WJd8A33hVrd43mOnK5j+cbXPQ5txugwBMc4y3SP0NNCEkjgxBpnTPltuvB4+NYZy5flw XBsvQfG8k17WBKQFkgxKwsPkRAO+v25643zTyuNWN1EWmdHY7qAvU0d6l063pmuX7bgg dvUc32duGRUpxufex0rlS8k1TKOC9t2ZUMnN3lKfXeEhT3YYXvouzNM2w1Xgu9qbgLfJ SC8Q== X-Gm-Message-State: AOJu0YzVc77N3kg23Ua2RNLrxQ32GB6esbKJOSYfFCFrfylMmcqyB62J vvzxuAULZ+HtWzx8kaifs/esKHKdW74rs8UYUeo= X-Received: by 2002:a05:6e02:3205:b0:351:375f:2a31 with SMTP id cd5-20020a056e02320500b00351375f2a31mr3101949ilb.6.1697585726148; Tue, 17 Oct 2023 16:35:26 -0700 (PDT) MIME-Version: 1.0 References: <20231017232152.2605440-1-nphamcs@gmail.com> <20231017232152.2605440-4-nphamcs@gmail.com> In-Reply-To: <20231017232152.2605440-4-nphamcs@gmail.com> From: Nhat Pham Date: Tue, 17 Oct 2023 16:35:13 -0700 Message-ID: Subject: Re: [PATCH v3 3/5] mm: memcg: add per-memcg zswap writeback stat To: akpm@linux-foundation.org Cc: hannes@cmpxchg.org, cerasuolodomenico@gmail.com, yosryahmed@google.com, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com, mhocko@kernel.org, roman.gushchin@linux.dev, shakeelb@google.com, muchun.song@linux.dev, linux-mm@kvack.org, kernel-team@meta.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, shuah@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 17 Oct 2023 16:35:38 -0700 (PDT) On Tue, Oct 17, 2023 at 4:21=E2=80=AFPM Nhat Pham wrote= : > > From: Domenico Cerasuolo > > Since zswap now writes back pages from memcg-specific LRUs, we now need a > new stat to show writebacks count for each memcg. > > Suggested-by: Nhat Pham > Signed-off-by: Domenico Cerasuolo > Signed-off-by: Nhat Pham /s/Signed-off/Acked This is Domenico's work :) I used the wrong tag here. Should be: Acked-by: Nhat Pham > --- > include/linux/memcontrol.h | 2 ++ > mm/memcontrol.c | 15 +++++++++++++++ > mm/zswap.c | 3 +++ > 3 files changed, 20 insertions(+) > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index 3de10fabea0f..7868b1e00bf5 100644 > --- a/include/linux/memcontrol.h > +++ b/include/linux/memcontrol.h > @@ -38,6 +38,7 @@ enum memcg_stat_item { > MEMCG_KMEM, > MEMCG_ZSWAP_B, > MEMCG_ZSWAPPED, > + MEMCG_ZSWAP_WB, > MEMCG_NR_STAT, > }; > > @@ -1884,6 +1885,7 @@ static inline void count_objcg_event(struct obj_cgr= oup *objcg, > bool obj_cgroup_may_zswap(struct obj_cgroup *objcg); > void obj_cgroup_charge_zswap(struct obj_cgroup *objcg, size_t size); > void obj_cgroup_uncharge_zswap(struct obj_cgroup *objcg, size_t size); > +void obj_cgroup_report_zswap_wb(struct obj_cgroup *objcg); > #else > static inline bool obj_cgroup_may_zswap(struct obj_cgroup *objcg) > { > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 1bde67b29287..a9118871e5a6 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -1505,6 +1505,7 @@ static const struct memory_stat memory_stats[] =3D = { > #if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_ZSWAP) > { "zswap", MEMCG_ZSWAP_B }= , > { "zswapped", MEMCG_ZSWAPPED }= , > + { "zswap_wb", MEMCG_ZSWAP_WB }= , > #endif > { "file_mapped", NR_FILE_MAPPED }= , > { "file_dirty", NR_FILE_DIRTY }= , > @@ -1541,6 +1542,7 @@ static int memcg_page_state_unit(int item) > switch (item) { > case MEMCG_PERCPU_B: > case MEMCG_ZSWAP_B: > + case MEMCG_ZSWAP_WB: > case NR_SLAB_RECLAIMABLE_B: > case NR_SLAB_UNRECLAIMABLE_B: > case WORKINGSET_REFAULT_ANON: > @@ -7861,6 +7863,19 @@ void obj_cgroup_uncharge_zswap(struct obj_cgroup *= objcg, size_t size) > rcu_read_unlock(); > } > > +void obj_cgroup_report_zswap_wb(struct obj_cgroup *objcg) > +{ > + struct mem_cgroup *memcg; > + > + if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) > + return; > + > + rcu_read_lock(); > + memcg =3D obj_cgroup_memcg(objcg); > + mod_memcg_state(memcg, MEMCG_ZSWAP_WB, 1); > + rcu_read_unlock(); > +} > + > static u64 zswap_current_read(struct cgroup_subsys_state *css, > struct cftype *cft) > { > diff --git a/mm/zswap.c b/mm/zswap.c > index d2989ad11814..15485427e3fa 100644 > --- a/mm/zswap.c > +++ b/mm/zswap.c > @@ -704,6 +704,9 @@ static enum lru_status shrink_memcg_cb(struct list_he= ad *item, struct list_lru_o > } > zswap_written_back_pages++; > > + if (entry->objcg) > + obj_cgroup_report_zswap_wb(entry->objcg); > + > /* > * Writeback started successfully, the page now belongs to the > * swapcache. Drop the entry from zswap - unless invalidate alrea= dy > -- > 2.34.1