get_order(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

get_order(9) πŸ’…

okay bestie, welcome to the Kernel API Manual page for get_order β€” yes, the function name is literally the whole vibe. It's here to tell you the allocation order for a memory size, and we're gonna get into it.


✨ NAME ✨

get_order β€” determine the allocation order of a memory size πŸ’–

πŸŽ€ SYNOPSIS πŸŽ€

int get_order (unsigned long size );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • size β€” the size for which you want to get the order. That's the whole input, bestie; hand it a size and it does its little logarithmic thing. 🫢

πŸ”₯ DESCRIPTION πŸ”₯

so get_order determines the allocation order of a particular sized block of memory. It's on a logarithmic scale, and the mapping is giving:

  • 0 -> 2^0 * PAGE_SIZE and below
  • 1 -> 2^1 * PAGE_SIZE to 2^0 * PAGE_SIZE + 1
  • 2 -> 2^2 * PAGE_SIZE to 2^1 * PAGE_SIZE + 1
  • 3 -> 2^3 * PAGE_SIZE to 2^2 * PAGE_SIZE + 1
  • 4 -> 2^4 * PAGE_SIZE to 2^3 * PAGE_SIZE + 1
  • ...

The order that comes back is used to find the smallest allocation granule required to hold an object of the specified size. Very "smallest container that fits the fit" energy. πŸŽ€

⚠️ heads up, bestie: the result is undefined if the size is 0. Not "zero-ish", not "tiny", literally undefined. Don't do it. πŸ’€

🌈 SEE ALSO 🌈

  • Kernel file ./include/asm-generic/getorder.h πŸ“

and that's the page, periodt. this cutie is sourced from ./include/asm-generic, dated October 2026, and it's serving get_order(9) realness. πŸ’–βœ¨

πŸ“¦ where this page comes from