From patchwork Mon Jun 29 23:45:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 11632861 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CDB9592A for ; Mon, 29 Jun 2020 23:48:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 966D520780 for ; Mon, 29 Jun 2020 23:48:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 966D520780 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 29DAD6B0089; Mon, 29 Jun 2020 19:48:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 24D5A8D001B; Mon, 29 Jun 2020 19:48:38 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 18C636B0092; Mon, 29 Jun 2020 19:48:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0081.hostedemail.com [216.40.44.81]) by kanga.kvack.org (Postfix) with ESMTP id 053666B0089 for ; Mon, 29 Jun 2020 19:48:38 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id BB7F6181AC9CB for ; Mon, 29 Jun 2020 23:48:37 +0000 (UTC) X-FDA: 76983891474.20.grip89_0e0805626e73 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id 942E8180C07AF for ; Mon, 29 Jun 2020 23:48:37 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,dave.hansen@linux.intel.com,,RULES_HIT:30001:30034:30054:30064,0,RBL:192.55.52.93:@linux.intel.com:.lbl8.mailshell.net-64.95.201.95 62.18.0.100;04yg4fihd3kanim35d69ixgozxe9uopfco95q973453rgfmt5jaf5nyaz33apt1.dwpp4g3bhenp9azj71bc6k53o1c1eui6e1gfhae91a8w9bdcb518s331md6nrwg.1-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: grip89_0e0805626e73 X-Filterd-Recvd-Size: 4832 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Mon, 29 Jun 2020 23:48:36 +0000 (UTC) IronPort-SDR: U6A0RV23l+aiqYYDwWZA49Ub1EkoDurE4EAgEroool3m9rN8GDKmvFqE41uZcUNCwqpgnoohJp OlbydgQJmp7g== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="144290595" X-IronPort-AV: E=Sophos;i="5.75,296,1589266800"; d="scan'208";a="144290595" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2020 16:48:34 -0700 IronPort-SDR: cSvOxbCWprVWDC9jeINzlhUbJCerkYsavNkCk9Uq9WEwYZfOjAVF34iAZDqm10x7jxTHjulg67 rR543a07qo2A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,296,1589266800"; d="scan'208";a="355607603" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by orsmga001.jf.intel.com with ESMTP; 29 Jun 2020 16:48:34 -0700 Subject: [RFC][PATCH 4/8] mm/vmscan: add page demotion counter To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org,Dave Hansen ,yang.shi@linux.alibaba.com,rientjes@google.com,ying.huang@intel.com,dan.j.williams@intel.com From: Dave Hansen Date: Mon, 29 Jun 2020 16:45:10 -0700 References: <20200629234503.749E5340@viggo.jf.intel.com> In-Reply-To: <20200629234503.749E5340@viggo.jf.intel.com> Message-Id: <20200629234510.1BF23254@viggo.jf.intel.com> X-Rspamd-Queue-Id: 942E8180C07AF X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: From: Yang Shi Account the number of demoted pages into reclaim_state->nr_demoted. Add pgdemote_kswapd and pgdemote_direct VM counters showed in /proc/vmstat. [ daveh: - __count_vm_events() a bit, and made them look at the THP size directly rather than getting data from migrate_pages() ] Signed-off-by: Yang Shi Signed-off-by: Dave Hansen Cc: David Rientjes Cc: Huang Ying Cc: Dan Williams --- b/include/linux/vm_event_item.h | 2 ++ b/mm/migrate.c | 13 ++++++++++++- b/mm/vmscan.c | 1 + b/mm/vmstat.c | 2 ++ 4 files changed, 17 insertions(+), 1 deletion(-) diff -puN include/linux/vm_event_item.h~mm-vmscan-add-page-demotion-counter include/linux/vm_event_item.h --- a/include/linux/vm_event_item.h~mm-vmscan-add-page-demotion-counter 2020-06-29 16:34:40.332312601 -0700 +++ b/include/linux/vm_event_item.h 2020-06-29 16:34:40.342312601 -0700 @@ -32,6 +32,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PS PGREFILL, PGSTEAL_KSWAPD, PGSTEAL_DIRECT, + PGDEMOTE_KSWAPD, + PGDEMOTE_DIRECT, PGSCAN_KSWAPD, PGSCAN_DIRECT, PGSCAN_DIRECT_THROTTLE, diff -puN mm/migrate.c~mm-vmscan-add-page-demotion-counter mm/migrate.c --- a/mm/migrate.c~mm-vmscan-add-page-demotion-counter 2020-06-29 16:34:40.334312601 -0700 +++ b/mm/migrate.c 2020-06-29 16:34:40.343312601 -0700 @@ -1187,6 +1187,7 @@ static struct page *alloc_demote_node_pa int migrate_demote_mapping(struct page *page) { int next_nid = next_demotion_node(page_to_nid(page)); + int ret; VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE(PageHuge(page), page); @@ -1198,8 +1199,18 @@ int migrate_demote_mapping(struct page * return -ENOMEM; /* MIGRATE_ASYNC is the most light weight and never blocks.*/ - return __unmap_and_move(alloc_demote_node_page, NULL, next_nid, + ret = __unmap_and_move(alloc_demote_node_page, NULL, next_nid, page, MIGRATE_ASYNC, MR_DEMOTION); + + if (ret == MIGRATEPAGE_SUCCESS) { + int nr_demoted = hpage_nr_pages(page); + if (current_is_kswapd()) + __count_vm_events(PGDEMOTE_KSWAPD, nr_demoted); + else + __count_vm_events(PGDEMOTE_DIRECT, nr_demoted); + } + + return ret; } diff -puN mm/vmscan.c~mm-vmscan-add-page-demotion-counter mm/vmscan.c --- a/mm/vmscan.c~mm-vmscan-add-page-demotion-counter 2020-06-29 16:34:40.336312601 -0700 +++ b/mm/vmscan.c 2020-06-29 16:34:40.344312601 -0700 @@ -140,6 +140,7 @@ struct scan_control { unsigned int immediate; unsigned int file_taken; unsigned int taken; + unsigned int demoted; } nr; /* for recording the reclaimed slab by now */ diff -puN mm/vmstat.c~mm-vmscan-add-page-demotion-counter mm/vmstat.c --- a/mm/vmstat.c~mm-vmscan-add-page-demotion-counter 2020-06-29 16:34:40.339312601 -0700 +++ b/mm/vmstat.c 2020-06-29 16:34:40.345312601 -0700 @@ -1198,6 +1198,8 @@ const char * const vmstat_text[] = { "pgrefill", "pgsteal_kswapd", "pgsteal_direct", + "pgdemote_kswapd", + "pgdemote_direct", "pgscan_kswapd", "pgscan_direct", "pgscan_direct_throttle",