npages_in_range(9)

๐Ÿ“ฆ version 7.3.1, in nixpkgs unstable

๐Ÿ’… npages_in_range(9) โ€” Kernel API Manual

okay bestie, so this is a page from the Kernel API Manual and honestly it's giving "small macro, big job" energy. Let's get into it โœจ


๐ŸŒธ NAME ๐ŸŒธ

npages_in_range โ€” literally just: calculate the number of pages in a given range. that's it. that's the whole vibe ๐ŸŽ€


โœจ SYNOPSIS โœจ

unsigned long npages_in_range (unsigned long start , unsigned long end
);

like, you hand it two unsigned longs and it hands you back an unsigned long. no cap, that's the whole signature ๐Ÿซถ


๐Ÿงš ARGUMENTS ๐Ÿงš

  • start โ€” the start address of the range. where the vibe begins ๐Ÿ’–
  • end โ€” the end address of the range. where the vibe stops ๐Ÿฆ‹

๐Ÿ”ฅ DESCRIPTION ๐Ÿ”ฅ

okay so here's the tea โ˜• โ€” this macro calculates the number of pages in a given memory range, and that range is specified by the start and end addresses.

how does it do it? it takes the difference between the end and start addresses and divides that by the page size (PAGE_SIZE) to determine the number of pages in the range. math girlie behavior, honestly ๐Ÿงฎ๐Ÿ’…


๐Ÿ‘‘ RETURN ๐Ÿ‘‘

the number of pages in the specified range. iconic. periodt. โญ


๐ŸŒˆ SEE ALSO ๐ŸŒˆ

no like there's a whole friend group here, iykyk ๐Ÿ’œ


okay that's the whole page bestie, go divide something by PAGE_SIZE and slay ๐Ÿ’…

source/version: ./drivers/gpu/drm ยท dated October 2026 ยท and yeah, it's npages_in_range(9) the whole way through ๐ŸŽ€โœจ

๐Ÿ“ฆ where this page comes from