linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Is there a different memory allocation path other than the buddy allocator?
@ 2021-04-28  7:37 Shivank Garg
  2021-04-28 14:44 ` David Hildenbrand
  0 siblings, 1 reply; 2+ messages in thread
From: Shivank Garg @ 2021-04-28  7:37 UTC (permalink / raw)
  To: linux-kernel, linux-mm, akpm, gregkh, sergey.senozhatsky, pmladek

Hi Everyone!

I'm understanding memory allocation in Linux and doing some changes in
buddy allocator (__alloc_pages_nodemask) for my experiments. I create
a new flag in `struct page->flags` (by adding a new flag in `enum
pageflags` in `page-flags.h`. I set this bit permanently in
__alloc_pages_nodemask (to not to be cleared once set and survive all
further allocation and freeing). But I'm not able to see expected
behavior.

I'm guessing this is because Linux is also using some different path
to allocate memory (probably during boot). Is my hypothesis correct?

Is there any different memory allocation path other than buddy
allocator? Where can I find it?

To keep the newly added bit in the page_flag set for 'struct page'
lifetime.  I make sure not to clear it while freeing by unsetting it
in "#define PAGE_FLAGS_CHECK_AT_PREP       \
-       (((1UL << NR_PAGEFLAGS) - 1) & ~__PG_HWPOISON & ~(1UL <<
PG_NEWEXPFLAG))" I know  adding new bits in page->flag is probably not
a good idea but this if for better understanding :)

Thank You and stay safe!

Best Regards,
Shivank


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Is there a different memory allocation path other than the buddy allocator?
  2021-04-28  7:37 Is there a different memory allocation path other than the buddy allocator? Shivank Garg
@ 2021-04-28 14:44 ` David Hildenbrand
  0 siblings, 0 replies; 2+ messages in thread
From: David Hildenbrand @ 2021-04-28 14:44 UTC (permalink / raw)
  To: Shivank Garg, linux-kernel, linux-mm, akpm, gregkh,
	sergey.senozhatsky, pmladek

On 28.04.21 09:37, Shivank Garg wrote:
> Hi Everyone!
> 
> I'm understanding memory allocation in Linux and doing some changes in
> buddy allocator (__alloc_pages_nodemask) for my experiments. I create
> a new flag in `struct page->flags` (by adding a new flag in `enum
> pageflags` in `page-flags.h`. I set this bit permanently in
> __alloc_pages_nodemask (to not to be cleared once set and survive all
> further allocation and freeing). But I'm not able to see expected
> behavior.
> 
> I'm guessing this is because Linux is also using some different path
> to allocate memory (probably during boot). Is my hypothesis correct?
> 
> Is there any different memory allocation path other than buddy
> allocator? Where can I find it?

memblock is the early memory allocator during boot, before the buddy is 
up and running. The range allocator (e.g., alloc_contig_range()) is some 
kind of mechanism that builds up on top of the buddy. Other allcoators 
(hugetlb, slab, ...) might cache some pages, but effectively get 
"physical memory" either via memblock or the buddy.

CMA is another special-purpose allocator which reserves physical memory 
areas via memblock and then uses the range allocator to actually 
allocate memory inside these reserved regions at runtime.

-- 
Thanks,

David / dhildenb



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-28 14:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-28  7:37 Is there a different memory allocation path other than the buddy allocator? Shivank Garg
2021-04-28 14:44 ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox