Bug 189214

Summary: mlock(2) allocation limit description inaccurate
Product: Documentation Reporter: Lawrence Chen <beastie>
Component: Books & ArticlesAssignee: Benjamin Kaduk <bjk>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description Lawrence Chen 2014-05-02 01:10:00 UTC
	

	In mlock(2), it says:

	Since physical memory is a potentially scarce resource, processes are
	limited in how much they can lock down.  A single process can mlock()
	the minimum of a system-wide ``wired pages'' limit vm.max_wired and
	the per-process RLIMIT_MEMLOCK resource limit.

Fix: 

The more correct answer is like its the minimum of the per-process
	RLIMIT_MEMLOCK resource limt, and the difference of the system-wide
	''wired pages'' limit vm.max_wired and the total count of wired pages
	on the system vm.stat.vm.v_wire_count.

	Been trying to figure out why gnome-keyring-daemon can't lock any memory
	even though I have set "security.bsd.unprivileged_mlock=1" and
	RLIMIT_MEMLOCK default to 64 (kilobytes.)

	vm.max_wired on my system defaults to 1323555 (pages - pagesize is 4k.)

	Well, turns out vm.stat.vm.v_wire_count was 2020311....
Comment 1 Benjamin Kaduk freebsd_committer freebsd_triage 2014-05-17 03:44:42 UTC
Responsible Changed
From-To: freebsd-doc->bjk

take
Comment 2 dfilter service freebsd_committer freebsd_triage 2014-05-17 04:05:57 UTC
Author: bjk (doc committer)
Date: Sat May 17 03:05:52 2014
New Revision: 266285
URL: http://svnweb.freebsd.org/changeset/base/266285

Log:
  Correct documentation of the limit on how much memory can be mlock()ed
  
  vm.max_wired is a system-wide limit, not per-process.  Reword the
  section to make this more clear.
  
  PR:		docs/189214
  Submitted by:	Lawrence Chen (original text)
  Approved by:	hrs (mentor)

Modified:
  head/lib/libc/sys/mlock.2

Modified: head/lib/libc/sys/mlock.2
==============================================================================
--- head/lib/libc/sys/mlock.2	Sat May 17 03:03:17 2014	(r266284)
+++ head/lib/libc/sys/mlock.2	Sat May 17 03:05:52 2014	(r266285)
@@ -28,7 +28,7 @@
 .\"	@(#)mlock.2	8.2 (Berkeley) 12/11/93
 .\" $FreeBSD$
 .\"
-.Dd March 18, 2013
+.Dd May 17, 2014
 .Dt MLOCK 2
 .Os
 .Sh NAME
@@ -91,14 +91,21 @@ Locked mappings are not inherited by the
 .Pp
 Since physical memory is a potentially scarce resource, processes are
 limited in how much they can lock down.
-A single process can
+The amount of memory that a single process can
 .Fn mlock
-the minimum of
-a system-wide ``wired pages'' limit
-.Va vm.max_wired
-and the per-process
+is limited by both the per-process
 .Li RLIMIT_MEMLOCK
-resource limit.
+resource limit and the
+system-wide
+.Dq wired pages
+limit
+.Va vm.max_wired .
+.Va vm.max_wired
+applies to the system as a whole, so the amount available to a single
+process at any given time is the difference between
+.Va vm.max_wired
+and
+.Va vm.stats.vm.v_wire_count .
 .Pp
 If
 .Va security.bsd.unprivileged_mlock
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 3 Benjamin Kaduk freebsd_committer freebsd_triage 2014-05-17 04:09:29 UTC
State Changed
From-To: open->patched

Committed to head in r266285
Comment 4 Benjamin Kaduk freebsd_committer freebsd_triage 2014-06-06 00:23:49 UTC
MFC to stable/10 in r266952 and stable/9 in r266982.