From patchwork Tue Oct 24 20:33:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nhat Pham X-Patchwork-Id: 13435244 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 24144C25B6C for ; Tue, 24 Oct 2023 20:33:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 14EFB6B02EC; Tue, 24 Oct 2023 16:33:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B0F26B02ED; Tue, 24 Oct 2023 16:33:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E6D966B02EE; Tue, 24 Oct 2023 16:33:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D3D586B02EC for ; Tue, 24 Oct 2023 16:33:10 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id ABC11408CE for ; Tue, 24 Oct 2023 20:33:10 +0000 (UTC) X-FDA: 81381504540.09.5F922F0 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf25.hostedemail.com (Postfix) with ESMTP id DB475A0008 for ; Tue, 24 Oct 2023 20:33:08 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SJHkdn8d; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=nphamcs@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698179588; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ct7ILXQfwShOguQLCzN2H+ZHxo/ASPBQwkijnwC3QMY=; b=j1Nztu1D1d/6JxA8M0hBDXHt1Jfvc0qURgx30ND70DXZaNtgqhjyJoKTL9x960kOeA1E/Z L3Rftnq37VYfHj0HiCecREtlKgqa/SuBZs+BaE2v6fyE6UzNN1f+1TM9RrtlgrPs/piCGj j6z3OdPOxglWDI/7RjKta33e1CjG8+I= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SJHkdn8d; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=nphamcs@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698179588; a=rsa-sha256; cv=none; b=rEfzuO7kQwOhSVVHoTXBCTDLxcG3tW/u0z4rCmRR2uihNCwQWxwp5V3AtRqWADigKD8xIg Oc0rF7jojayHDG3uoW0kM0X3F8GRvB1CmpCb/C15mpfaHdHb1wFG8psvqWOaSVZUxhCiX8 L5upGfxaciXu4aqfhrrmeflZwVeQCvc= Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6b6f4c118b7so4052019b3a.0 for ; Tue, 24 Oct 2023 13:33:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698179587; x=1698784387; darn=kvack.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=ct7ILXQfwShOguQLCzN2H+ZHxo/ASPBQwkijnwC3QMY=; b=SJHkdn8dTIikrOwAhRa3dmdcyxZng/vqpSeG9P4ss2eazIZzUNXd2uuDAzreaBEnGM xK7ArRBWnCFxy1OVUK0qAmHFnwFywMUFALsZCCMPc+OiaiVhBEADoAcNedrJdt7Y9QoI aKOedbNsrws/2CISLhLxVPvKDpqOZINJF9MTL/Zp2yj1Q0xABUVhWqnJLp8He/qfHKxI otadnWDNgmc07YuiLCRrzFGgOtVoXIGMgO7iVDimSYLMTsOXJF9nZ8Q20v2LZ7UOXWuq 6U4VBh+owVaSKGteR6usay5ywlXgZhW05oLlelxLnecZde7PbMgMPPCkJ03mpc7KTfKO 9tNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698179587; x=1698784387; 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=ct7ILXQfwShOguQLCzN2H+ZHxo/ASPBQwkijnwC3QMY=; b=m6AthU6PhNlRFwj7wrUkN4g0RA14No8S2S2UVgJnBpXRCk64KpuefAOuWEiF8ACPCg Yp4hgESp1mguxKjNey4ZIdP6RkpQKdUnSmoG8Ff25W/QWb1WbJJ85AKYV3ftjfcroNyq cN7UCymZLF+pySdEoZ0DyzCr7OCB8USCUaPjEFI5XYxuMUEKI6coKkjld4SQ6Mz5dU04 yyZoHkpg9aCZXhwngCxtOsHkrU9MeAV94Zvv0toqkjYoJWv8qMTtyoyvqknCqBlgG5dK lLc4D25cr9hXkQoS/GAhp0DHsAK6qTR/+2M9+4D7P04krTJQAhvNpy/KGcgjPRno7BXe C8KA== X-Gm-Message-State: AOJu0Yw/b2RspUy8Lvk09uTPZ0KUI6ngPMprVXFXOTZZPLPwMu6WQREz 3mVMt+ZGHdhPuUmBOI9t+QY= X-Google-Smtp-Source: AGHT+IEqQ/yO6Q0UWV3ZQ4PNu7f2MkIruUL16KnuV71cH8iufU01U3EFGNtF5ep2fwen3nE8TNzFNg== X-Received: by 2002:a05:6a00:1142:b0:6be:23dd:d612 with SMTP id b2-20020a056a00114200b006be23ddd612mr12348489pfm.16.1698179587511; Tue, 24 Oct 2023 13:33:07 -0700 (PDT) Received: from localhost (fwdproxy-prn-014.fbsv.net. [2a03:2880:ff:e::face:b00c]) by smtp.gmail.com with ESMTPSA id z2-20020aa79f82000000b00692cac7a065sm7990229pfr.151.2023.10.24.13.33.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 13:33:06 -0700 (PDT) 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 v4 3/5] mm: memcg: add per-memcg zswap writeback stat Date: Tue, 24 Oct 2023 13:33:00 -0700 Message-Id: <20231024203302.1920362-4-nphamcs@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231024203302.1920362-1-nphamcs@gmail.com> References: <20231024203302.1920362-1-nphamcs@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 34fw7xy697w75i7z41kc3s1txpyz7r8f X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: DB475A0008 X-HE-Tag: 1698179588-608699 X-HE-Meta: U2FsdGVkX18AVsO6drcsh/FueRV1LdB1qEReClDDGTUT+sMyTfS/gQ/udxsKkltnZJxMSDs2UKa2eFqfhNLvq1K9aj5vSO8smTzAlbrpGS4ryEsDZM0mBtc4+NlWt1kI1OHYB2qQwGD880yswc+p6MCipxmvoNIrRZaCPIhZbTZXKzUFTC21cbwwexzCqfdr9jucxw0PDHqYCCVuGEgjhXu5tFIWxR0jEJmN4qauMlITZWJ4X+M4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ErJAaBJmpAKsKR/WtFZ3kE0haSsQ3aiEgQhxPs/EoKKd8JxrzF1aL5ACWCPyAmaumB103PvFoP+uz+NgIdb8r4HpN7R4aZTLBjWzrmOgn/8TsEW6KgiXkln/CMv8WsdP9XJrLmb7kdWzFTiKXea9SGhHA== 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: List-Subscribe: List-Unsubscribe: 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 8abfa1240040..3153359c3841 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -145,6 +145,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 61c0c46c2d62..568d9d037a59 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -593,6 +593,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 359460deb377..5e5572f3b456 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 ee8e227e7b0b..b87311e48de9 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -711,6 +711,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