[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
what stops someone from calling kmalloc() with __GFP_HIGHMEM??
according to love's book on kernel development, p. 190:
"You cannot specify __GFP_HIGHMEM to either __get_free_pages() or
kmalloc(). Because these both return a logical address, and not a
page structure, it is possible these functions would allocate memory
that is not currently mapped in the kernel's virtual address space
and, thus, does not have a logical address."
but, AFIACT, there's nothing to stop you from doing such a thing.
if you look in mm/page_alloc.c, you can read:
fastcall unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order)
{
struct page * page;
page = alloc_pages(gfp_mask, order);
if (!page)
return 0;
return (unsigned long) page_address(page);
}
as you can see, there's no check on whether __GFP_HIGHMEM was
specified -- the routine simply calls alloc_pages(), which *is*
allowed to accept __GFP_HIGHMEM as a zone modifier.
so what's to stop someone from calling __get_free_pages()
incorrectly with __GFP_HIGHMEM?
rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA
http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ