Information on kernel linux movable memory (__GFP_MOVABLE flag)

25 Views Asked by At

I would need some information about memory management in the Linux kernel when using the __GFP_MOVABLE flag. The operating principle is clear; its function is to reduce memory fragmentation. What is not clear to me is how to correctly use a memory block allocated with kmalloc and the __GFP_MOVABLE flag.

void* buf;

buf = kmalloc(1000, GFP_KERNEL | __GFP_MOVABLE);
    

[After a long time]

    
kfree(buf);

Based on what I have read, the memory block allocated with kmalloc can be moved in the background to reduce fragmentation. So, could the return value from kmalloc (variable buf) at some point indicate a portion of memory that is no longer valid ? What precautions should I take to correctly use the memory portion pointed to by the variable buf ?

Thank you very much, Massimo

0

There are 0 best solutions below