Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5451521yba; Wed, 10 Apr 2019 21:00:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqzO3uYpC8+sKKnntUM0zCmEOi/Mlad+EMefyvCxvu/usHw7VFltSJ1J/YubYmqE5DvwG4rc X-Received: by 2002:a65:43c3:: with SMTP id n3mr45933052pgp.375.1554955221341; Wed, 10 Apr 2019 21:00:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554955221; cv=none; d=google.com; s=arc-20160816; b=UN9gAXN2XxoMEy+2GI2tcI4kaeDKELVJDiFH+qkrwOdr4++no6YtqGXTuT7FxJnaYF 2X0IaXCFrdA0s2cNQx/Gnbzhgq6pn+BaZos7LQwMr6YV4wZ2KWhrc2fS/0ZFy66mRMDf jYZLAiw9CivwYsEQK+IJ5H2gujC0iwiQYfN8uEWLrszX/h2V1ZP1WIIsfm4txjJpp1Qf oabeh0DbciEGZxlvyI8hXexUM1XOYZI6UFBEnxHpHGxxEuiLhE2heKyTqRwXiNv+y9My 63W0ZYZ9AX/QpJoquXj/48snBZGbY/DL/tVwD4bsfbUUNtktMOK/qGbGrAZ70cG+dpOC WG2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=8cOivVWY4TyKGsTwqMSmS+kBKv0VXMIFbIVXDNKOfGQ=; b=CjpWwip1F96eLLR5ZOETl+ooTF0rxxH+8REWBtjuf9kutdVMHANoyvclLvja1jurP6 JTVL1Esaq1hfmAJKLk9NiJBpdQXNDE82q6f7SJzVnvNuLBKzR9mHiljK6hqXfhBkOlo9 U6X/wYhwG9LhdsNVacYuUATTBnQrf5GVyDdRB4KxqZzsfN1oBuyPvMAC6fT4lPHoetpL 9MWABqf+/g02KACsQ+Xp9svl4wIPb72XX0vrukdRFh0dkCeGYUckeHjjlSDknH92Hopr o0an5gHLvJyAqPXzn6w28nLSYzxd+cadrWM6ImG+kktE+DBdscuYpYdvS8xqWNDmM2H4 MHFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x23si10172731plr.48.2019.04.10.21.00.05; Wed, 10 Apr 2019 21:00:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726957AbfDKD5r (ORCPT + 99 others); Wed, 10 Apr 2019 23:57:47 -0400 Received: from out4437.biz.mail.alibaba.com ([47.88.44.37]:41139 "EHLO out4437.biz.mail.alibaba.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726832AbfDKD53 (ORCPT ); Wed, 10 Apr 2019 23:57:29 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R991e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---0TP0I5rB_1554955031; Received: from e19h19392.et15sqa.tbsite.net(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0TP0I5rB_1554955031) by smtp.aliyun-inc.com(127.0.0.1); Thu, 11 Apr 2019 11:57:24 +0800 From: Yang Shi To: mhocko@suse.com, mgorman@techsingularity.net, riel@surriel.com, hannes@cmpxchg.org, akpm@linux-foundation.org, dave.hansen@intel.com, keith.busch@intel.com, dan.j.williams@intel.com, fengguang.wu@intel.com, fan.du@intel.com, ying.huang@intel.com, ziy@nvidia.com Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [v2 PATCH 8/9] mm: vmscan: add page demotion counter Date: Thu, 11 Apr 2019 11:56:58 +0800 Message-Id: <1554955019-29472-9-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1554955019-29472-1-git-send-email-yang.shi@linux.alibaba.com> References: <1554955019-29472-1-git-send-email-yang.shi@linux.alibaba.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Account the number of demoted pages into reclaim_state->nr_demoted. Add pgdemote_kswapd and pgdemote_direct VM counters showed in /proc/vmstat. Signed-off-by: Yang Shi --- include/linux/vm_event_item.h | 2 ++ include/linux/vmstat.h | 1 + mm/internal.h | 1 + mm/vmscan.c | 7 +++++++ mm/vmstat.c | 2 ++ 5 files changed, 13 insertions(+) diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index 47a3441..499a3aa 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -32,6 +32,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, PGREFILL, PGSTEAL_KSWAPD, PGSTEAL_DIRECT, + PGDEMOTE_KSWAPD, + PGDEMOTE_DIRECT, PGSCAN_KSWAPD, PGSCAN_DIRECT, PGSCAN_DIRECT_THROTTLE, diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 2db8d60..eb5d21c 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -29,6 +29,7 @@ struct reclaim_stat { unsigned nr_activate; unsigned nr_ref_keep; unsigned nr_unmap_fail; + unsigned nr_demoted; }; #ifdef CONFIG_VM_EVENT_COUNTERS diff --git a/mm/internal.h b/mm/internal.h index 8c424b5..8ba4853 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -156,6 +156,7 @@ struct scan_control { unsigned int immediate; unsigned int file_taken; unsigned int taken; + unsigned int demoted; } nr; }; diff --git a/mm/vmscan.c b/mm/vmscan.c index 50cde53..a52c8248 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1511,6 +1511,12 @@ static unsigned long shrink_page_list(struct list_head *page_list, nr_reclaimed += nr_succeeded; + stat->nr_demoted = nr_succeeded; + if (current_is_kswapd()) + __count_vm_events(PGDEMOTE_KSWAPD, stat->nr_demoted); + else + __count_vm_events(PGDEMOTE_DIRECT, stat->nr_demoted); + if (err) { if (err == -ENOMEM) set_bit(PGDAT_CONTENDED, @@ -2019,6 +2025,7 @@ static int current_may_throttle(void) sc->nr.unqueued_dirty += stat.nr_unqueued_dirty; sc->nr.writeback += stat.nr_writeback; sc->nr.immediate += stat.nr_immediate; + sc->nr.demoted += stat.nr_demoted; sc->nr.taken += nr_taken; if (file) sc->nr.file_taken += nr_taken; diff --git a/mm/vmstat.c b/mm/vmstat.c index 1a431dc..d1e4993 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1192,6 +1192,8 @@ int fragmentation_index(struct zone *zone, unsigned int order) "pgrefill", "pgsteal_kswapd", "pgsteal_direct", + "pgdemote_kswapd", + "pgdemote_direct", "pgscan_kswapd", "pgscan_direct", "pgscan_direct_throttle", -- 1.8.3.1