2001-11-19 19:24:27

by George Anzinger

[permalink] [raw]
Subject: Memory allocation question

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?


--
George [email protected]
High-res-timers: http://sourceforge.net/projects/high-res-timers/
Real time sched: http://sourceforge.net/projects/rtsched/


2001-11-19 19:42:28

by Alan

[permalink] [raw]
Subject: Re: Memory allocation question

> 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

2001-11-21 18:47:48

by George Anzinger

[permalink] [raw]
Subject: Re: Memory allocation question

Alan Cox wrote:
>
> > 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() ?

--
George [email protected]
High-res-timers: http://sourceforge.net/projects/high-res-timers/
Real time sched: http://sourceforge.net/projects/rtsched/

2001-11-21 18:52:28

by Rik van Riel

[permalink] [raw]
Subject: Re: Memory allocation question

On Wed, 21 Nov 2001, george anzinger wrote:
> Alan Cox wrote:
> >
> > > 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
--
DMCA, SSSCA, W3C? Who cares? http://thefreeworld.net/

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

2001-11-21 20:14:04

by George Anzinger

[permalink] [raw]
Subject: Re: Memory allocation question

Rik van Riel wrote:
>
> On Wed, 21 Nov 2001, george anzinger wrote:
> > Alan Cox wrote:
> > >
> > > > 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.
>
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?
--
George [email protected]
High-res-timers: http://sourceforge.net/projects/high-res-timers/
Real time sched: http://sourceforge.net/projects/rtsched/

2001-11-21 20:26:28

by Rik van Riel

[permalink] [raw]
Subject: Re: Memory allocation question

On Wed, 21 Nov 2001, george anzinger wrote:

> /*
> * 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
--
DMCA, SSSCA, W3C? Who cares? http://thefreeworld.net/

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