svn commit: r361945 - head/sys/compat/linux

Mark Johnston markj at FreeBSD.org
Mon Jun 8 22:29:53 UTC 2020


Author: markj
Date: Mon Jun  8 22:29:52 2020
New Revision: 361945
URL: https://svnweb.freebsd.org/changeset/base/361945

Log:
  Stop computing a "sharedram" value when emulating Linux sysinfo(2).
  
  The previous code was computing an incorrect value in a very expensive
  manner.  "sharedram" is supposed to be the amount of memory used by
  named swap objects, which on FreeBSD basically corresponds to memory
  usage by shared memory objects (including, for example, GEM objects) and
  tmpfs.  We currently have no cheap way to count such pages.  The
  previous code tried to determine the number of copy-on-write pages
  shared between processes.
  
  Just replace the computed value with 0.  illumos reportedly does the
  same thing.  Linux itself did not populate this field until a 2014
  commit, "mm: export NR_SHMEM via sysinfo(2) / si_meminfo() interfaces".
  
  Reported by:	mjg
  MFC after:	1 week

Modified:
  head/sys/compat/linux/linux_misc.c

Modified: head/sys/compat/linux/linux_misc.c
==============================================================================
--- head/sys/compat/linux/linux_misc.c	Mon Jun  8 21:51:36 2020	(r361944)
+++ head/sys/compat/linux/linux_misc.c	Mon Jun  8 22:29:52 2020	(r361945)
@@ -79,7 +79,6 @@ __FBSDID("$FreeBSD$");
 #include <vm/vm_kern.h>
 #include <vm/vm_map.h>
 #include <vm/vm_extern.h>
-#include <vm/vm_object.h>
 #include <vm/swap_pager.h>
 
 #ifdef COMPAT_LINUX32
@@ -151,7 +150,6 @@ int
 linux_sysinfo(struct thread *td, struct linux_sysinfo_args *args)
 {
 	struct l_sysinfo sysinfo;
-	vm_object_t object;
 	int i, j;
 	struct timespec ts;
 
@@ -170,13 +168,6 @@ linux_sysinfo(struct thread *td, struct linux_sysinfo_
 	sysinfo.freeram = sysinfo.totalram - vm_wire_count() * PAGE_SIZE;
 
 	sysinfo.sharedram = 0;
-	mtx_lock(&vm_object_list_mtx);
-	TAILQ_FOREACH(object, &vm_object_list, object_list)
-		if (object->shadow_count > 1)
-			sysinfo.sharedram += object->resident_page_count;
-	mtx_unlock(&vm_object_list_mtx);
-
-	sysinfo.sharedram *= PAGE_SIZE;
 	sysinfo.bufferram = 0;
 
 	swap_pager_status(&i, &j);


More information about the svn-src-head mailing list