* [Q] get_ma_area() function
@ 2002-05-07 11:58 Andrey Panin
2002-05-07 13:58 ` Hugh Dickins
0 siblings, 1 reply; 2+ messages in thread
From: Andrey Panin @ 2002-05-07 11:58 UTC (permalink / raw)
To: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 573 bytes --]
Hi,
looking at mm/vmalloc.c i found one strange (for me) line of code.
From mm/vmalloc.c:
struct vm_struct * get_vm_area(unsigned long size, unsigned long flags)
{
unsigned long addr;
struct vm_struct **p, *tmp, *area;
area = (struct vm_struct *) kmalloc(sizeof(*area), GFP_KERNEL);
if (!area)
return NULL;
size += PAGE_SIZE;
^^^^^^^^^^^^^^^^^^
Why ? Maybe size = PAGE_ALIGN(size); is more correct here ?
Best regards.
--
Andrey Panin | Embedded systems software engineer
pazke@orbita1.ru | PGP key: wwwkeys.eu.pgp.net
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [Q] get_ma_area() function
2002-05-07 11:58 [Q] get_ma_area() function Andrey Panin
@ 2002-05-07 13:58 ` Hugh Dickins
0 siblings, 0 replies; 2+ messages in thread
From: Hugh Dickins @ 2002-05-07 13:58 UTC (permalink / raw)
To: Andrey Panin; +Cc: linux-kernel
On Tue, 7 May 2002, Andrey Panin wrote:
>
> looking at mm/vmalloc.c i found one strange (for me) line of code.
>
> From mm/vmalloc.c:
>
> struct vm_struct * get_vm_area(unsigned long size, unsigned long flags)
> {
> unsigned long addr;
> struct vm_struct **p, *tmp, *area;
>
> area = (struct vm_struct *) kmalloc(sizeof(*area), GFP_KERNEL);
> if (!area)
> return NULL;
> size += PAGE_SIZE;
> ^^^^^^^^^^^^^^^^^^
> Why ? Maybe size = PAGE_ALIGN(size); is more correct here ?
No, __vmalloc already did the size = PAGE_ALIGN(size).
Here it is intentionally adding one page to the virtual allocation size,
to leave one invalid guard or fence page between vmalloc'ed allocations,
to trap overruns from one area to the next. You're right, a comment
would be appropriate there.
Hugh
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-05-07 13:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-07 11:58 [Q] get_ma_area() function Andrey Panin
2002-05-07 13:58 ` Hugh Dickins
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®