Re: Newbie: allocating aligned physically-contiguous memory?



Neil Steiner <neil.steiner@xxxxxx> wrote:
Here's what I need to do:
1. Allocate block of 0x00200000 physically contiguous bytes from memory.
2. Guarantee the block is aligned on a physical 0x00200000 boundary.
3. Make the block visible from user space, if possible.

It would be nice to just kmalloc(0x00200000,GFP_USER), but that wouldn't
give me any way to enforce the physical alignment requirement. I'm sure
someone here has done this kind of thing a million times. Any ideas?
Anything I should be reading up on?

I guess you should have a look at the __get_free_pages() function,
it returns (if available) a number of physically contiguous pages
(of course starting on a page bondary-:). It's defined as

__get_free_pages( unsigned int flags, unsigned int order )

The 'flags' argument is the same as for kmalloc() and 'order'
is the base-two logarithm of the number of pages you are re-
questing (i.e. 21 in your case if I got the maths right;-).
The function exists for both 2.4 and 2.6 kernels (include
<linux/slab.h> for the declaration).

Regards, Jens
--
\ Jens Thoms Toerring ___ jt@xxxxxxxxxxx
\__________________________ http://toerring.de
.



Relevant Pages

  • RE: .NET SUCKS --- READ FOLLOWING. MICROSOFT IS A SUCKY CO
    ... Any application that must guarantee a response 100% of the time within 1 ... PREALLOCATE all memory you need, ... If your response time requirements are 1 second, ... The app has to respond to the requests in no more than 1 s. ...
    (microsoft.public.dotnet.framework)
  • Re: (OT)Kissing Robot (from Japan, natch)
    ... guarantee that she won't destroy the universe? ... do I have any guarantee that she ... Will her memory will be wiped if she fails her trial deployment? ...
    (rec.arts.anime.misc)
  • Re: [ckrm-tech] [RFC][PATCH 5/8] RSS controller task migration support
    ... This seems to be correct for resources like cpu, disk or network ... some pages of a job remain in memory when the system is low on free ... a smooth activity compared to a group/container B with a set of jobs ... The idea of getting a guarantee is simple: ...
    (Linux-Kernel)
  • Re: WaitForSingleObject() will not deadlock
    ... Even though the assignment of value 2 is guaranteed ... compiler's guarantee), without the specific guarantee from the thread ... the *compiler* does not guarantee this. ... Any data written to memory after the new thread is ...
    (microsoft.public.vc.mfc)
  • Re: [Lhms-devel] [PATCH 0/7] Fragmentation Avoidance V19
    ... > rate of features and complexity going in. ... guarantee things, kswapd would need to know how to clear out UesrRclm ... > kernel memory. ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)