mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Badari Pulavarty <pbadari@us.ibm.com>
To: lkml <linux-kernel@vger.kernel.org>
Cc: akpm@osdl.org
Subject: [PATCH] SHM_NORESERVE flags for shmget()
Date: Mon, 31 Oct 2005 14:02:32 -0800	[thread overview]
Message-ID: <1130796152.24503.26.camel@localhost.localdomain> (raw)

[-- Attachment #1: Type: text/plain, Size: 322 bytes --]

Hi Andrew,

Here is the patch to add SHM_NORESERVE functionality
similar to MAP_NORESERVE for shared memory segments.

This mainly to avoid abuse of OVERCOMMIT_ALWAYS and
this flag is ignored for OVERCOMMIT_NEVER. 
Hugh reviewed the patch earlier and had no objections 
to it. Could you include this ?

Thanks,
Badari





[-- Attachment #2: shm-noreserve.patch --]
[-- Type: text/x-patch, Size: 1510 bytes --]

Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com>
diff -Naurp -X dontdiff linux-2.6.14/include/linux/shm.h linux-2.6.14.new/include/linux/shm.h
--- linux-2.6.14/include/linux/shm.h	2005-09-30 14:17:35.000000000 -0700
+++ linux-2.6.14.new/include/linux/shm.h	2005-10-18 08:46:03.000000000 -0700
@@ -92,6 +92,7 @@ struct shmid_kernel /* private to the ke
 #define	SHM_DEST	01000	/* segment will be destroyed on last detach */
 #define SHM_LOCKED      02000   /* segment will not be swapped */
 #define SHM_HUGETLB     04000   /* segment will use huge TLB pages */
+#define SHM_NORESERVE   010000  /* don't check for reservations */
 
 #ifdef CONFIG_SYSVIPC
 long do_shmat(int shmid, char __user *shmaddr, int shmflg, unsigned long *addr);
diff -Naurp -X dontdiff linux-2.6.14/ipc/shm.c linux-2.6.14.new/ipc/shm.c
--- linux-2.6.14/ipc/shm.c	2005-09-30 14:17:35.000000000 -0700
+++ linux-2.6.14.new/ipc/shm.c	2005-10-20 14:14:40.000000000 -0700
@@ -212,8 +212,16 @@ static int newseg (key_t key, int shmflg
 		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))

                 reply	other threads:[~2005-10-31 22:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1130796152.24503.26.camel@localhost.localdomain \
    --to=pbadari@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®