On Wed, Oct 14, 2020 at 09:17:04AM -0700, Darrick J. Wong wrote: > On Wed, Oct 14, 2020 at 04:03:45AM +0100, Matthew Wilcox (Oracle) wrote: > > If the page is compound, check the last index in the page and return > > the appropriate size. Change the return type to ssize_t in case we ever > > support pages larger than 2GB. > > "But what about 16G pages?" :P They're not practical with today's I/O limits; a x4 PCIe link running at gen4 speeds will take 2 seconds to do 16GB of I/O. Assuming doubling of PCIe speeds every four years, and a reasonable latency of 0.1 seconds, we're about fifteen years away from that being reasonable. I'm sure this code will have bitrotted by then and whoever tries to add support for them will have work to do ... > > /* page is wholly inside EOF */ > > - if (page->index < index) > > - return PAGE_SIZE; > > + if (page->index + thp_nr_pages(page) - 1 < index) > > Just curious, is this expression common enough to create a helper for > that too? > > #define thp_last_index(page) ((page)->index + thp_nr_pages(page) - 1) ? > > (Maybe make that a static inline, I used a macro for brevity) I had that in an earlier version and there were two callers, so I took it out again because it was more effort to explain what it did than it was to open-code it.