public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Andy Whitcroft <apw@shadowen.org>
Cc: anton@samba.org, sds@epoch.ncsc.mil, ak@suse.de, raybry@sgi.com,
	lse-tech@lists.sourceforge.net, linux-ia64@vger.kernel.org,
	linux-kernel@vger.kernel.org, mbligh@aracnet.com
Subject: Re: [PATCH] [0/6] HUGETLB memory commitment
Date: Thu, 25 Mar 2004 15:51:17 -0800	[thread overview]
Message-ID: <20040325155117.60dbc0e1.akpm@osdl.org> (raw)
In-Reply-To: <41997489.1080257240@42.150.104.212.access.eclipse.net.uk>

Andy Whitcroft <apw@shadowen.org> wrote:
>
> --On 25 March 2004 13:04 -0800 Andrew Morton <akpm@osdl.org> wrote:
> 
> > Sorry, but I just don't see why we need all this complexity and generality.
> > 
> > If there was any likelihood that there would be additional memory domains
> > in the 2.6 future then OK.  But I don't think there will be.  We simply
> > need some little old patch which fixes this bug.
> > 
> > Such as adding a `vma' arg to vm_enough_memory() and vm_unacct_memory() and
> > doing
> > 
> > 	if (is_vm_hugetlb_page(vma))
> > 		return;
> > 
> > and
> > 
> > -	allowed = totalram_pages * sysctl_overcommit_ratio / 100;
> > +	allowed = (totalram_pages - htlbpagemem << HPAGE_SHIFT) *
> > +			sysctl_overcommit_ratio / 100;
> > 
> > in cap_vm_enough_memory().
> 
> That's pretty much what you get if you only apply the first two patches.  Sadly, you can't just pass a vma as you don't always have one when you are making the decision.  For example when a shm segment is being created you need to commit the memory at that point, but its not been attached at all so there is no vma to check.  That's why I went with an abstract domain.  These patches have been tested in isolation and do seem to work.
> 
> The other patches started out wanting to solve a second issue, the generality seemed to come out naturally.  I am not sure how important it is, but when we create a normal shm domain we commit the memory then.  For an hugetlb one we only commit the memory when the region is attached the first time, ie when the pages are cleared and filled.  Also we have no policy control over them.
> 
> In short I guess if we only are trying to fix the overcommit cross over between the normal and hugetlb, then the first two patches should be basically there.
> 
> Let me know what the decision is and I'll steer the ship in that direction.

I think it's simply:

- Make normal overcommit logic skip hugepages completely

- Teach the overcommit_memory=2 logic that hugepages are basically
  "pinned", so subtract them from the arithmetic.

And that's it.  The hugepages are semantically quite different from normal
memory (prefaulted, preallocated, unswappable) and we've deliberately
avoided pretending otherwise.

As for the shm problem, well, perhaps it's best to leave vm_enough_memory()
as it is and fix it up in the callers.  So most callsites will call:

static inline int vm_anough_memory_vma(struct vm_area_struct *vma,
					unsigned long nr_pages)
{
	if (is_vm_hugetlb_page(vma))
		return 0;
	return vm_enough_memory(nr_pages);
}

and in do_mmap_pgoff() perhaps we can do:

+	if (file && !is_file_hugepages(file)) {
		charged = len >> PAGE_SHIFT;
		if (security_vm_enough_memory(charged))
			return -ENOMEM;
+	}




  reply	other threads:[~2004-03-25 23:52 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-25 16:54 [PATCH] [0/6] HUGETLB memory commitment Andy Whitcroft
2004-03-25 16:58 ` [PATCH] [1/6] " Andy Whitcroft
2004-03-25 16:59 ` [PATCH] [2/6] " Andy Whitcroft
2004-03-25 17:00 ` [PATCH] [3/6] " Andy Whitcroft
2004-03-25 17:01 ` [PATCH] [4/6] " Andy Whitcroft
2004-03-25 17:02 ` [PATCH] [5/6] " Andy Whitcroft
2004-03-25 17:03 ` [PATCH] [6/6] " Andy Whitcroft
2004-03-25 21:04 ` [PATCH] [0/6] " Andrew Morton
2004-03-25 23:27   ` Andy Whitcroft
2004-03-25 23:51     ` Andrew Morton [this message]
2004-03-25 23:59       ` Andy Whitcroft
2004-03-26  0:10         ` Keith Owens
2004-03-26  0:22           ` Andrew Morton
2004-03-26  8:58             ` [Lse-tech] " Suparna Bhattacharya
2004-03-26  3:39               ` Keith Owens
2004-03-26 17:15                 ` Suparna Bhattacharya
2004-03-26  2:01         ` Andy Whitcroft
2004-03-26  0:18       ` Martin J. Bligh
2004-03-28 18:02     ` Ray Bryant
2004-03-28 19:10       ` Martin J. Bligh
2004-03-28 21:32         ` [Lse-tech] " Ray Bryant
2004-03-29 16:50           ` Martin J. Bligh
2004-03-29 12:30         ` Andy Whitcroft
2004-03-29 20:45           ` Chen, Kenneth W
2004-03-29 20:49             ` Chen, Kenneth W
2004-03-30 12:57               ` Andy Whitcroft
2004-03-30 20:04                 ` Chen, Kenneth W
2004-03-30 21:48                   ` Andy Whitcroft
2004-03-31  1:48                     ` Andy Whitcroft
2004-03-31  8:51                       ` Chen, Kenneth W
2004-03-31 16:20                         ` Andy Whitcroft
2004-04-01 21:15                         ` Andy Whitcroft
2004-04-01 22:50                           ` Andy Whitcroft
2004-04-01 23:09                           ` Chen, Kenneth W
2004-04-03  3:57                             ` [PATCH] " Ray Bryant
2004-04-04  3:31                               ` Chen, Kenneth W
2004-04-04 22:15                                 ` Ray Bryant
2004-04-05 15:26                                 ` [Lse-tech] " Ray Bryant
2004-04-05 17:01                                   ` Chen, Kenneth W
2004-04-05 18:22                                     ` Ray Bryant
2004-04-05 23:18                                       ` Chen, Kenneth W
2004-04-06  1:05                                         ` Ray Bryant
2004-04-06 16:14                                         ` Andy Whitcroft
2004-04-06 17:40                                           ` Chen, Kenneth W

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=20040325155117.60dbc0e1.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=ak@suse.de \
    --cc=anton@samba.org \
    --cc=apw@shadowen.org \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lse-tech@lists.sourceforge.net \
    --cc=mbligh@aracnet.com \
    --cc=raybry@sgi.com \
    --cc=sds@epoch.ncsc.mil \
    /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