Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 May 2017 18:40:41 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r317695 - head/sys/vm
Message-ID:  <201705021840.v42Ief5R003549@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Tue May  2 18:40:41 2017
New Revision: 317695
URL: https://svnweb.freebsd.org/changeset/base/317695

Log:
  Emulate pre-r317061 ABI.
  
  This restores 32bit-sized accesses to vmcnt sysctls, making old
  binaries like top(1), systat(8) and reboot(8) mostly functional on
  newer kernel.
  
  Reviewed by:	bde
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/vm/vm_meter.c

Modified: head/sys/vm/vm_meter.c
==============================================================================
--- head/sys/vm/vm_meter.c	Tue May  2 18:37:11 2017	(r317694)
+++ head/sys/vm/vm_meter.c	Tue May  2 18:40:41 2017	(r317695)
@@ -266,8 +266,27 @@ static SYSCTL_NODE(_vm_stats, OID_AUTO, 
 	"VM meter vm stats");
 SYSCTL_NODE(_vm_stats, OID_AUTO, misc, CTLFLAG_RW, 0, "VM meter misc stats");
 
+static int
+sysctl_handle_vmstat(SYSCTL_HANDLER_ARGS)
+{
+	uint64_t val;
+#ifdef COMPAT_FREEBSD11
+	uint32_t val32;
+#endif
+
+	val = counter_u64_fetch(*(counter_u64_t *)arg1);
+#ifdef COMPAT_FREEBSD11
+	if (req->oldlen == sizeof(val32)) {
+		val32 = val;		/* truncate */
+		return (SYSCTL_OUT(req, &val32, sizeof(val32)));
+	}
+#endif
+	return (SYSCTL_OUT(req, &val, sizeof(val)));
+}
+
 #define	VM_STATS(parent, var, descr) \
-    SYSCTL_COUNTER_U64(parent, OID_AUTO, var, CTLFLAG_RD, &vm_cnt.var, descr)
+    SYSCTL_OID(parent, OID_AUTO, var, CTLTYPE_U64 | CTLFLAG_MPSAFE | \
+    CTLFLAG_RD, &vm_cnt.var, 0, sysctl_handle_vmstat, "QU", descr);
 #define	VM_STATS_VM(var, descr)		VM_STATS(_vm_stats_vm, var, descr)
 #define	VM_STATS_SYS(var, descr)	VM_STATS(_vm_stats_sys, var, descr)
 



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