Skip to contentSkip to conversation

Memory allocation question

DISCUSSION george anzinger 3 participants 6 messages Nov 19, 2001 – Nov 21, 2001

lore
Share & tools
lore
#0 lore raw

I need (want) to allocate block of memory for POSIX timers in about page size chuncks. Currently I am using kmalloc() to allocate a page at a time. I don't want to have to worry about mapping/unmapping etc. I just what to go about using the memory. It will be used for timers so it must not be paged.

Is kmalloc() the best interface to use or is there a better one?

Signature · 3 lines
George           [email protected]
High-res-timers: http://sourceforge.net/projects/high-res-timers/
Real time sched: http://sourceforge.net/projects/rtsched/
#1 lore raw
Quoted 2 lines

size chuncks. Currently I am using kmalloc() to allocate a page at a time. I don't want to have to worry about mapping/unmapping etc. I

Use get_free_page() to get page sized chunks

#2 lore raw
Quoted 5 lines · Alan Cox
Quoted 3 lines

size chuncks. Currently I am using kmalloc() to allocate a page at a time. I don't want to have to worry about mapping/unmapping etc. I

Use get_free_page() to get page sized chunks

What about __get_free_page() ? I don't need or want the clear page (performance issues).

And then to return the page, free_page() ?

Signature · 3 lines
George           [email protected]
High-res-timers: http://sourceforge.net/projects/high-res-timers/
Real time sched: http://sourceforge.net/projects/rtsched/
#3 lore raw
Quoted 9 lines · george anzinger
Quoted 5 lines · Alan Cox
Quoted 3 lines

size chuncks. Currently I am using kmalloc() to allocate a page at a time. I don't want to have to worry about mapping/unmapping etc. I

Use get_free_page() to get page sized chunks

What about __get_free_page() ? I don't need or want the clear page (performance issues).

get_free_page() doesn't clear the page afaics.

regards,

Rik

Signature · 3 lines
DMCA, SSSCA, W3C?  Who cares?  http://thefreeworld.net/

http://www.surriel.com/		http://distro.conectiva.com/
#4 lore raw
Quoted 7 lines · Rik van Riel
Quoted 5 lines · george anzinger
Quoted 4 lines · Alan Cox
Quoted 3 lines

size chuncks. Currently I am using kmalloc() to allocate a page at a time. I don't want to have to worry about mapping/unmapping etc. I

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Use get_free_page() to get page sized chunks

What about __get_free_page() ? I don't need or want the clear page (performance issues).

get_free_page() doesn't clear the page afaics.

In mm.h (2.4.13 kernel)....

#define __get_free_page(gfp_mask) \
		__get_free_pages((gfp_mask),0)
#define __get_dma_pages(gfp_mask, order) \
		__get_free_pages((gfp_mask) | GFP_DMA,(order))

/*
* The old interface name will be removed in 2.5:
*/
#define get_free_page get_zeroed_page
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Where as __get_free_page() does not zero. I know this is an old kernel, but...

What am I missing?

Signature · 3 lines
George           [email protected]
High-res-timers: http://sourceforge.net/projects/high-res-timers/
Real time sched: http://sourceforge.net/projects/rtsched/
#5 lore raw
Quoted 8 lines · george anzinger

/*
* The old interface name will be removed in 2.5:
*/
#define get_free_page get_zeroed_page
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Where as __get_free_page() does not zero. I know this is an old kernel, but...

Urghhh, you're right.

Rik

Signature · 3 lines
DMCA, SSSCA, W3C?  Who cares?  http://thefreeworld.net/

http://www.surriel.com/		http://distro.conectiva.com/