summaryrefslogtreecommitdiffstats
path: root/ipc/shm.c
diff options
context:
space:
mode:
authorBadari Pulavarty <pbadari@us.ibm.com>2005-11-07 09:59:27 +0100
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-07 16:53:37 +0100
commitbf8f972d3a1daf969cf44f64cc36d53bfd76441f (patch)
treec3f0ac2f789c695d13858171144aa5f4ecdc84c1 /ipc/shm.c
parent[PATCH] fuse: remove dead code from fuse_permission (diff)
downloadlinux-bf8f972d3a1daf969cf44f64cc36d53bfd76441f.tar.xz
linux-bf8f972d3a1daf969cf44f64cc36d53bfd76441f.zip
[PATCH] SHM_NORESERVE flags for shmget()
Add SHM_NORESERVE functionality similar to MAP_NORESERVE for shared memory segments. This is mainly to avoid abuse of OVERCOMMIT_ALWAYS and this flag is ignored for OVERCOMMIT_NEVER. Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com> Cc: Hugh Dickins <hugh@veritas.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'ipc/shm.c')
-rw-r--r--ipc/shm.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index b58c651d31ae..587d836d80d9 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -212,8 +212,16 @@ static int newseg (key_t key, int shmflg, size_t size)
file = hugetlb_zero_setup(size);
shp->mlock_user = current->user;
} else {
+ int acctflag = VM_ACCOUNT;
+ /*
+ * Do not allow no accounting for OVERCOMMIT_NEVER, even
+ * if it's asked for.
+ */
+ if ((shmflg & SHM_NORESERVE) &&
+ sysctl_overcommit_memory != OVERCOMMIT_NEVER)
+ acctflag = 0;
sprintf (name, "SYSV%08x", key);
- file = shmem_file_setup(name, size, VM_ACCOUNT);
+ file = shmem_file_setup(name, size, acctflag);
}
error = PTR_ERR(file);
if (IS_ERR(file))