From patchwork Mon Nov 27 19:37:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nhat Pham X-Patchwork-Id: 170375 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp3407452vqx; Mon, 27 Nov 2023 11:37:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IHI76KiVQyh819GFmQtXMHCVNMWpcw0AV2ipruSR53OmkaSH4E3mSHVrnhOKV25S+GRqGXj X-Received: by 2002:a05:6a21:a5a8:b0:18c:3fe8:d8cc with SMTP id gd40-20020a056a21a5a800b0018c3fe8d8ccmr10540202pzc.28.1701113858097; Mon, 27 Nov 2023 11:37:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701113858; cv=none; d=google.com; s=arc-20160816; b=uJYcAxpD0TFandXiVeURMVG1Mte5JK6A2cgv4OGdRtKp74d1dWFahIHi03jS3nbXMC FQk40+PVhHMLCAT1ZkIJ6SdsrqZDJFUgXFHSm5YMMXWxiU71bbxBw0Z/ijoqI8wjCs/P HERYqIupU5EqrHq6o6ZP581DGj3W7XDBJMyt07+wbIxEQdUy61cpvFaa6Zcb8rqpn62f wTZTe7VgJRBOx/CrX0kQX6uwHYvqvlTr8jegr+6JcB/aemZ/FbYQtsoBHyuB3KndEGg/ ePHutL2bdvTzyt3pKJq7BnhxZ9As2OQQ7HhZu4syHhOkFJqShD4zgRyaEbXoCCxGPYm8 x/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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5O5wu9Cq/51IfGIxfcOGm2UEiIvcNVg0blWRA633/+k=; fh=5ynFD2G6LA0fdRuAOSZxbBxHoIIG4U3xrwbnkupZs28=; b=S5d2ly3ldsE+vqYjNOoicqfX0iW412mbD0QgQsHApSjAE1EuXHJf3nMwKz+JSlFGrn DKTiG9DPcjd+apIDIK4nLjNaH5k7xJJ7hPLWGfQgcwI478Y5oZFYkUaETOeQTx6X2QY9 eMMJOWL1Q/PhR07ydqCAhh9giY/KeRBHnBX/O7rk3pCl/xcYG4LNn7qfAkwP+jsDuzdI 9xcqy4KWK2TFJgvNdlxZL0R/+jWkoPf6rEXFR27sf/pjxVbrV+ugeLKiymQoFm2UUOGL YRjR1jXN92K9K3N+Ob9Cm3M2RiiogMQ2/RaRa9GYdNPg5ZwCsTbtVA2g4QOVjeEvX6+K kyvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ighDkBR+; 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 195-20020a6301cc000000b005c21fa725casi9602329pgb.596.2023.11.27.11.37.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 11:37:38 -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=ighDkBR+; 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 A53EC805F95F; Mon, 27 Nov 2023 11:37:36 -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 S232993AbjK0ThL (ORCPT + 99 others); Mon, 27 Nov 2023 14:37:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232782AbjK0ThC (ORCPT ); Mon, 27 Nov 2023 14:37:02 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3B7F1B4; Mon, 27 Nov 2023 11:37:08 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6c398717726so3818500b3a.2; Mon, 27 Nov 2023 11:37:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701113828; x=1701718628; 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=5O5wu9Cq/51IfGIxfcOGm2UEiIvcNVg0blWRA633/+k=; b=ighDkBR+sbXXLHMFEBPzc2tMNeQGDU5KvZg/3mbqHD41lN1XtOmzUNZSldjr2V8Qxp e223lmVPg7/eLmynFUjafh1J42RPKNcHN5HJfOjt742LVxW7KeIeK7p8UUtnt83oQHVL J2bqe2nx8hnjlhqec51cx4ASKZIwvZ7Y3lZw81Zdg7TWemisNf+j+84caIWKHBHVV35k SiyDkeXf/Lia50GJ2oH2PEspAD9bSVna+p/aS+9uyVdXdUy5FUcTfgQNbIQWAQzvVUgI pdLkX4Th3YCiwW5LSqvhposWr7/ZnuJwzUMQZoijO3frc+CTA6OiCsR9D8GKuTlGeNBL mZrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701113828; x=1701718628; 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=5O5wu9Cq/51IfGIxfcOGm2UEiIvcNVg0blWRA633/+k=; b=mIEpa92yVhC29vnb/8aZa64K/gIN7pIFWOo9o5V/zW2h9BxzkmrKyh7Rk8fNtdwUe9 z1P2ybtrhmtPEY+ovay3SfL1CDSmiAAl3iCNaMNSq34tchKUsQvynvqXoVgKeU5B8Cw4 RK9ZHPONx3owUvnvHmpbczY27SGppUEUX3u2lfuo7ycv/GyA0BAD0y6iL4vScTI0tmqL 7z7LbwtWlg5e8Fh62WGOa5gsZIaLdAnAZSdQAtN26/axWhk1eVNdXNKYZI15thwIlGIO EYXqeI4mSeCJCcrL9bLp18x4PySsL+FiWrsWt81oTjcLuyZvdWCvCpFcV4yhfQHWkjDZ IAmQ== X-Gm-Message-State: AOJu0YxrNNZcSTjfoIEmzMlUfiQ15xo6pIxehCBT9Mb/B4cALLLL8ABT GxwrLYULRx3GLWApFZ0UZ2w= X-Received: by 2002:a05:6a21:19a:b0:18c:ab4:f6c9 with SMTP id le26-20020a056a21019a00b0018c0ab4f6c9mr12929291pzb.56.1701113828278; Mon, 27 Nov 2023 11:37:08 -0800 (PST) Received: from localhost (fwdproxy-prn-023.fbsv.net. [2a03:2880:ff:17::face:b00c]) by smtp.gmail.com with ESMTPSA id x18-20020aa793b2000000b00688435a9915sm7569191pff.189.2023.11.27.11.37.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 11:37:07 -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 v6 4/6] mm: memcg: add per-memcg zswap writeback stat Date: Mon, 27 Nov 2023 11:37:01 -0800 Message-Id: <20231127193703.1980089-5-nphamcs@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231127193703.1980089-1-nphamcs@gmail.com> References: <20231127193703.1980089-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_BLOCKED,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 11:37:36 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783747165253486881 X-GMAIL-MSGID: 1783747165253486881 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 0399aec8c0e3..a82f9c695c6c 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 e441cbcab9a9..9f5142524d48 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