From 3e5fae34fc49099effbd315f053841392da0f026 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Mon, 8 Jun 2020 22:29:52 +0000 Subject: [PATCH] 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 --- sys/compat/linux/linux_misc.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 79bed0d1f64..4dc414ba329 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -79,7 +79,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #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_args *args) 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);