All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Cox <alan@redhat.com>
To: linux-kernel@vger.kernel.org, torvalds@osdl.org
Subject: PATCH: Root reservations for strict overcommit
Date: Tue, 31 Aug 2004 10:34:49 -0400	[thread overview]
Message-ID: <20040831143449.GA26680@devserv.devel.redhat.com> (raw)

This was on my TODO list for a while and it turns out someone already fixed the
armwaving overcommit mode for the same problem. It is easy to get into a
situation where you have no overcommit and nothing can be done because there is
no memory to clean up the stable but non-useful state of the machine.

The fix is trivial and duplicated from the armwaving overcommit code path.
The last 3% of the memory can be claimed by root processes only. It isn't a
cure but it does seem to solve the real world problems - at least providing
you have enough memory for 3% to be useful 8).

--- security/commoncap.c~	2004-08-31 15:27:46.777504736 +0100
+++ security/commoncap.c	2004-08-31 15:27:46.778504584 +0100
@@ -357,6 +357,11 @@
 
 	allowed = (totalram_pages - hugetlb_total_pages())
 	       	* sysctl_overcommit_ratio / 100;
+	/*
+	 * Leave the last 3% for root
+	 */
+	if (!capable(CAP_SYS_ADMIN))
+		allowed -= allowed / 32;
 	allowed += total_swap_pages;
 
 	if (atomic_read(&vm_committed_space) < allowed)

             reply	other threads:[~2004-08-31 14:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-31 14:34 Alan Cox [this message]
2004-08-31 17:13 ` PATCH: Root reservations for strict overcommit Bill Davidsen
2004-08-31 16:37   ` Alan Cox
2004-08-31 19:49     ` V13
2004-09-02  9:36       ` Paul Jackson

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=20040831143449.GA26680@devserv.devel.redhat.com \
    --to=alan@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.