Highlight a large (32 MB) contiguous region

Is it possible to isolate large (i.e. 32 MB) physically contiguous areas of memory from the kernel code at runtime (i.e. do not use bootmem)? From my experiments it seems that it is impossible to get anything more than a piece of 4 MB, regardless of which GFP flags I use. According to the documentation I read, GFP_NOFAIL should make kmalloc just wait until it is needed to free the requested amount, but from what I can say it just makes the request hang indefinitely if you request more than available - it seems to be doesn't try to actively free memory to execute the request (i.e. kswapd doesn't seem to work). Is there a way to tell the kernel to aggressively start replacing material to free the requested allocation?

Edit: So, I see from Eugene’s answer that it will not be possible to get a 32-megabyte region from one kilometer ... but is there any way to do this in a more hacker way? How to identify the largest available contiguous region, then manually transfer / replace data on either side of it?

Or how about something like this:

1) Grab a bunch of 4mb chunks until you're out of memory. 2) Check them all to see if any of them happen to be contiguous, if so, combine them. 3) kfree the rest 4) goto 1) 

Could this work if you have enough time to start?

+4
source share
2 answers

You might want to take a look at the Allocator related memory plugins . Judging by the LWN article, these fixes are exactly what you need.

+1
source

Link Mircea - one of the options; if you have an IOMMU on your device, you can use it to display a continuous view over many non-contiguous pages in memory.

0
source

Source: https://habr.com/ru/post/1369108/


All Articles