From owner-freebsd-stable@FreeBSD.ORG Mon Oct 15 14:17:23 2007 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F217916A41B; Mon, 15 Oct 2007 14:17:23 +0000 (UTC) (envelope-from is@rambler-co.ru) Received: from relay0.rambler.ru (relay0.rambler.ru [81.19.66.187]) by mx1.freebsd.org (Postfix) with ESMTP id 4C76513C46B; Mon, 15 Oct 2007 14:17:23 +0000 (UTC) (envelope-from is@rambler-co.ru) Received: from relay0.rambler.ru (localhost [127.0.0.1]) by relay0.rambler.ru (Postfix) with ESMTP id D7830B096; Mon, 15 Oct 2007 18:17:21 +0400 (MSD) Received: from localhost (is1.park.rambler.ru [81.19.64.121]) by relay0.rambler.ru (Postfix) with ESMTP id B28ADB089; Mon, 15 Oct 2007 18:17:21 +0400 (MSD) Date: Mon, 15 Oct 2007 18:17:14 +0400 From: Igor Sysoev To: freebsd-current@freebsd.org, freebsd-stable@freebsd.org Message-ID: <20071015141714.GL24828@rambler-co.ru> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="AqsLC8rIMeq19msA" Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: No virus found Cc: Subject: 2G+ sysv shm segments X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Oct 2007 14:17:24 -0000 --AqsLC8rIMeq19msA Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Two years ago Christian S.J. Peron had increased total number of SysV shm pages on 64-bit platform, that allows to create many shm segments more than 2G in sum. However, the patch does not allow to create a single large segment more than 2G. The attached patches against 6.x and 7.x allow to create 2G+ segments. I know that stock 6.x will not have this feature because of compatibility, but I send 6.x patch too because someone may want to use 2G+ shm on 6.x. To install: patch -d < /usr < big_sysvshmX.txt [ rebuild kernel ] cd /usr/src/include/ make obj make make install cd /usr/src/usr.bin/ipcs/ make obj make make install -- Igor Sysoev http://sysoev.ru/en/ --AqsLC8rIMeq19msA Content-Type: text/plain; charset=koi8-r Content-Disposition: attachment; filename="big_sysvshm6.txt" --- src/sys/sys/shm.h 2007-09-12 23:33:39.000000000 +0400 +++ src/sys/sys/shm.h 2007-10-15 17:42:38.000000000 +0400 @@ -77,7 +77,7 @@ struct shmid_ds { struct ipc_perm shm_perm; /* operation permission structure */ - int shm_segsz; /* size of segment in bytes */ + size_t shm_segsz; /* size of segment in bytes */ pid_t shm_lpid; /* process ID of last shared memory op */ pid_t shm_cpid; /* process ID of creator */ short shm_nattch; /* number of current attaches */ @@ -94,11 +94,11 @@ * might be of interest to user programs. Do we really want/need this? */ struct shminfo { - int shmmax, /* max shared memory segment size (bytes) */ - shmmin, /* min shared memory segment size (bytes) */ - shmmni, /* max number of shared memory identifiers */ - shmseg, /* max shared memory segments per process */ - shmall; /* max amount of shared memory (pages) */ + u_long shmmax; /* max shared memory segment size (bytes) */ + u_long shmmin; /* max shared memory segment size (bytes) */ + u_long shmmni; /* max number of shared memory identifiers */ + u_long shmseg; /* max shared memory segments per process */ + u_long shmall; /* max amount of shared memory (pages) */ }; /* --- src/sys/kern/sysv_shm.c 2007-09-12 23:33:19.000000000 +0400 +++ src/sys/kern/sysv_shm.c 2007-10-15 17:16:54.000000000 +0400 @@ -181,15 +181,15 @@ static int shm_allow_removed; SYSCTL_DECL(_kern_ipc); -SYSCTL_INT(_kern_ipc, OID_AUTO, shmmax, CTLFLAG_RW, &shminfo.shmmax, 0, +SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmmax, CTLFLAG_RW, &shminfo.shmmax, 0, "Maximum shared memory segment size"); -SYSCTL_INT(_kern_ipc, OID_AUTO, shmmin, CTLFLAG_RW, &shminfo.shmmin, 0, +SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmmin, CTLFLAG_RW, &shminfo.shmmin, 0, "Minimum shared memory segment size"); -SYSCTL_INT(_kern_ipc, OID_AUTO, shmmni, CTLFLAG_RDTUN, &shminfo.shmmni, 0, +SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmmni, CTLFLAG_RDTUN, &shminfo.shmmni, 0, "Number of shared memory identifiers"); -SYSCTL_INT(_kern_ipc, OID_AUTO, shmseg, CTLFLAG_RDTUN, &shminfo.shmseg, 0, +SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmseg, CTLFLAG_RDTUN, &shminfo.shmseg, 0, "Number of segments per process"); -SYSCTL_INT(_kern_ipc, OID_AUTO, shmall, CTLFLAG_RW, &shminfo.shmall, 0, +SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmall, CTLFLAG_RW, &shminfo.shmall, 0, "Maximum number of pages available for shared memory"); SYSCTL_INT(_kern_ipc, OID_AUTO, shm_use_phys, CTLFLAG_RW, &shm_use_phys, 0, "Enable/Disable locking of shared memory pages in core"); @@ -754,7 +754,8 @@ struct shmget_args *uap; int mode; { - int i, segnum, shmid, size; + int i, segnum, shmid; + size_t size; struct ucred *cred = td->td_ucred; struct shmid_kernel *shmseg; vm_object_t shm_object; @@ -967,15 +968,15 @@ { int i; - TUNABLE_INT_FETCH("kern.ipc.shmmaxpgs", &shminfo.shmall); + TUNABLE_ULONG_FETCH("kern.ipc.shmmaxpgs", &shminfo.shmall); for (i = PAGE_SIZE; i > 0; i--) { shminfo.shmmax = shminfo.shmall * i; if (shminfo.shmmax >= shminfo.shmall) break; } - TUNABLE_INT_FETCH("kern.ipc.shmmin", &shminfo.shmmin); - TUNABLE_INT_FETCH("kern.ipc.shmmni", &shminfo.shmmni); - TUNABLE_INT_FETCH("kern.ipc.shmseg", &shminfo.shmseg); + TUNABLE_ULONG_FETCH("kern.ipc.shmmin", &shminfo.shmmin); + TUNABLE_ULONG_FETCH("kern.ipc.shmmni", &shminfo.shmmni); + TUNABLE_ULONG_FETCH("kern.ipc.shmseg", &shminfo.shmseg); TUNABLE_INT_FETCH("kern.ipc.shm_use_phys", &shm_use_phys); shmalloced = shminfo.shmmni; --- src/usr.bin/ipcs/ipcs.c 2007-09-12 23:32:25.000000000 +0400 +++ src/usr.bin/ipcs/ipcs.c 2007-10-15 17:29:06.000000000 +0400 @@ -93,11 +93,11 @@ }; #define SHMINFO_XVEC \ -X(shmmax, sizeof(int)) \ -X(shmmin, sizeof(int)) \ -X(shmmni, sizeof(int)) \ -X(shmseg, sizeof(int)) \ -X(shmall, sizeof(int)) +X(shmmax, sizeof(u_long)) \ +X(shmmin, sizeof(u_long)) \ +X(shmmni, sizeof(u_long)) \ +X(shmseg, sizeof(u_long)) \ +X(shmall, sizeof(u_long)) #define SEMINFO_XVEC \ X(semmap, sizeof(int)) \ @@ -376,15 +376,15 @@ if ((display & (SHMINFO | SHMTOTAL))) { if (display & SHMTOTAL) { printf("shminfo:\n"); - printf("\tshmmax: %12d\t(max shared memory segment size)\n", + printf("\tshmmax: %12ld\t(max shared memory segment size)\n", shminfo.shmmax); - printf("\tshmmin: %12d\t(min shared memory segment size)\n", + printf("\tshmmin: %12ld\t(min shared memory segment size)\n", shminfo.shmmin); - printf("\tshmmni: %12d\t(max number of shared memory identifiers)\n", + printf("\tshmmni: %12ld\t(max number of shared memory identifiers)\n", shminfo.shmmni); - printf("\tshmseg: %12d\t(max shared memory segments per process)\n", + printf("\tshmseg: %12ld\t(max shared memory segments per process)\n", shminfo.shmseg); - printf("\tshmall: %12d\t(max amount of shared memory in pages)\n\n", + printf("\tshmall: %12ld\t(max amount of shared memory in pages)\n\n", shminfo.shmall); } if (display & SHMINFO) { @@ -439,7 +439,7 @@ kshmptr->u.shm_nattch); if (option & BIGGEST) - printf(" %12d", + printf(" %12ld", kshmptr->u.shm_segsz); if (option & PID) --AqsLC8rIMeq19msA Content-Type: text/plain; charset=koi8-r Content-Disposition: attachment; filename="big_sysvshm7.txt" --- src/sys/sys/shm.h 2007-09-12 23:33:39.000000000 +0400 +++ src/sys/sys/shm.h 2007-10-15 17:42:38.000000000 +0400 @@ -77,7 +77,7 @@ struct shmid_ds { struct ipc_perm shm_perm; /* operation permission structure */ - int shm_segsz; /* size of segment in bytes */ + size_t shm_segsz; /* size of segment in bytes */ pid_t shm_lpid; /* process ID of last shared memory op */ pid_t shm_cpid; /* process ID of creator */ short shm_nattch; /* number of current attaches */ --- src/sys/kern/sysv_shm.c 2007-09-12 23:33:19.000000000 +0400 +++ src/sys/kern/sysv_shm.c 2007-10-15 17:16:54.000000000 +0400 @@ -717,7 +717,8 @@ struct shmget_args *uap; int mode; { - int i, segnum, shmid, size; + int i, segnum, shmid; + size_t size; struct ucred *cred = td->td_ucred; struct shmid_kernel *shmseg; vm_object_t shm_object; --- src/usr.bin/ipcs/ipcs.c 2007-09-12 23:32:25.000000000 +0400 +++ src/usr.bin/ipcs/ipcs.c 2007-10-15 17:29:06.000000000 +0400 @@ -376,15 +376,15 @@ if ((display & (SHMINFO | SHMTOTAL))) { if (display & SHMTOTAL) { printf("shminfo:\n"); - printf("\tshmmax: %12d\t(max shared memory segment size)\n", + printf("\tshmmax: %12ld\t(max shared memory segment size)\n", shminfo.shmmax); - printf("\tshmmin: %12d\t(min shared memory segment size)\n", + printf("\tshmmin: %12ld\t(min shared memory segment size)\n", shminfo.shmmin); - printf("\tshmmni: %12d\t(max number of shared memory identifiers)\n", + printf("\tshmmni: %12ld\t(max number of shared memory identifiers)\n", shminfo.shmmni); - printf("\tshmseg: %12d\t(max shared memory segments per process)\n", + printf("\tshmseg: %12ld\t(max shared memory segments per process)\n", shminfo.shmseg); - printf("\tshmall: %12d\t(max amount of shared memory in pages)\n\n", + printf("\tshmall: %12ld\t(max amount of shared memory in pages)\n\n", shminfo.shmall); } if (display & SHMINFO) { @@ -439,7 +439,7 @@ kshmptr->u.shm_nattch); if (option & BIGGEST) - printf(" %12d", + printf(" %12ld", kshmptr->u.shm_segsz); if (option & PID) --AqsLC8rIMeq19msA--