* [patch, 2.5] __vmalloc allocates spurious page?
@ 2002-10-15 19:32 Marcus Alanen
2002-10-15 21:58 ` Marcus Alanen
0 siblings, 1 reply; 5+ messages in thread
From: Marcus Alanen @ 2002-10-15 19:32 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
Hi,
I think __vmalloc allocates an unnecessary page. While the virtual
address space should have a one-page hole in it, that is taken care of
by get_vm_area. All other routines (particularly map_vm_area)
subtract PAGE_SIZE from area->size before usage, so the last page
table entry isn't even set up.
The unnecessary page is allocated only if size is initially a multiple
of PAGE_SIZE, which sounds like a common case.
Marcus
diff -Naurd --exclude-from=/home/maalanen/linux/base/diff_exclude linus-2.5.42/mm/vmalloc.c msa-2.5.42/mm/vmalloc.c
--- linus-2.5.42/mm/vmalloc.c Sat Oct 12 16:42:57 2002
+++ msa-2.5.42/mm/vmalloc.c Tue Oct 15 21:53:10 2002
@@ -387,7 +387,7 @@
if (!area)
return NULL;
- nr_pages = (size+PAGE_SIZE) >> PAGE_SHIFT;
+ nr_pages = (size+PAGE_SIZE-1) >> PAGE_SHIFT;
array_size = (nr_pages * sizeof(struct page *));
area->nr_pages = nr_pages;
--
Marcus Alanen * Software Construction Laboratory *
marcus.alanen@abo.fi * http://www.tucs.fi/Research/labs/softcons.php *
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch, 2.5] __vmalloc allocates spurious page?
2002-10-15 19:32 [patch, 2.5] __vmalloc allocates spurious page? Marcus Alanen
@ 2002-10-15 21:58 ` Marcus Alanen
2002-10-15 22:05 ` Russell King
0 siblings, 1 reply; 5+ messages in thread
From: Marcus Alanen @ 2002-10-15 21:58 UTC (permalink / raw)
To: maalanen, Andrew Morton; +Cc: linux-kernel
>The unnecessary page is allocated only if size is initially a multiple
>of PAGE_SIZE, which sounds like a common case.
Actually, size is already PAGE_ALIGNed, so we get the amount of pages
even easier.
Marcus
diff -Naurd --exclude-from=/home/maalanen/linux/base/diff_exclude linus-2.5.42/mm/vmalloc.c msa-2.5.42/mm/vmalloc.c
--- linus-2.5.42/mm/vmalloc.c Sat Oct 12 16:42:57 2002
+++ msa-2.5.42/mm/vmalloc.c Wed Oct 16 00:52:33 2002
@@ -387,7 +387,7 @@
if (!area)
return NULL;
- nr_pages = (size+PAGE_SIZE) >> PAGE_SHIFT;
+ nr_pages = size >> PAGE_SHIFT;
array_size = (nr_pages * sizeof(struct page *));
area->nr_pages = nr_pages;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch, 2.5] __vmalloc allocates spurious page?
2002-10-15 21:58 ` Marcus Alanen
@ 2002-10-15 22:05 ` Russell King
2002-10-15 22:11 ` William Lee Irwin III
2002-10-15 22:21 ` Andrew Morton
0 siblings, 2 replies; 5+ messages in thread
From: Russell King @ 2002-10-15 22:05 UTC (permalink / raw)
To: Marcus Alanen; +Cc: maalanen, Andrew Morton, linux-kernel
On Wed, Oct 16, 2002 at 12:58:12AM +0300, Marcus Alanen wrote:
> >The unnecessary page is allocated only if size is initially a multiple
> >of PAGE_SIZE, which sounds like a common case.
>
> Actually, size is already PAGE_ALIGNed, so we get the amount of pages
> even easier.
IIRC, back in the dim and distant past, the extra page was originally to
catch things running off the end of their space (eg, modules). The
idea was that modules (and other vmalloc'd areas) would be separated
by one unmapped page.
It looks like this got broken recently though.
--
Russell King (rmk@arm.linux.org.uk) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [patch, 2.5] __vmalloc allocates spurious page?
2002-10-15 22:05 ` Russell King
@ 2002-10-15 22:11 ` William Lee Irwin III
2002-10-15 22:21 ` Andrew Morton
1 sibling, 0 replies; 5+ messages in thread
From: William Lee Irwin III @ 2002-10-15 22:11 UTC (permalink / raw)
To: Russell King; +Cc: Marcus Alanen, maalanen, Andrew Morton, linux-kernel
On Wed, Oct 16, 2002 at 12:58:12AM +0300, Marcus Alanen wrote:
>> Actually, size is already PAGE_ALIGNed, so we get the amount of pages
>> even easier.
On Tue, Oct 15, 2002 at 11:05:06PM +0100, Russell King wrote:
> IIRC, back in the dim and distant past, the extra page was originally to
> catch things running off the end of their space (eg, modules). The
> idea was that modules (and other vmalloc'd areas) would be separated
> by one unmapped page.
> It looks like this got broken recently though.
Hmm? I looked briefly to check the patch and the guard page was added
onto the thing elsewhere in vmalloc.c
Bill
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch, 2.5] __vmalloc allocates spurious page?
2002-10-15 22:05 ` Russell King
2002-10-15 22:11 ` William Lee Irwin III
@ 2002-10-15 22:21 ` Andrew Morton
1 sibling, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2002-10-15 22:21 UTC (permalink / raw)
To: Russell King; +Cc: Marcus Alanen, maalanen, linux-kernel
Russell King wrote:
>
> On Wed, Oct 16, 2002 at 12:58:12AM +0300, Marcus Alanen wrote:
> > >The unnecessary page is allocated only if size is initially a multiple
> > >of PAGE_SIZE, which sounds like a common case.
> >
> > Actually, size is already PAGE_ALIGNed, so we get the amount of pages
> > even easier.
>
> IIRC, back in the dim and distant past, the extra page was originally to
> catch things running off the end of their space (eg, modules). The
> idea was that modules (and other vmalloc'd areas) would be separated
> by one unmapped page.
>
> It looks like this got broken recently though.
Still there I think.
struct vm_struct *get_vm_area(unsigned long size, unsigned long flags)
{
...
/*
* We always allocate a guard page.
*/
size += PAGE_SIZE;
Marcus's patch looks reasonable.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-10-15 22:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-15 19:32 [patch, 2.5] __vmalloc allocates spurious page? Marcus Alanen
2002-10-15 21:58 ` Marcus Alanen
2002-10-15 22:05 ` Russell King
2002-10-15 22:11 ` William Lee Irwin III
2002-10-15 22:21 ` Andrew Morton
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.