Skip to contentSkip to conversation

way to allocate memory within a range ?

DISCUSSION Auguste Mome 4 participants 5 messages Feb 24, 2010 – Mar 21, 2010 Memory management

lore
Share & tools
lore
#0 lore raw

Hello,
I'd like to use kmem_cache() system, but need the memory taken from a specific range if requested, outside the range otherwise.
I think about adding new zone and define new GFP flag to either select or ignore the zone. Does it sound possible? Then I welcome any hint if you know where to add the appropriated test in allocator, how to attach the region to the new zone id).

Or slab/slub system is not designed for this, I should forget it and opt for another system?

August.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw
Quoted 10 lines · Auguste Mome

I'd like to use kmem_cache() system, but need the memory taken from a specific range if requested, outside the range otherwise.
I think about adding new zone and define new GFP flag to either select or ignore the zone. Does it sound possible? Then I welcome any hint if you know where to add the appropriated test in allocator, how to attach the region to the new zone id).

Or slab/slub system is not designed for this, I should forget it and opt for another system?

No slab allocator is going to be designed for that other than SLAB_DMA to allocate from lowmem. If you don't have need for lowmem, why do you need memory only from a certain range? I can imagine it would have a usecase for memory hotplug to avoid allocating slab that cannot be reclaimed on certain nodes, but ZONE_MOVABLE seems more appropriate to guarantee such migration properties.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#4 lore raw
In reply to Auguste Mome
Quoted 11 lines · On Wed, 24 Feb 2010 01:46:49 +0100 Auguste Mome <[email protected]> wrote:

Hello,
I'd like to use kmem_cache() system, but need the memory taken from a specific range if requested, outside the range otherwise.
I think about adding new zone and define new GFP flag to either select or ignore the zone. Does it sound possible? Then I welcome any hint if you know where to add the appropriated test in allocator, how to attach the region to the new zone id).

Or slab/slub system is not designed for this, I should forget it and opt for another system?

I think you can find adding a new zone is very hard. please forget.

But for what purpose you want to specifiy phyiscal address of memory ?

Thanks,
-Kame

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw
In reply to David Rientjes
Quoted 10 lines · David Rientjes
Quoted 3 lines

Or slab/slub system is not designed for this, I should forget it and opt for another system?

No slab allocator is going to be designed for that other than SLAB_DMA to allocate from lowmem. If you don't have need for lowmem, why do you need memory only from a certain range? I can imagine it would have a usecase for memory hotplug to avoid allocating slab that cannot be reclaimed on certain nodes, but ZONE_MOVABLE seems more appropriate to guarantee such migration properties.

Awhile ago I posted a patch to do just that. It was called alloc_pages_range() and the intend was to replace the dma zone.

http://lkml.indiana.edu/hypermail/linux/kernel/0609.2/2096.html

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw

OK thanks for your comments, I found that mempool() API can do the job I need, because
I can live with a fixed size for allocated object, so I plan to populate the pool by adding all the
"cells" of the given range.
My use case is another module aside Linux that would map the the same memory area.

August.

Quoted 13 lines · Christoph Lameter
Quoted 10 lines · David Rientjes
Quoted 3 lines

Or slab/slub system is not designed for this, I should forget it and opt for another system?

No slab allocator is going to be designed for that other than SLAB_DMA to allocate from lowmem.  If you don't have need for lowmem, why do you need memory only from a certain range?  I can imagine it would have a usecase for memory hotplug to avoid allocating slab that cannot be reclaimed on certain nodes, but ZONE_MOVABLE seems more appropriate to guarantee such migration properties.

Quoted 6 lines

Awhile ago I posted a patch to do just that. It was called alloc_pages_range() and the intend was to replace the dma zone.

http://lkml.indiana.edu/hypermail/linux/kernel/0609.2/2096.html

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>