Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3147137ybt; Mon, 29 Jun 2020 16:53:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuroNsRxb2yCqf/uOGacd8H2xO4ifGDGBy3Py3jg7ynIp8ANfe6jOnyyDXoQwz5AaU8svZ X-Received: by 2002:a05:6402:1d89:: with SMTP id dk9mr8605959edb.31.1593474798075; Mon, 29 Jun 2020 16:53:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593474798; cv=none; d=google.com; s=arc-20160816; b=D3QkiVAU+y/gfJ/8kjbqLanhBxKCNyKPUdu4oe3+B38WW/h5eh6hxT/D7gmFDhSeDs mXdO+oXUB8fHxNM00fd4IF8dzvlzlFBzi1qrPHh9c5t8FDloIY0xo/ZvGJzOd+4K9m+R 95un+3P8cSKXE9ulTyges2Nmz5seLw44CYk9382Ns2xD0pamK3kFh0+BcbCG87LRG1m0 I+UyrmnczcKxQSNxwJcR57dB2ET6RStmQcNXR2hvC8nM2nFVMM52u1gTQqP/WNorzX31 RpW1bKxyirv/QpEyseN9wiekJiXpvoUqwa/jsFLPQIsX+n4Tq0aLSY0Mf/DbZY9wixZS ExYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:in-reply-to:references:date :from:cc:to:subject:ironport-sdr:ironport-sdr; bh=OpIXJZVwgC/c5PoTyMZH4DR2BsX/rt3rN2VHOWPxyjM=; b=Z1Tx+Mb2Ce8iDT8h5mDPrRvwiGVd4aEh+clpSa8amzOZ9arQWoQIPNOAjqoiVsTqMg ERjc95/JsYyqImDZwnJludefBYrCodrOUHx47j0ckM2ijs+v8MXxHuR+yFq/mZk4PfOP KUq7uJCVdDOK32Lm08xVZLupjEFE5uLXJF0OVoaVVxDHWwNurS8TJY260h545zMjotFv QoM6/1QprY7sv3ecPhn5n/jmyk0V355DWqOCVX70VbroF2pW1m4+6/2iAo1YBJZFGjEc kJX4gfDJ46IY+Ve2SulxLUzh6DM+pDlKbrVOEhrRC7jyIGSzZHxJUZt6KiZ40a4aEI/W MUEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u17si716600ejj.13.2020.06.29.16.52.54; Mon, 29 Jun 2020 16:53:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728200AbgF2Xsh (ORCPT + 99 others); Mon, 29 Jun 2020 19:48:37 -0400 Received: from mga07.intel.com ([134.134.136.100]:11691 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726500AbgF2Xsg (ORCPT ); Mon, 29 Jun 2020 19:48:36 -0400 IronPort-SDR: NARoCczc+1EEaPgWaesHpuehkla4kN/ikw1ekRbOaulrWvBpo116gfzPFRlOuVTQbWN7owpytM yVF3lF6QDLJg== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="211173260" X-IronPort-AV: E=Sophos;i="5.75,296,1589266800"; d="scan'208";a="211173260" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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", _