svn commit: r362188 - in stable/12/sys: compat/linux vm

Mark Johnston markj at FreeBSD.org
Mon Jun 15 03:02:20 UTC 2020


Author: markj
Date: Mon Jun 15 03:02:19 2020
New Revision: 362188
URL: https://svnweb.freebsd.org/changeset/base/362188

Log:
  Revert r362187, it contained some unintended changes.
  
  This is a direct commit to stable/12.

Modified:
  stable/12/sys/compat/linux/linux_misc.c
  stable/12/sys/vm/vm_map.c
  stable/12/sys/vm/vm_map.h
  stable/12/sys/vm/vm_mmap.c
  stable/12/sys/vm/vm_unix.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linux/linux_misc.c
==============================================================================
--- stable/12/sys/compat/linux/linux_misc.c	Mon Jun 15 03:01:28 2020	(r362187)
+++ stable/12/sys/compat/linux/linux_misc.c	Mon Jun 15 03:02:19 2020	(r362188)
@@ -78,6 +78,7 @@ __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
@@ -149,6 +150,7 @@ 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;
 
@@ -166,13 +168,14 @@ linux_sysinfo(struct thread *td, struct linux_sysinfo_
 	sysinfo.totalram = physmem * PAGE_SIZE;
 	sysinfo.freeram = sysinfo.totalram - vm_wire_count() * PAGE_SIZE;
 
-	/*
-	 * sharedram counts pages allocated to named, swap-backed objects such
-	 * as shared memory segments and tmpfs files.  There is no cheap way to
-	 * compute this, so just leave the field unpopulated.  Linux itself only
-	 * started setting this field in the 3.x timeframe.
-	 */
 	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);

Modified: stable/12/sys/vm/vm_map.c
==============================================================================
--- stable/12/sys/vm/vm_map.c	Mon Jun 15 03:01:28 2020	(r362187)
+++ stable/12/sys/vm/vm_map.c	Mon Jun 15 03:02:19 2020	(r362188)
@@ -3097,7 +3097,7 @@ vm_map_wire_locked(vm_map_t map, vm_offset_t start, vm
 	u_long npages;
 	u_int last_timestamp;
 	int rv;
-	boolean_t need_wakeup, result, user_wire, user_wire_limit;
+	boolean_t need_wakeup, result, user_wire;
 	vm_prot_t prot;
 
 	VM_MAP_ASSERT_LOCKED(map);
@@ -3108,7 +3108,6 @@ vm_map_wire_locked(vm_map_t map, vm_offset_t start, vm
 	if (flags & VM_MAP_WIRE_WRITE)
 		prot |= VM_PROT_WRITE;
 	user_wire = (flags & VM_MAP_WIRE_USER) ? TRUE : FALSE;
-	user_wire_limit = (flags & VM_MAP_WIRE_USER_LIMIT) ? TRUE : FALSE;
 	VM_MAP_RANGE_CHECK(map, start, end);
 	if (!vm_map_lookup_entry(map, start, &first_entry)) {
 		if (flags & VM_MAP_WIRE_HOLESOK)
@@ -3189,8 +3188,7 @@ vm_map_wire_locked(vm_map_t map, vm_offset_t start, vm
 			entry->wired_count++;
 
 			npages = atop(entry->end - entry->start);
-			if (user_wire_limit &&
-			    !vm_map_wire_user_count_add(npages)) {
+			if (user_wire && !vm_map_wire_user_count_add(npages)) {
 				vm_map_wire_entry_failure(map, entry,
 				    entry->start);
 				end = entry->end;
@@ -3252,7 +3250,7 @@ vm_map_wire_locked(vm_map_t map, vm_offset_t start, vm
 			last_timestamp = map->timestamp;
 			if (rv != KERN_SUCCESS) {
 				vm_map_wire_entry_failure(map, entry, faddr);
-				if (user_wire_limit)
+				if (user_wire)
 					vm_map_wire_user_count_sub(npages);
 				end = entry->end;
 				goto done;
@@ -3321,7 +3319,7 @@ done:
 			 */
 			if (entry->wired_count == 1) {
 				vm_map_entry_unwire(map, entry);
-				if (user_wire_limit)
+				if (user_wire)
 					vm_map_wire_user_count_sub(
 					    atop(entry->end - entry->start));
 			} else
@@ -4457,8 +4455,7 @@ retry:
 	if (rv == KERN_SUCCESS && (map->flags & MAP_WIREFUTURE) != 0) {
 		rv = vm_map_wire_locked(map, grow_start,
 		    grow_start + grow_amount,
-		    VM_MAP_WIRE_USER | VM_MAP_WIRE_USER_LIMIT |
-		    VM_MAP_WIRE_NOHOLES);
+		    VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
 	}
 	vm_map_lock_downgrade(map);
 

Modified: stable/12/sys/vm/vm_map.h
==============================================================================
--- stable/12/sys/vm/vm_map.h	Mon Jun 15 03:01:28 2020	(r362187)
+++ stable/12/sys/vm/vm_map.h	Mon Jun 15 03:02:19 2020	(r362188)
@@ -397,8 +397,6 @@ long vmspace_resident_count(struct vmspace *vmspace);
 
 #define VM_MAP_WIRE_WRITE	4	/* Validate writable. */
 
-#define	VM_MAP_WIRE_USER_LIMIT	8	/* Enfore the user wiring limit */
-
 #ifdef _KERNEL
 boolean_t vm_map_check_protection (vm_map_t, vm_offset_t, vm_offset_t, vm_prot_t);
 vm_map_t vm_map_create(pmap_t, vm_offset_t, vm_offset_t);

Modified: stable/12/sys/vm/vm_mmap.c
==============================================================================
--- stable/12/sys/vm/vm_mmap.c	Mon Jun 15 03:01:28 2020	(r362187)
+++ stable/12/sys/vm/vm_mmap.c	Mon Jun 15 03:02:19 2020	(r362188)
@@ -1046,7 +1046,7 @@ kern_mlock(struct proc *proc, struct ucred *cred, uint
 	}
 #endif
 	error = vm_map_wire(map, start, end,
-	    VM_MAP_WIRE_USER | VM_MAP_WIRE_USER_LIMIT | VM_MAP_WIRE_NOHOLES);
+	    VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
 #ifdef RACCT
 	if (racct_enable && error != KERN_SUCCESS) {
 		PROC_LOCK(proc);
@@ -1111,8 +1111,7 @@ sys_mlockall(struct thread *td, struct mlockall_args *
 		 * calling vm_fault_wire() for each page in the region.
 		 */
 		error = vm_map_wire(map, vm_map_min(map), vm_map_max(map),
-		    VM_MAP_WIRE_USER | VM_MAP_WIRE_USER_LIMIT |
-		    VM_MAP_WIRE_HOLESOK);
+		    VM_MAP_WIRE_USER|VM_MAP_WIRE_HOLESOK);
 		if (error == KERN_SUCCESS)
 			error = 0;
 		else if (error == KERN_RESOURCE_SHORTAGE)
@@ -1590,7 +1589,6 @@ vm_mmap_object(vm_map_t map, vm_offset_t *addr, vm_siz
 			if ((map->flags & MAP_WIREFUTURE) != 0)
 				(void)vm_map_wire_locked(map, *addr,
 				    *addr + size, VM_MAP_WIRE_USER |
-				    VM_MAP_WIRE_USER_LIMIT |
 				    ((flags & MAP_STACK) ? VM_MAP_WIRE_HOLESOK :
 				    VM_MAP_WIRE_NOHOLES));
 			vm_map_unlock(map);

Modified: stable/12/sys/vm/vm_unix.c
==============================================================================
--- stable/12/sys/vm/vm_unix.c	Mon Jun 15 03:01:28 2020	(r362187)
+++ stable/12/sys/vm/vm_unix.c	Mon Jun 15 03:02:19 2020	(r362188)
@@ -185,8 +185,7 @@ kern_break(struct thread *td, uintptr_t *addr)
 		    0);
 		if (rv == KERN_SUCCESS && (map->flags & MAP_WIREFUTURE) != 0) {
 			rv = vm_map_wire_locked(map, old, new,
-			    VM_MAP_WIRE_USER | VM_MAP_WIRE_USER_LIMIT |
-			    VM_MAP_WIRE_NOHOLES);
+			    VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
 			if (rv != KERN_SUCCESS)
 				vm_map_delete(map, old, new);
 		}


More information about the svn-src-all mailing list