From nobody@FreeBSD.org  Wed Jan  7 19:51:45 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E9D9E1065675
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  7 Jan 2009 19:51:45 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id D88698FC20
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  7 Jan 2009 19:51:45 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n07Jpjjj050991
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 7 Jan 2009 19:51:45 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n07JpjXH050990;
	Wed, 7 Jan 2009 19:51:45 GMT
	(envelope-from nobody)
Message-Id: <200901071951.n07JpjXH050990@www.freebsd.org>
Date: Wed, 7 Jan 2009 19:51:45 GMT
From: Kirk Strauser <kirk@strauser.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Can't shmget() more than 2GB of memory, regardless of kern.ipc.shm{max,all}
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         130274
>Category:       kern
>Synopsis:       [sysvipc] Can't shmget() more than 2GB of memory, regardless of kern.ipc.shm{max,all}
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kib
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan 07 20:00:06 UTC 2009
>Closed-Date:    Thu Mar 12 17:31:05 UTC 2009
>Last-Modified:  Thu Mar 12 17:31:05 UTC 2009
>Originator:     Kirk Strauser
>Release:        7.1-RELEASE
>Organization:
The Strauser Group
>Environment:
FreeBSD db1.daycos.com 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Fri Jan  2 22:14:00 CST 2009     root@db1.daycos.com:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
I cannot use shmget() to allocate 2GB or more of shared memory, regardless of the settings of kern.ipc.shmmax and kern.ipc.shmall.  Right now, I have:

$ sysctl kern.ipc.shmmax                           
kern.ipc.shmmax: 8589934592
$ sysctl kern.ipc.shmall
kern.ipc.shmall: 2097152   # 8GB / 4096

Here's a minimal test program I wrote:

########################

#include <stdio.h>
#include <sys/shm.h>

int main() {
    size_t size = 2*1024*1024*1024l - 4096;
    int segid;
    printf("Requested: %zd\n", size);
    segid = shmget(234, size, IPC_CREAT);
    if(segid == -1) {
        perror("Died");
        return;
    }
    printf("SHM ID   : %zd\n", segid);
}

########################

If I define "size" to be no larger than 2GB-4KB, then the program finishes successfully.  Otherwise, it fails with [ENOSPC].
>How-To-Repeat:
Try to allocate 2GB or more of shared memory.
>Fix:


>Release-Note:
>Audit-Trail:

From: Kirk Strauser <kirk@strauser.com>
To: bug-followup@FreeBSD.org,
 kirk@strauser.com
Cc:  
Subject: Re: kern/130274: [sysvipc] Can't shmget() more than 2GB of memory, regardless of kern.ipc.shm{max,all}
Date: Thu, 15 Jan 2009 09:37:23 -0600

 Anyone?  This is a very real problem for people running PostgreSQL on  
 machines with lots of memory.  Since PostgreSQL tuning guides tend to  
 recommend using 1/4 of RAM for shared memory, this means that anyone  
 with more than 8GB of RAM is running a suboptimal setup.
 -- 
 Kirk Strauser
 
 
 
 
Responsible-Changed-From-To: freebsd-bugs->kib 
Responsible-Changed-By: kib 
Responsible-Changed-When: Mon Feb 23 19:55:01 UTC 2009 
Responsible-Changed-Why:  
Grab. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=130274 
State-Changed-From-To: open->patched 
State-Changed-By: kib 
State-Changed-When: Mon Mar 2 18:57:08 UTC 2009 
State-Changed-Why:  
Workaround that allows us to run Postgresql with large shm segments 
is committed; r189283. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=130274 
State-Changed-From-To: patched->closed 
State-Changed-By: kib 
State-Changed-When: Thu Mar 12 17:30:39 UTC 2009 
State-Changed-Why:  
Patch merged to stable/7. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=130274 
>Unformatted:
