From lchen@zen.lhaven.homeip.net  Fri May  2 00:02:01 2014
Return-Path: <lchen@zen.lhaven.homeip.net>
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id 7BBFDCB7
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  2 May 2014 00:02:01 +0000 (UTC)
Received: from mho-02-ewr.mailhop.org (mho-02-ewr.mailhop.org [204.13.248.72])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client did not present a certificate)
	by mx1.freebsd.org (Postfix) with ESMTPS id 4BE131C5C
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  2 May 2014 00:02:00 +0000 (UTC)
Received: from ip70-179-144-228.fv.ks.cox.net ([70.179.144.228] helo=zen.lhaven.homeip.net)
	by mho-02-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256)
	(Exim 4.72)
	(envelope-from <lchen@zen.lhaven.homeip.net>)
	id 1Wg0vQ-000PaJ-3x
	for FreeBSD-gnats-submit@freebsd.org; Fri, 02 May 2014 00:02:00 +0000
Received: from zen.lhaven.homeip.net (localhost [127.0.0.1])
	by zen.lhaven.homeip.net (8.14.8/8.14.7) with ESMTP id s4200hfh081257;
	Thu, 1 May 2014 19:00:53 -0500 (CDT)
	(envelope-from lchen@zen.lhaven.homeip.net)
Received: (from lchen@localhost)
	by zen.lhaven.homeip.net (8.14.8/8.14.7/Submit) id s4200NU6081077;
	Thu, 1 May 2014 19:00:23 -0500 (CDT)
	(envelope-from lchen)
Message-Id: <201405020000.s4200NU6081077@zen.lhaven.homeip.net>
Date: Thu, 1 May 2014 19:00:23 -0500 (CDT)
From: Lawrence "The Dreamer" Chen <beastie@tardisi.com>
Reply-To: Lawrence "The Dreamer" Chen <beastie@tardisi.com>
To: FreeBSD-gnats-submit@freebsd.org
Subject: mlock(2) allocation limit description inaccurate
X-Send-Pr-Version: 3.114
X-GNATS-Notify:

>Number:         189214
>Category:       docs
>Synopsis:       mlock(2) allocation limit description inaccurate
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bjk
>State:          patched
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 02 00:10:00 UTC 2014
>Closed-Date:    
>Last-Modified:  Sat May 17 03:10:00 UTC 2014
>Originator:     Lawrence "The Dreamer" Chen
>Release:        FreeBSD 9.2-RELEASE-p5 amd64
>Organization:
>Environment:
System: FreeBSD zen.lhaven.homeip.net 9.2-RELEASE-p5 FreeBSD 9.2-RELEASE-p5 #0: Tue Apr 29 19:09:13 UTC 2014 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64


	
>Description:
	

	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.

>How-To-Repeat:
	
>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....
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-doc->bjk 
Responsible-Changed-By: bjk 
Responsible-Changed-When: Sat May 17 02:44:42 UTC 2014 
Responsible-Changed-Why:  
take 

http://www.freebsd.org/cgi/query-pr.cgi?pr=189214 
State-Changed-From-To: open->patched 
State-Changed-By: bjk 
State-Changed-When: Sat May 17 03:09:29 UTC 2014 
State-Changed-Why:  
Committed to head in r266285 

http://www.freebsd.org/cgi/query-pr.cgi?pr=189214 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: docs/189214: commit references a PR
Date: Sat, 17 May 2014 03:05:57 +0000 (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"
 
>Unformatted:
