6

I would like to change my kernel's page size from 4KB to 4MB as I have had a large addition of RAM to my computer and I am never running out of anymore.

The idea is that programs requiring large amounts of memory will spend less time on allocating pages. I suppose it would improve performance, and I would like to try.

I can’t find anywhere when running make menuconfig. Is there a way to do that?

3 Answers 3

7

The PAGESIZE is set at kernel compile time. That selection is only valid for i386 hardware. If you run a 64-bit system or any other architecture, the page size is 4K and cannot be changed.

1
  • 2
    To verify PAGE_SIZE you can use the command getconf PAGE_SIZE Jun 2, 2016 at 18:15
5

You probably want to look at Transparent Hugepages. The .config item is CONFIG_TRANSPARENT_HUGEPAGE. Note that enabling this won't give you huge pages automatically. You'll need to set the CONFIG_TRANSPARENT_HUGEPAGE_MADVISE to 'n', in order to make it the default.

Also note that this doesn't allow you to choose an arbitrary page size. I allows to use the huge page size of the architecture. For x86_64 this is 1Mb, see https://en.wikipedia.org/wiki/Page_(computer_memory)#Huge_pages for the full table.

1

Slabs seem to be an exact solution you are just looking for. Slabs are memory units pre-allocated by kernel and should more or less avoid the allocation overhead, which seems just what you are trying to reach.

For more information, see Wikipedia: Slab allocation

Changing page size (if it was possible) to an amount of 1MiB would cause excessive memory waste. Many (I mean dozens of) subprocesses and daemons take up just few kB of memory. Is any memory that cheap?

1
  • Even if there were a hundred or more of these sub-processes running, 200MB of RAM isn't that much for someone with 16GB, it's not like I ever come close to maxing that out(I don't game on this machine). Not that I think you'd necessarily see a lot of performance gains from using huge pages. Jun 20, 2021 at 23:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .