Thread (17 messages) 17 messages, 7 authors, 2026-04-02

Re: [PATCH 0/8] mm: globalize rest_of_page() macro

From: Yury Norov <hidden>
Date: 2026-03-04 03:33:10
Also in: dm-devel, dri-devel, intel-gfx, kvm, linux-block, linux-crypto, linux-ext4, linux-f2fs-devel, linux-fsdevel, linux-mm, linux-nfs, linux-perf-users, linux-riscv, linux-s390, linux-sound, linux-spi, linux-xfs, lkml, netdev, v9fs, virtualization

On Tue, Mar 03, 2026 at 06:49:36PM -0800, Sean Christopherson wrote:
On Tue, Mar 03, 2026, Jens Axboe wrote:
quoted
On 3/3/26 7:28 PM, Jakub Kicinski wrote:
quoted
On Tue,  3 Mar 2026 20:27:08 -0500 Yury Norov wrote:
quoted
The net/9p networking driver has a handy macro to calculate the
amount of bytes from a given pointer to the end of page. Move it
to core/mm, and apply tree-wide. No functional changes intended.

This series was originally introduced as a single patch #07/12 in:

https://lore.kernel.org/all/20260219181407.290201-1-ynorov@nvidia.com/ (local)

Split it for better granularity and submit separately.
I don't get what the motivation is here. Another helper developers
and readers of the code will need to know about just to replace 
obvious and easy to comprehend math.
I fully agree, I had the same thought reading this.
+1 from KVM-land.
My motivation is that it helps to simplify constructions like this:

-               loff_t cmp_len = min(PAGE_SIZE - offset_in_page(srcoff),
-                                    PAGE_SIZE - offset_in_page(dstoff));
+               loff_t cmp_len = min(rest_of_page(srcoff), rest_of_page(dstoff));

Or this:

-               if (folio_test_highmem(dst_folio) &&
-                   chunk > PAGE_SIZE - offset_in_page(dst_off))
-                       chunk = PAGE_SIZE - offset_in_page(dst_off);
-               if (folio_test_highmem(src_folio) &&
-                   chunk > PAGE_SIZE - offset_in_page(src_off))
-                       chunk = PAGE_SIZE - offset_in_page(src_off);
+               if (folio_test_highmem(dst_folio) && chunk > rest_of_page(dst_off))
+                       chunk = rest_of_page(dst_off);
+               if (folio_test_highmem(src_folio) && chunk > rest_of_page(src_off))
+                       chunk = rest_of_page(src_off);

To a point where I don't have to use my brains to decode them. I agree
it's an easy math. It's just too bulky to my (and 9p guys too) taste.

Thanks,
Yury
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help