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/
--- 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)
--- 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)
_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to