From patchwork Thu Oct 31 22:45:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinsey Ho X-Patchwork-Id: 13858418 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 51301E6748E for ; Thu, 31 Oct 2024 22:47:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 66C446B0098; Thu, 31 Oct 2024 18:46:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6190B6B0099; Thu, 31 Oct 2024 18:46:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F42D6B009A; Thu, 31 Oct 2024 18:46:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 1F1476B0098 for ; Thu, 31 Oct 2024 18:46:59 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C12B7120451 for ; Thu, 31 Oct 2024 22:46:58 +0000 (UTC) X-FDA: 82735382898.08.49B0BD4 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) by imf09.hostedemail.com (Postfix) with ESMTP id BA435140006 for ; Thu, 31 Oct 2024 22:46:37 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=QZhH8kuM; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf09.hostedemail.com: domain of 33wgkZwgKCMAqotyk4numuumrk.iusrot03-ssq1giq.uxm@flex--kinseyho.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=33wgkZwgKCMAqotyk4numuumrk.iusrot03-ssq1giq.uxm@flex--kinseyho.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730414654; a=rsa-sha256; cv=none; b=UsbOpPL6+LQz+NgapquKDidN7/QEDhgOKXRURbisKcMzajZYjxEb9Ft8/vctb2a0kfErnZ WCH0e1DlGavGYrvzK9Avslk9eIM0YBwUUzcOxXclwB8eT57H4k7BXvWN8q1qVCA1Iegs4E EgV25rfDirFrl1FL35tzz2j2htkDNRo= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=QZhH8kuM; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf09.hostedemail.com: domain of 33wgkZwgKCMAqotyk4numuumrk.iusrot03-ssq1giq.uxm@flex--kinseyho.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=33wgkZwgKCMAqotyk4numuumrk.iusrot03-ssq1giq.uxm@flex--kinseyho.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730414654; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xsh0ecj9Etn04xB/gBU/50JDS6BBsG2RgrIM+NKe2T8=; b=jsyD167phBwVKLq0lvZP2sL0FMlmXNm4+J9I4LvbeSUIAYDfuICr5fAIehatNLGf30Qx9I Fd9cIvKwiHE5GV5GcvEt6hn2bMUao7m1Fx6m2kNtkTlFb7G8y2qyLjYi6yRwleFhDnWBJo 8eww5RxEQnqNfT9JA9V+wZKvpBg/MWk= Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-7cbe272efa6so1611846a12.3 for ; Thu, 31 Oct 2024 15:46:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1730414816; x=1731019616; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=xsh0ecj9Etn04xB/gBU/50JDS6BBsG2RgrIM+NKe2T8=; b=QZhH8kuMTIPf4MAUp6yDnFxhFw73OospuPXBTOiSq2uqgrxBJ2tcAEwucTmymv7X+C U5hobV2ZnCi09XIoMCuKKvEOaLM9xxA1DO3eZ5KkCIrk5J4IlDXViKkiAVFJ+y3p4+lN S0jDqBDVJPIfOFkd00C6L6wRoUUAvIKcx0e9ZfnNs1huB7GQMuuNbEsfdI+ilFhrrBwB 736N6vHiC9qmT2MKPsdrgI7lQrDQgqu2GhrzrJYI3otAWPeQ+po5hVzw6eCbqnGY6B4K sc/YYe1bzpiK2W9y31rYVgzGwSpo1FWoxeOSWT6zNV9Jpn2z7GgZUtVv66+3CV/e/twu BkDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730414816; x=1731019616; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xsh0ecj9Etn04xB/gBU/50JDS6BBsG2RgrIM+NKe2T8=; b=CDYLMhNRsfJw4Bt4+9cFSWTYZ1FJI6FZkcTN9ilcAKOSEt78cYq2ohSMJBTeh3Grbj C8ierKs7j3PtTtpeiPhM3qRhqXFNSXpCvMotLDApnjdbCA2Byt5lj6Qiw+TwGtRV9BQt a0w5bws+UKsh6RWifvKRKe5aEYx8Roz04CR3Mb1HSU6EJsABItWsx0VPpjQDqXMy4tZA RWvtRIs+9AkXhiY2XOxmfLZ1KDdbcVrlMaZ7Xdol1WkbkzuOXeZhX/pxjay7s8jQrRN7 KRzUTMs+U1w51I6hPu8z5cY3rw4AkRJiMhPdpej6DvyU4yrVt37kexMDb7EX4sHoXY+7 OBWA== X-Forwarded-Encrypted: i=1; AJvYcCW87nJE3A/yWeMPSIqkO6i7KMaZuhgaDj1BMglO7uV/lqwOrIwFMbzsWRwfNNRiO6Q6n87/HIceRQ==@kvack.org X-Gm-Message-State: AOJu0YyX0Y0XTYlltUlwIdvxkaa8lbXMoKq4jYx8iWuThL7Q5Nsmyaz4 Q07/64Ri9V7h4gdKL6emMk1BNiMKMVjAWJirSUbapd68vSGU0sR1Tj1rcgyF1/5oD3hmfMfBjtf 52Z5w6k2Ybw== X-Google-Smtp-Source: AGHT+IHArSVwIyggeWsU6JRSK21WNKSRntcwjMdlKacSUh+G18VKzCn39+gQ7DKViVCf1aeNUXLCZjBpRJnC0A== X-Received: from kinseyct.c.googlers.com ([fda3:e722:ac3:cc00:a1:836b:ac13:31a5]) (user=kinseyho job=sendgmr) by 2002:a63:34c1:0:b0:7ea:c554:d831 with SMTP id 41be03b00d2f7-7ee290c2030mr8465a12.7.1730414815657; Thu, 31 Oct 2024 15:46:55 -0700 (PDT) Date: Thu, 31 Oct 2024 22:45:51 +0000 In-Reply-To: <20241031224551.1736113-1-kinseyho@google.com> Mime-Version: 1.0 References: <20241031224551.1736113-1-kinseyho@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Message-ID: <20241031224551.1736113-3-kinseyho@google.com> Subject: [PATCH mm-unstable v1 2/2] mm, swap: add pages allocated for struct swap_cgroup to vmstat From: Kinsey Ho To: Andrew Morton Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Pasha Tatashin , David Rientjes , willy@infradead.org, Vlastimil Babka , David Hildenbrand , Kinsey Ho , Joel Granados , Kaiyang Zhao , Sourav Panda , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org X-Stat-Signature: hr4ed5ugsmr9w744ixioooub47xrrqmb X-Rspamd-Queue-Id: BA435140006 X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1730414797-64308 X-HE-Meta: U2FsdGVkX1+CTgDzIj2MTTyk77FPCZ7OGqRW4fbIrdC54mbLeGIEzA7HItI4uvlVIYZKsq+Q0/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Q1PbbakIo1UUBpnggkHcgnKi3dwO36oxWogjZnYtYe0Sud/VjddkogM6Krqd6l/uXdEhZrgiGJnRZEr3pReqv/oqSOdmejvmkwwM2dLPggr78ou2FF6QS29YRziXtLyHuA1Yzn7t7uqKEowIwlNls5+EUJ4IV2PtlWGsmdn8ycGSRRnU2hI9fr8kQn7rrTsompz4CQmZ7iqcIawEiQfYnYeA0pwyUEAULz6gyBZWTMoDHH31tnx5sRuH6EzF9JzJeBNJ9XejzlNjT1pMw5fAJnuQ3cE25/t1D8jJVP2gotlzeCZUVlUngxgBqwSbeu8dzb5i0JfmzJjHodqnKVDroru4RDfOgccFJz6kjayn+VqH7j8m+DdLdpUrzeMQ6y43vvQMG2DKEdMAOSkJqc+Eu2wv0wpoSDevTIzn709cFGE/l/e6c9tot5TKSYXRSJmHWyKw= 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: Export the number of pages allocated for storing struct swap_cgroup in vmstat using global system-wide counters. Signed-off-by: Kinsey Ho --- include/linux/vmstat.h | 3 +++ mm/swap_cgroup.c | 3 +++ mm/vmstat.c | 3 +++ 3 files changed, 9 insertions(+) diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index ac4d42c4fabd..227e951d1219 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -41,6 +41,9 @@ enum vm_stat_item { NR_DIRTY_BG_THRESHOLD, NR_MEMMAP_PAGES, /* page metadata allocated through buddy allocator */ NR_MEMMAP_BOOT_PAGES, /* page metadata allocated through boot allocator */ +#if defined(CONFIG_MEMCG) && defined(CONFIG_SWAP) + NR_SWAP_CGROUP_PAGES, /* allocated to store struct swap_cgroup */ +#endif NR_VM_STAT_ITEMS, }; diff --git a/mm/swap_cgroup.c b/mm/swap_cgroup.c index da1278f0563b..82eda8a3efe1 100644 --- a/mm/swap_cgroup.c +++ b/mm/swap_cgroup.c @@ -53,6 +53,8 @@ static int swap_cgroup_prepare(int type) if (!(idx % SWAP_CLUSTER_MAX)) cond_resched(); } + mod_global_page_state(NR_SWAP_CGROUP_PAGES, ctrl->length); + return 0; not_enough_page: max = idx; @@ -228,6 +230,7 @@ void swap_cgroup_swapoff(int type) if (!(i % SWAP_CLUSTER_MAX)) cond_resched(); } + mod_global_page_state(NR_SWAP_CGROUP_PAGES, -length); vfree(map); } } diff --git a/mm/vmstat.c b/mm/vmstat.c index e5a6dd5106c2..259574261ec1 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1295,6 +1295,9 @@ const char * const vmstat_text[] = { "nr_dirty_background_threshold", "nr_memmap_pages", "nr_memmap_boot_pages", +#if defined(CONFIG_MEMCG) && defined(CONFIG_SWAP) + "nr_swap_cgroup_pages", +#endif #if defined(CONFIG_VM_EVENT_COUNTERS) || defined(CONFIG_MEMCG) /* enum vm_event_item counters */