From patchwork Mon Nov 27 23:45:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nhat Pham X-Patchwork-Id: 170505 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp3550874vqx; Mon, 27 Nov 2023 15:46:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IEtRzE4mfttikIAgFXGoDNHqUln6sLF+pJuzx+jmoKJOInsy0oYHoqtjgVpsrKaTrMVVoQr X-Received: by 2002:a05:6a20:938b:b0:180:ebec:da1e with SMTP id x11-20020a056a20938b00b00180ebecda1emr15769709pzh.21.1701128792438; Mon, 27 Nov 2023 15:46:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701128792; cv=none; d=google.com; s=arc-20160816; b=KI3ooI2PKu9iup14UiXfHpTMVd6tjCmAE6Svrdczlotzp+VKQLyQwXW66uUKK8WFI1 fiNH3i8NwZN9rnJ90zLktFITV8FmNns6gpVzi/qUgj9xIAjYVigMLftKM7a73wgqCh9R 3PWBs+RfZRSzlowdnYNwA4TDryrUR0mLmvtsO10gJ/cf0Epx0u1DN4cGVLVxIlho/Apv ilqUJpBVwmhmvFmtBC0ZAdTeyvS8VO6RzUuSk7OxgLPzmy77zA2NHyZgkAGTWDQRNGaJ cAndyYWEJNqGqdOCt/PdgU2CjccazEsWAu5rsKgNxpMI0PBrXSx0VudTyGzcRuLQdpaX SXkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+QqTttvrK+ydHCThErTWQGU78pwuFOyKaqUvf3Lt6j8=; fh=5ynFD2G6LA0fdRuAOSZxbBxHoIIG4U3xrwbnkupZs28=; b=FmOWQirntNkUDekBU+SDEXpo6PwwAzut1tjZERNqjiq9FInibKP4aY7kOZ2KBc+AU2 xWM+sbPMDzfa+O5F/CX63ltwSbxQlsE0mD0xorFp1/zrx74dWULr1M/Oc1UkWC3gvI9O 0WO9cOboyNaYlJnEexzl9VMVS+989BZUBxaIMTL42nmNGnrJ4w0yioI7c+B193Sp36r9 agjO8frA06rmP5AElAYt5t1k1/0r6TwXmf1dqP7vVcIs4HynFOYWe5K/PnUw193W7EPA uz1Pt8ci3M9hi//DMx067rUyMSSZlHc+y5bLn2vM/C2y1bfih2CDTDnbWkRrxyXMaoei R9ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NrHaEoiI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id b1-20020a056a00114100b006cb6cc08e3fsi11170654pfm.387.2023.11.27.15.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 15:46:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NrHaEoiI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 498B180A8B40; Mon, 27 Nov 2023 15:46:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233895AbjK0XqS (ORCPT + 99 others); Mon, 27 Nov 2023 18:46:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233796AbjK0XqA (ORCPT ); Mon, 27 Nov 2023 18:46:00 -0500 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D19EB1B1; Mon, 27 Nov 2023 15:46:05 -0800 (PST) Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-5c2066accc5so3253232a12.3; Mon, 27 Nov 2023 15:46:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701128765; x=1701733565; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+QqTttvrK+ydHCThErTWQGU78pwuFOyKaqUvf3Lt6j8=; b=NrHaEoiIGzswpw48UOOMgSE/w6JjfTItR35NDtUcjjGzgm4yBvBYHpIcoENC9fMcvp AdtPmEOGjksixBn1UqcKUyKFDtZxKMCFuWy07Pd+HDiMjc+e/VfXDPELs5MLEhOhA5hR kEj8EwHC2agx1EHc4vVNFx96OyjlvwqskFw5+kfGE0SG5CACgLAW5sf2rfSyKS73e+XR ZpWRAtF2ywuDXO6vv7VctR06WGcm/2ODALmWT8SY/NJmc0/xPAS+clrClkeQCddAZzdR 7r5RR7/V8gcbcwzHs8GdnI+Y65EGLMjLfEJxj3JxzKmA2iA0Z4TXzQPkJ0E2jHXxuhYO /kcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701128765; x=1701733565; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+QqTttvrK+ydHCThErTWQGU78pwuFOyKaqUvf3Lt6j8=; b=a18pdayLB7pcOUSsXC4Bcm0KY8B9vP7SFjOro0ceqZ8hbN4NyaMl44qgW1hjalatCy iSnTJbCqOyLXW0xbBrlrmP8NPmRosSG/AJ6pABQw/yjS39ii5Ld+XJq2POZ94jBLFZ7e 23mKTU9dSwRxPLpz8FQ7K3d9yWVTSUAuyIbpPROIbx2rvhJv2Va7L8bZVvVbiNkbHj53 0x/PWNOI8I4ui3m3TGkH4mbXZssUJBLmwvn6UyS0RuDJcITN97+SvuF5S+54PfjILT+A rkwYuxMxM/ZGrYYs92KE3UwLHejGK2GtMY2e4f+eE4710OG7nqB0hzP1puHt8zlttqD5 /ZWQ== X-Gm-Message-State: AOJu0YxhsnthAwX9FnAQ5Mx51t5WhOkTOUhdhqDH0ij/jZw6OpD1J1bZ Qw8uNfvaJW/d4vmLZJv42Pk= X-Received: by 2002:a17:90b:4d06:b0:27c:f9e7:30fd with SMTP id mw6-20020a17090b4d0600b0027cf9e730fdmr12623338pjb.7.1701128765215; Mon, 27 Nov 2023 15:46:05 -0800 (PST) Received: from localhost (fwdproxy-prn-116.fbsv.net. [2a03:2880:ff:74::face:b00c]) by smtp.gmail.com with ESMTPSA id 25-20020a17090a031900b0027d0af2e9c3sm9103232pje.40.2023.11.27.15.46.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 15:46:04 -0800 (PST) From: Nhat Pham 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, chrisl@kernel.org, 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 Subject: [PATCH v7 4/6] mm: memcg: add per-memcg zswap writeback stat Date: Mon, 27 Nov 2023 15:45:58 -0800 Message-Id: <20231127234600.2971029-5-nphamcs@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231127234600.2971029-1-nphamcs@gmail.com> References: <20231127234600.2971029-1-nphamcs@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 27 Nov 2023 15:46:31 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783762824769766144 X-GMAIL-MSGID: 1783762824769766144 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 --- include/linux/vm_event_item.h | 1 + mm/memcontrol.c | 1 + mm/vmstat.c | 1 + mm/zswap.c | 3 +++ 4 files changed, 6 insertions(+) diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index d1b847502f09..f4569ad98edf 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -142,6 +142,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, #ifdef CONFIG_ZSWAP ZSWPIN, ZSWPOUT, + ZSWP_WB, #endif #ifdef CONFIG_X86 DIRECT_MAP_LEVEL2_SPLIT, diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 8c0f3f971179..f88c8fd03689 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -703,6 +703,7 @@ static const unsigned int memcg_vm_event_stat[] = { #if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_ZSWAP) ZSWPIN, ZSWPOUT, + ZSWP_WB, #endif #ifdef CONFIG_TRANSPARENT_HUGEPAGE THP_FAULT_ALLOC, diff --git a/mm/vmstat.c b/mm/vmstat.c index afa5a38fcc9c..2249f85e4a87 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1401,6 +1401,7 @@ const char * const vmstat_text[] = { #ifdef CONFIG_ZSWAP "zswpin", "zswpout", + "zswp_wb", #endif #ifdef CONFIG_X86 "direct_map_level2_splits", diff --git a/mm/zswap.c b/mm/zswap.c index 5e397fc1f375..6a761753f979 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -754,6 +754,9 @@ static enum lru_status shrink_memcg_cb(struct list_head *item, struct list_lru_o } zswap_written_back_pages++; + if (entry->objcg) + count_objcg_event(entry->objcg, ZSWP_WB); + /* * Writeback started successfully, the page now belongs to the * swapcache. Drop the entry from zswap - unless invalidate already