Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Aug 2018 21:03:45 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r338278 - head/sys/vm
Message-ID:  <201808232103.w7NL3jEO062343@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Thu Aug 23 21:03:45 2018
New Revision: 338278
URL: https://svnweb.freebsd.org/changeset/base/338278

Log:
  Add a per-pagequeue pdpages counter.
  
  Expose these counters under the vm.domain sysctl node.  The existing
  vm.stats.vm.v_pdpages sysctl is preserved.
  
  Reviewed by:	alc (previous version)
  Differential Revision:	https://reviews.freebsd.org/D14666

Modified:
  head/sys/vm/vm_meter.c
  head/sys/vm/vm_page.c
  head/sys/vm/vm_pageout.c
  head/sys/vm/vm_pagequeue.h

Modified: head/sys/vm/vm_meter.c
==============================================================================
--- head/sys/vm/vm_meter.c	Thu Aug 23 20:44:26 2018	(r338277)
+++ head/sys/vm/vm_meter.c	Thu Aug 23 21:03:45 2018	(r338278)
@@ -364,7 +364,6 @@ VM_STATS_VM(v_vnodepgsout, "Vnode pages paged out");
 VM_STATS_VM(v_intrans, "In transit page faults");
 VM_STATS_VM(v_reactivated, "Pages reactivated by pagedaemon");
 VM_STATS_VM(v_pdwakeups, "Pagedaemon wakeups");
-VM_STATS_VM(v_pdpages, "Pages analyzed by pagedaemon");
 VM_STATS_VM(v_pdshortfalls, "Page reclamation shortfalls");
 VM_STATS_VM(v_dfree, "Pages freed by pagedaemon");
 VM_STATS_VM(v_pfree, "Pages freed by exiting processes");
@@ -436,8 +435,7 @@ vm_free_count(void)
 	return (v);
 }
 
-static
-u_int
+static u_int
 vm_pagequeue_count(int pq)
 {
 	u_int v;
@@ -454,23 +452,42 @@ u_int
 vm_active_count(void)
 {
 
-	return vm_pagequeue_count(PQ_ACTIVE);
+	return (vm_pagequeue_count(PQ_ACTIVE));
 }
 
 u_int
 vm_inactive_count(void)
 {
 
-	return vm_pagequeue_count(PQ_INACTIVE);
+	return (vm_pagequeue_count(PQ_INACTIVE));
 }
 
 u_int
 vm_laundry_count(void)
 {
 
-	return vm_pagequeue_count(PQ_LAUNDRY);
+	return (vm_pagequeue_count(PQ_LAUNDRY));
 }
 
+static int
+sysctl_vm_pdpages(SYSCTL_HANDLER_ARGS)
+{
+	struct vm_pagequeue *pq;
+	uint64_t ret;
+	int dom, i;
+
+	ret = counter_u64_fetch(vm_cnt.v_pdpages);
+	for (dom = 0; dom < vm_ndomains; dom++)
+		for (i = 0; i < PQ_COUNT; i++) {
+			pq = &VM_DOMAIN(dom)->vmd_pagequeues[i];
+			ret += pq->pq_pdpages;
+		}
+	return (SYSCTL_OUT(req, &ret, sizeof(ret)));
+}
+SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pdpages,
+    CTLTYPE_U64 | CTLFLAG_MPSAFE | CTLFLAG_RD, NULL, 0, sysctl_vm_pdpages, "QU",
+    "Pages analyzed by pagedaemon");
+
 static void
 vm_domain_stats_init(struct vm_domain *vmd, struct sysctl_oid *parent)
 {
@@ -486,15 +503,31 @@ vm_domain_stats_init(struct vm_domain *vmd, struct sys
 	SYSCTL_ADD_UINT(NULL, SYSCTL_CHILDREN(oid), OID_AUTO,
 	    "active", CTLFLAG_RD, &vmd->vmd_pagequeues[PQ_ACTIVE].pq_cnt, 0,
 	    "Active pages");
+	SYSCTL_ADD_U64(NULL, SYSCTL_CHILDREN(oid), OID_AUTO,
+	    "actpdpgs", CTLFLAG_RD,
+	    &vmd->vmd_pagequeues[PQ_ACTIVE].pq_pdpages, 0,
+	    "Active pages scanned by the page daemon");
 	SYSCTL_ADD_UINT(NULL, SYSCTL_CHILDREN(oid), OID_AUTO,
 	    "inactive", CTLFLAG_RD, &vmd->vmd_pagequeues[PQ_INACTIVE].pq_cnt, 0,
 	    "Inactive pages");
+	SYSCTL_ADD_U64(NULL, SYSCTL_CHILDREN(oid), OID_AUTO,
+	    "inactpdpgs", CTLFLAG_RD,
+	    &vmd->vmd_pagequeues[PQ_INACTIVE].pq_pdpages, 0,
+	    "Inactive pages scanned by the page daemon");
 	SYSCTL_ADD_UINT(NULL, SYSCTL_CHILDREN(oid), OID_AUTO,
 	    "laundry", CTLFLAG_RD, &vmd->vmd_pagequeues[PQ_LAUNDRY].pq_cnt, 0,
 	    "laundry pages");
+	SYSCTL_ADD_U64(NULL, SYSCTL_CHILDREN(oid), OID_AUTO,
+	    "laundpdpgs", CTLFLAG_RD,
+	    &vmd->vmd_pagequeues[PQ_LAUNDRY].pq_pdpages, 0,
+	    "Laundry pages scanned by the page daemon");
 	SYSCTL_ADD_UINT(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, "unswappable",
 	    CTLFLAG_RD, &vmd->vmd_pagequeues[PQ_UNSWAPPABLE].pq_cnt, 0,
 	    "Unswappable pages");
+	SYSCTL_ADD_U64(NULL, SYSCTL_CHILDREN(oid), OID_AUTO,
+	    "unswppdpgs", CTLFLAG_RD,
+	    &vmd->vmd_pagequeues[PQ_UNSWAPPABLE].pq_pdpages, 0,
+	    "Unswappable pages scanned by the page daemon");
 	SYSCTL_ADD_UINT(NULL, SYSCTL_CHILDREN(oid), OID_AUTO,
 	    "inactive_target", CTLFLAG_RD, &vmd->vmd_inactive_target, 0,
 	    "Target inactive pages");

Modified: head/sys/vm/vm_page.c
==============================================================================
--- head/sys/vm/vm_page.c	Thu Aug 23 20:44:26 2018	(r338277)
+++ head/sys/vm/vm_page.c	Thu Aug 23 21:03:45 2018	(r338278)
@@ -481,6 +481,7 @@ vm_page_domain_init(int domain)
 		TAILQ_INIT(&pq->pq_pl);
 		mtx_init(&pq->pq_mutex, pq->pq_name, "vm pagequeue",
 		    MTX_DEF | MTX_DUPOK);
+		pq->pq_pdpages = 0;
 		vm_page_init_marker(&vmd->vmd_markers[i], i, 0);
 	}
 	mtx_init(&vmd->vmd_free_mtx, "vm page free queue", NULL, MTX_DEF);

Modified: head/sys/vm/vm_pageout.c
==============================================================================
--- head/sys/vm/vm_pageout.c	Thu Aug 23 20:44:26 2018	(r338277)
+++ head/sys/vm/vm_pageout.c	Thu Aug 23 21:03:45 2018	(r338278)
@@ -246,7 +246,7 @@ vm_pageout_end_scan(struct scan_state *ss)
 
 	TAILQ_REMOVE(&pq->pq_pl, ss->marker, plinks.q);
 	vm_page_aflag_clear(ss->marker, PGA_ENQUEUED);
-	VM_CNT_ADD(v_pdpages, ss->scanned);
+	pq->pq_pdpages += ss->scanned;
 }
 
 /*

Modified: head/sys/vm/vm_pagequeue.h
==============================================================================
--- head/sys/vm/vm_pagequeue.h	Thu Aug 23 20:44:26 2018	(r338277)
+++ head/sys/vm/vm_pagequeue.h	Thu Aug 23 21:03:45 2018	(r338278)
@@ -71,6 +71,7 @@ struct vm_pagequeue {
 	struct pglist	pq_pl;
 	int		pq_cnt;
 	const char	* const pq_name;
+	uint64_t	pq_pdpages;
 } __aligned(CACHE_LINE_SIZE);
 
 #ifndef VM_BATCHQUEUE_SIZE



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808232103.w7NL3jEO062343>