From: Yury Norov <ynorov@nvidia.com>
To: Andrew Morton <akpm@linux-foundation.org>,
"David S. Miller" <davem@davemloft.net>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Theodore Ts'o" <tytso@mit.edu>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexander Duyck <alexanderduyck@fb.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Alexandra Winter <wintera@linux.ibm.com>,
Andreas Dilger <adilger.kernel@dilger.ca>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Anna Schumaker <anna@kernel.org>,
Anton Yakovlev <anton.yakovlev@opensynergy.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Aswin Karuvally <aswin@linux.ibm.com>,
Borislav Petkov <bp@alien8.de>, Carlos Maiolino <cem@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Chao Yu <chao@kernel.org>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Christian Brauner <brauner@kernel.org>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
David Airlie <airlied@gmail.com>,
Dominique Martinet <asmadeus@codewreck.org>,
Dongsheng Yang <dongsheng.yang@linux.dev>,
Eric Dumazet <edumazet@google.com>,
Eric Van Hensbergen <ericvh@kernel.org>,
Heiko Carstens <hca@linux.ibm.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
Ingo Molnar <mingo@redhat.com>, Jaegeuk Kim <jaegeuk@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Jani Nikula <jani.nikula@linux.intel.com>,
Janosch Frank <frankja@linux.ibm.com>,
Jaroslav Kysela <perex@perex.cz>, Jens Axboe <axboe@kernel.dk>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Latchesar Ionkov <lucho@ionkov.net>,
Linus Walleij <linusw@kernel.org>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Mark Brown <broonie@kernel.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Miklos Szeredi <miklos@szeredi.hu>,
Namhyung Kim <namhyung@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paolo Abeni <pabeni@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Paul Walmsley <pjw@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Sean Christopherson <seanjc@google.com>,
Simona Vetter <simona@ffwll.ch>, Takashi Iwai <tiwai@suse.com>,
Thomas Gleixner <tglx@kernel.org>,
Trond Myklebust <trondmy@kernel.org>,
Tvrtko Ursulin <tursulin@ursulin.net>,
Vasily Gorbik <gor@linux.ibm.com>, Will Deacon <will@kernel.org>,
Yury Norov <yury.norov@gmail.com>, Zheng Gu <cengku@gmail.com>
Cc: Yury Norov <ynorov@nvidia.com>,
linux-kernel@vger.kernel.org, x86@kernel.org,
linux-arm-kernel@lists.infradead.org,
linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org,
kvm@vger.kernel.org, linux-s390@vger.kernel.org,
linux-block@vger.kernel.org, intel-gfx@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, dm-devel@lists.linux.dev,
netdev@vger.kernel.org, linux-spi@vger.kernel.org,
linux-ext4@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org,
linux-nfs@vger.kernel.org, linux-crypto@vger.kernel.org,
linux-mm@kvack.org, linux-perf-users@vger.kernel.org,
v9fs@lists.linux.dev, virtualization@lists.linux.dev,
linux-sound@vger.kernel.org
Subject: [PATCH 4/8] core: use rest_of_page() macro where appropriate
Date: Tue, 3 Mar 2026 20:27:12 -0500 [thread overview]
Message-ID: <20260304012717.201797-5-ynorov@nvidia.com> (raw)
In-Reply-To: <20260304012717.201797-1-ynorov@nvidia.com>
Switch core and library code to using the macro. No functional
changes intended.
Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
include/crypto/scatterwalk.h | 2 +-
include/linux/highmem.h | 24 ++++++++++--------------
include/linux/iomap.h | 2 +-
include/linux/iov_iter.h | 3 +--
kernel/events/ring_buffer.c | 2 +-
lib/bitmap-str.c | 2 +-
lib/iov_iter.c | 5 ++---
7 files changed, 17 insertions(+), 23 deletions(-)
diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h
index 624fab589c2c..c671d5383c12 100644
--- a/include/crypto/scatterwalk.h
+++ b/include/crypto/scatterwalk.h
@@ -73,7 +73,7 @@ static inline unsigned int scatterwalk_clamp(struct scatter_walk *walk,
* page due to the data not being aligned to the algorithm's alignmask.
*/
if (IS_ENABLED(CONFIG_HIGHMEM))
- limit = PAGE_SIZE - offset_in_page(walk->offset);
+ limit = rest_of_page(walk->offset);
else
limit = PAGE_SIZE;
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index af03db851a1d..05528ba886fb 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -507,12 +507,10 @@ static inline void memcpy_folio(struct folio *dst_folio, size_t dst_off,
const char *src = kmap_local_folio(src_folio, src_off);
size_t chunk = len;
- 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);
memcpy(dst, src, chunk);
kunmap_local(src);
kunmap_local(dst);
@@ -580,9 +578,8 @@ static inline void memcpy_from_folio(char *to, struct folio *folio,
const char *from = kmap_local_folio(folio, offset);
size_t chunk = len;
- if (folio_test_partial_kmap(folio) &&
- chunk > PAGE_SIZE - offset_in_page(offset))
- chunk = PAGE_SIZE - offset_in_page(offset);
+ if (folio_test_partial_kmap(folio) && chunk > rest_of_page(offset))
+ chunk = rest_of_page(offset);
memcpy(to, from, chunk);
kunmap_local(from);
@@ -608,9 +605,8 @@ static inline void memcpy_to_folio(struct folio *folio, size_t offset,
char *to = kmap_local_folio(folio, offset);
size_t chunk = len;
- if (folio_test_partial_kmap(folio) &&
- chunk > PAGE_SIZE - offset_in_page(offset))
- chunk = PAGE_SIZE - offset_in_page(offset);
+ if (folio_test_partial_kmap(folio) && chunk > rest_of_page(offset))
+ chunk = rest_of_page(offset);
memcpy(to, from, chunk);
kunmap_local(to);
@@ -642,7 +638,7 @@ static inline __must_check void *folio_zero_tail(struct folio *folio,
size_t len = folio_size(folio) - offset;
if (folio_test_partial_kmap(folio)) {
- size_t max = PAGE_SIZE - offset_in_page(offset);
+ size_t max = rest_of_page(offset);
while (len > max) {
memset(kaddr, 0, max);
@@ -680,7 +676,7 @@ static inline void folio_fill_tail(struct folio *folio, size_t offset,
VM_BUG_ON(offset + len > folio_size(folio));
if (folio_test_partial_kmap(folio)) {
- size_t max = PAGE_SIZE - offset_in_page(offset);
+ size_t max = rest_of_page(offset);
while (len > max) {
memcpy(to, from, max);
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index 99b7209dabd7..6ae549192adb 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -142,7 +142,7 @@ static inline void *iomap_inline_data(const struct iomap *iomap, loff_t pos)
*/
static inline bool iomap_inline_data_valid(const struct iomap *iomap)
{
- return iomap->length <= PAGE_SIZE - offset_in_page(iomap->inline_data);
+ return iomap->length <= rest_of_page(iomap->inline_data);
}
/*
diff --git a/include/linux/iov_iter.h b/include/linux/iov_iter.h
index f9a17fbbd398..13a9ee653ef8 100644
--- a/include/linux/iov_iter.h
+++ b/include/linux/iov_iter.h
@@ -227,8 +227,7 @@ size_t iterate_xarray(struct iov_iter *iter, size_t len, void *priv, void *priv2
while (flen) {
void *base = kmap_local_folio(folio, offset);
- part = min_t(size_t, flen,
- PAGE_SIZE - offset_in_page(offset));
+ part = min_t(size_t, flen, rest_of_page(offset));
remain = step(base, progress, part, priv, priv2);
kunmap_local(base);
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 3e7de2661417..1db2868b90c9 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -590,7 +590,7 @@ long perf_output_copy_aux(struct perf_output_handle *aux_handle,
to &= (rb->aux_nr_pages << PAGE_SHIFT) - 1;
do {
- tocopy = PAGE_SIZE - offset_in_page(from);
+ tocopy = rest_of_page(from);
if (to > from)
tocopy = min(tocopy, to - from);
if (!tocopy)
diff --git a/lib/bitmap-str.c b/lib/bitmap-str.c
index be745209507a..a357342d5d6c 100644
--- a/lib/bitmap-str.c
+++ b/lib/bitmap-str.c
@@ -58,7 +58,7 @@ EXPORT_SYMBOL(bitmap_parse_user);
int bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp,
int nmaskbits)
{
- ptrdiff_t len = PAGE_SIZE - offset_in_page(buf);
+ ptrdiff_t len = rest_of_page(buf);
return list ? scnprintf(buf, len, "%*pbl\n", nmaskbits, maskp) :
scnprintf(buf, len, "%*pb\n", nmaskbits, maskp);
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 0a63c7fba313..c7e812349ca2 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -483,9 +483,8 @@ size_t copy_folio_from_iter_atomic(struct folio *folio, size_t offset,
char *to = kmap_local_folio(folio, offset);
n = bytes - copied;
- if (folio_test_partial_kmap(folio) &&
- n > PAGE_SIZE - offset_in_page(offset))
- n = PAGE_SIZE - offset_in_page(offset);
+ if (folio_test_partial_kmap(folio) && n > rest_of_page(offset))
+ n = rest_of_page(offset);
pagefault_disable();
n = __copy_from_iter(to, n, i);
--
2.43.0
WARNING: multiple messages have this Message-ID (diff)
From: Yury Norov via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: Andrew Morton <akpm@linux-foundation.org>,
"David S. Miller" <davem@davemloft.net>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Theodore Ts'o" <tytso@mit.edu>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexander Duyck <alexanderduyck@fb.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Alexandra Winter <wintera@linux.ibm.com>,
Andreas Dilger <adilger.kernel@dilger.ca>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Anna Schumaker <anna@kernel.org>,
Anton Yakovlev <anton.yakovlev@opensynergy.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Aswin Karuvally <aswin@linux.ibm.com>,
Borislav Petkov <bp@alien8.de>, Carlos Maiolino <cem@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Chao Yu <chao@kernel.org>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Christian Brauner <brauner@kernel.org>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
David Airlie <airlied@gmail.com>,
Dominique Martinet <asmadeus@codewreck.org>,
Dongsheng Yang <dongsheng.yang@linux.dev>,
Eric Dumazet <edumazet@google.com>,
Eric Van Hensbergen <ericvh@kernel.org>,
Heiko Carstens <hca@linux.ibm.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
Ingo Molnar <mingo@redhat.com>, Jaegeuk Kim <jaegeuk@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Jani Nikula <jani.nikula@linux.intel.com>,
Janosch Frank <frankja@linux.ibm.com>,
Jaroslav Kysela <perex@perex.cz>, Jens Axboe <axboe@kernel.dk>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Latchesar Ionkov <lucho@ionkov.net>,
Linus Walleij <linusw@kernel.org>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Mark Brown <broonie@kernel.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Miklos Szeredi <miklos@szeredi.hu>,
Namhyung Kim <namhyung@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paolo Abeni <pabeni@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Paul Walmsley <pjw@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Sean Christopherson <seanjc@google.com>,
Simona Vetter <simona@ffwll.ch>, Takashi Iwai <tiwai@suse.com>,
Thomas Gleixner <tglx@kernel.org>,
Trond Myklebust <trondmy@kernel.org>,
Tvrtko Ursulin <tursulin@ursulin.net>,
Vasily Gorbik <gor@linux.ibm.com>, Will Deacon <will@kernel.org>,
Yury Norov <yury.norov@gmail.com>, Zheng Gu <cengku@gmail.com>
Cc: kvm@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-mm@kvack.org, linux-riscv@lists.infradead.org,
linux-spi@vger.kernel.org, linux-s390@vger.kernel.org,
x86@kernel.org, Yury Norov <ynorov@nvidia.com>,
linux-ext4@vger.kernel.org, dm-devel@lists.linux.dev,
intel-gfx@lists.freedesktop.org, virtualization@lists.linux.dev,
linux-sound@vger.kernel.org, linux-block@vger.kernel.org,
linux-xfs@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-nfs@vger.kernel.org, netdev@vger.kernel.org,
v9fs@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-perf-users@vger.kernel.org, linux-crypto@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: [f2fs-dev] [PATCH 4/8] core: use rest_of_page() macro where appropriate
Date: Tue, 3 Mar 2026 20:27:12 -0500 [thread overview]
Message-ID: <20260304012717.201797-5-ynorov@nvidia.com> (raw)
In-Reply-To: <20260304012717.201797-1-ynorov@nvidia.com>
Switch core and library code to using the macro. No functional
changes intended.
Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
include/crypto/scatterwalk.h | 2 +-
include/linux/highmem.h | 24 ++++++++++--------------
include/linux/iomap.h | 2 +-
include/linux/iov_iter.h | 3 +--
kernel/events/ring_buffer.c | 2 +-
lib/bitmap-str.c | 2 +-
lib/iov_iter.c | 5 ++---
7 files changed, 17 insertions(+), 23 deletions(-)
diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h
index 624fab589c2c..c671d5383c12 100644
--- a/include/crypto/scatterwalk.h
+++ b/include/crypto/scatterwalk.h
@@ -73,7 +73,7 @@ static inline unsigned int scatterwalk_clamp(struct scatter_walk *walk,
* page due to the data not being aligned to the algorithm's alignmask.
*/
if (IS_ENABLED(CONFIG_HIGHMEM))
- limit = PAGE_SIZE - offset_in_page(walk->offset);
+ limit = rest_of_page(walk->offset);
else
limit = PAGE_SIZE;
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index af03db851a1d..05528ba886fb 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -507,12 +507,10 @@ static inline void memcpy_folio(struct folio *dst_folio, size_t dst_off,
const char *src = kmap_local_folio(src_folio, src_off);
size_t chunk = len;
- 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);
memcpy(dst, src, chunk);
kunmap_local(src);
kunmap_local(dst);
@@ -580,9 +578,8 @@ static inline void memcpy_from_folio(char *to, struct folio *folio,
const char *from = kmap_local_folio(folio, offset);
size_t chunk = len;
- if (folio_test_partial_kmap(folio) &&
- chunk > PAGE_SIZE - offset_in_page(offset))
- chunk = PAGE_SIZE - offset_in_page(offset);
+ if (folio_test_partial_kmap(folio) && chunk > rest_of_page(offset))
+ chunk = rest_of_page(offset);
memcpy(to, from, chunk);
kunmap_local(from);
@@ -608,9 +605,8 @@ static inline void memcpy_to_folio(struct folio *folio, size_t offset,
char *to = kmap_local_folio(folio, offset);
size_t chunk = len;
- if (folio_test_partial_kmap(folio) &&
- chunk > PAGE_SIZE - offset_in_page(offset))
- chunk = PAGE_SIZE - offset_in_page(offset);
+ if (folio_test_partial_kmap(folio) && chunk > rest_of_page(offset))
+ chunk = rest_of_page(offset);
memcpy(to, from, chunk);
kunmap_local(to);
@@ -642,7 +638,7 @@ static inline __must_check void *folio_zero_tail(struct folio *folio,
size_t len = folio_size(folio) - offset;
if (folio_test_partial_kmap(folio)) {
- size_t max = PAGE_SIZE - offset_in_page(offset);
+ size_t max = rest_of_page(offset);
while (len > max) {
memset(kaddr, 0, max);
@@ -680,7 +676,7 @@ static inline void folio_fill_tail(struct folio *folio, size_t offset,
VM_BUG_ON(offset + len > folio_size(folio));
if (folio_test_partial_kmap(folio)) {
- size_t max = PAGE_SIZE - offset_in_page(offset);
+ size_t max = rest_of_page(offset);
while (len > max) {
memcpy(to, from, max);
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index 99b7209dabd7..6ae549192adb 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -142,7 +142,7 @@ static inline void *iomap_inline_data(const struct iomap *iomap, loff_t pos)
*/
static inline bool iomap_inline_data_valid(const struct iomap *iomap)
{
- return iomap->length <= PAGE_SIZE - offset_in_page(iomap->inline_data);
+ return iomap->length <= rest_of_page(iomap->inline_data);
}
/*
diff --git a/include/linux/iov_iter.h b/include/linux/iov_iter.h
index f9a17fbbd398..13a9ee653ef8 100644
--- a/include/linux/iov_iter.h
+++ b/include/linux/iov_iter.h
@@ -227,8 +227,7 @@ size_t iterate_xarray(struct iov_iter *iter, size_t len, void *priv, void *priv2
while (flen) {
void *base = kmap_local_folio(folio, offset);
- part = min_t(size_t, flen,
- PAGE_SIZE - offset_in_page(offset));
+ part = min_t(size_t, flen, rest_of_page(offset));
remain = step(base, progress, part, priv, priv2);
kunmap_local(base);
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 3e7de2661417..1db2868b90c9 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -590,7 +590,7 @@ long perf_output_copy_aux(struct perf_output_handle *aux_handle,
to &= (rb->aux_nr_pages << PAGE_SHIFT) - 1;
do {
- tocopy = PAGE_SIZE - offset_in_page(from);
+ tocopy = rest_of_page(from);
if (to > from)
tocopy = min(tocopy, to - from);
if (!tocopy)
diff --git a/lib/bitmap-str.c b/lib/bitmap-str.c
index be745209507a..a357342d5d6c 100644
--- a/lib/bitmap-str.c
+++ b/lib/bitmap-str.c
@@ -58,7 +58,7 @@ EXPORT_SYMBOL(bitmap_parse_user);
int bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp,
int nmaskbits)
{
- ptrdiff_t len = PAGE_SIZE - offset_in_page(buf);
+ ptrdiff_t len = rest_of_page(buf);
return list ? scnprintf(buf, len, "%*pbl\n", nmaskbits, maskp) :
scnprintf(buf, len, "%*pb\n", nmaskbits, maskp);
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 0a63c7fba313..c7e812349ca2 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -483,9 +483,8 @@ size_t copy_folio_from_iter_atomic(struct folio *folio, size_t offset,
char *to = kmap_local_folio(folio, offset);
n = bytes - copied;
- if (folio_test_partial_kmap(folio) &&
- n > PAGE_SIZE - offset_in_page(offset))
- n = PAGE_SIZE - offset_in_page(offset);
+ if (folio_test_partial_kmap(folio) && n > rest_of_page(offset))
+ n = rest_of_page(offset);
pagefault_disable();
n = __copy_from_iter(to, n, i);
--
2.43.0
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
WARNING: multiple messages have this Message-ID (diff)
From: Yury Norov <ynorov@nvidia.com>
To: Andrew Morton <akpm@linux-foundation.org>,
"David S. Miller" <davem@davemloft.net>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Theodore Ts'o" <tytso@mit.edu>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexander Duyck <alexanderduyck@fb.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Alexandra Winter <wintera@linux.ibm.com>,
Andreas Dilger <adilger.kernel@dilger.ca>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Anna Schumaker <anna@kernel.org>,
Anton Yakovlev <anton.yakovlev@opensynergy.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Aswin Karuvally <aswin@linux.ibm.com>,
Borislav Petkov <bp@alien8.de>, Carlos Maiolino <cem@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Chao Yu <chao@kernel.org>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Christian Brauner <brauner@kernel.org>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
David Airlie <airlied@gmail.com>,
Dominique Martinet <asmadeus@codewreck.org>,
Dongsheng Yang <dongsheng.yang@linux.dev>,
Eric Dumazet <edumazet@google.com>,
Eric Van Hensbergen <ericvh@kernel.org>,
Heiko Carstens <hca@linux.ibm.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
Ingo Molnar <mingo@redhat.com>, Jaegeuk Kim <jaegeuk@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Jani Nikula <jani.nikula@linux.intel.com>,
Janosch Frank <frankja@linux.ibm.com>,
Jaroslav Kysela <perex@perex.cz>, Jens Axboe <axboe@kernel.dk>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Latchesar Ionkov <lucho@ionkov.net>,
Linus Walleij <linusw@kernel.org>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Mark Brown <broonie@kernel.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Miklos Szeredi <miklos@szeredi.hu>,
Namhyung Kim <namhyung@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paolo Abeni <pabeni@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Paul Walmsley <pjw@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Sean Christopherson <seanjc@google.com>,
Simona Vetter <simona@ffwll.ch>, Takashi Iwai <tiwai@suse.com>,
Thomas Gleixner <tglx@kernel.org>,
Trond Myklebust <trondmy@kernel.org>,
Tvrtko Ursulin <tursulin@ursulin.net>,
Vasily Gorbik <gor@linux.ibm.com>, Will Deacon <will@kernel.org>,
Yury Norov <yury.norov@gmail.com>, Zheng Gu <cengku@gmail.com>
Cc: Yury Norov <ynorov@nvidia.com>,
linux-kernel@vger.kernel.org, x86@kernel.org,
linux-arm-kernel@lists.infradead.org,
linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org,
kvm@vger.kernel.org, linux-s390@vger.kernel.org,
linux-block@vger.kernel.org, intel-gfx@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, dm-devel@lists.linux.dev,
netdev@vger.kernel.org, linux-spi@vger.kernel.org,
linux-ext4@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org,
linux-nfs@vger.kernel.org, linux-crypto@vger.kernel.org,
linux-mm@kvack.org, linux-perf-users@vger.kernel.org,
v9fs@lists.linux.dev, virtualization@lists.linux.dev,
linux-sound@vger.kernel.org
Subject: [PATCH 4/8] core: use rest_of_page() macro where appropriate
Date: Tue, 3 Mar 2026 20:27:12 -0500 [thread overview]
Message-ID: <20260304012717.201797-5-ynorov@nvidia.com> (raw)
In-Reply-To: <20260304012717.201797-1-ynorov@nvidia.com>
Switch core and library code to using the macro. No functional
changes intended.
Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
include/crypto/scatterwalk.h | 2 +-
include/linux/highmem.h | 24 ++++++++++--------------
include/linux/iomap.h | 2 +-
include/linux/iov_iter.h | 3 +--
kernel/events/ring_buffer.c | 2 +-
lib/bitmap-str.c | 2 +-
lib/iov_iter.c | 5 ++---
7 files changed, 17 insertions(+), 23 deletions(-)
diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h
index 624fab589c2c..c671d5383c12 100644
--- a/include/crypto/scatterwalk.h
+++ b/include/crypto/scatterwalk.h
@@ -73,7 +73,7 @@ static inline unsigned int scatterwalk_clamp(struct scatter_walk *walk,
* page due to the data not being aligned to the algorithm's alignmask.
*/
if (IS_ENABLED(CONFIG_HIGHMEM))
- limit = PAGE_SIZE - offset_in_page(walk->offset);
+ limit = rest_of_page(walk->offset);
else
limit = PAGE_SIZE;
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index af03db851a1d..05528ba886fb 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -507,12 +507,10 @@ static inline void memcpy_folio(struct folio *dst_folio, size_t dst_off,
const char *src = kmap_local_folio(src_folio, src_off);
size_t chunk = len;
- 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);
memcpy(dst, src, chunk);
kunmap_local(src);
kunmap_local(dst);
@@ -580,9 +578,8 @@ static inline void memcpy_from_folio(char *to, struct folio *folio,
const char *from = kmap_local_folio(folio, offset);
size_t chunk = len;
- if (folio_test_partial_kmap(folio) &&
- chunk > PAGE_SIZE - offset_in_page(offset))
- chunk = PAGE_SIZE - offset_in_page(offset);
+ if (folio_test_partial_kmap(folio) && chunk > rest_of_page(offset))
+ chunk = rest_of_page(offset);
memcpy(to, from, chunk);
kunmap_local(from);
@@ -608,9 +605,8 @@ static inline void memcpy_to_folio(struct folio *folio, size_t offset,
char *to = kmap_local_folio(folio, offset);
size_t chunk = len;
- if (folio_test_partial_kmap(folio) &&
- chunk > PAGE_SIZE - offset_in_page(offset))
- chunk = PAGE_SIZE - offset_in_page(offset);
+ if (folio_test_partial_kmap(folio) && chunk > rest_of_page(offset))
+ chunk = rest_of_page(offset);
memcpy(to, from, chunk);
kunmap_local(to);
@@ -642,7 +638,7 @@ static inline __must_check void *folio_zero_tail(struct folio *folio,
size_t len = folio_size(folio) - offset;
if (folio_test_partial_kmap(folio)) {
- size_t max = PAGE_SIZE - offset_in_page(offset);
+ size_t max = rest_of_page(offset);
while (len > max) {
memset(kaddr, 0, max);
@@ -680,7 +676,7 @@ static inline void folio_fill_tail(struct folio *folio, size_t offset,
VM_BUG_ON(offset + len > folio_size(folio));
if (folio_test_partial_kmap(folio)) {
- size_t max = PAGE_SIZE - offset_in_page(offset);
+ size_t max = rest_of_page(offset);
while (len > max) {
memcpy(to, from, max);
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index 99b7209dabd7..6ae549192adb 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -142,7 +142,7 @@ static inline void *iomap_inline_data(const struct iomap *iomap, loff_t pos)
*/
static inline bool iomap_inline_data_valid(const struct iomap *iomap)
{
- return iomap->length <= PAGE_SIZE - offset_in_page(iomap->inline_data);
+ return iomap->length <= rest_of_page(iomap->inline_data);
}
/*
diff --git a/include/linux/iov_iter.h b/include/linux/iov_iter.h
index f9a17fbbd398..13a9ee653ef8 100644
--- a/include/linux/iov_iter.h
+++ b/include/linux/iov_iter.h
@@ -227,8 +227,7 @@ size_t iterate_xarray(struct iov_iter *iter, size_t len, void *priv, void *priv2
while (flen) {
void *base = kmap_local_folio(folio, offset);
- part = min_t(size_t, flen,
- PAGE_SIZE - offset_in_page(offset));
+ part = min_t(size_t, flen, rest_of_page(offset));
remain = step(base, progress, part, priv, priv2);
kunmap_local(base);
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 3e7de2661417..1db2868b90c9 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -590,7 +590,7 @@ long perf_output_copy_aux(struct perf_output_handle *aux_handle,
to &= (rb->aux_nr_pages << PAGE_SHIFT) - 1;
do {
- tocopy = PAGE_SIZE - offset_in_page(from);
+ tocopy = rest_of_page(from);
if (to > from)
tocopy = min(tocopy, to - from);
if (!tocopy)
diff --git a/lib/bitmap-str.c b/lib/bitmap-str.c
index be745209507a..a357342d5d6c 100644
--- a/lib/bitmap-str.c
+++ b/lib/bitmap-str.c
@@ -58,7 +58,7 @@ EXPORT_SYMBOL(bitmap_parse_user);
int bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp,
int nmaskbits)
{
- ptrdiff_t len = PAGE_SIZE - offset_in_page(buf);
+ ptrdiff_t len = rest_of_page(buf);
return list ? scnprintf(buf, len, "%*pbl\n", nmaskbits, maskp) :
scnprintf(buf, len, "%*pb\n", nmaskbits, maskp);
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 0a63c7fba313..c7e812349ca2 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -483,9 +483,8 @@ size_t copy_folio_from_iter_atomic(struct folio *folio, size_t offset,
char *to = kmap_local_folio(folio, offset);
n = bytes - copied;
- if (folio_test_partial_kmap(folio) &&
- n > PAGE_SIZE - offset_in_page(offset))
- n = PAGE_SIZE - offset_in_page(offset);
+ if (folio_test_partial_kmap(folio) && n > rest_of_page(offset))
+ n = rest_of_page(offset);
pagefault_disable();
n = __copy_from_iter(to, n, i);
--
2.43.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-03-04 1:27 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-04 1:27 [PATCH 0/8] mm: globalize rest_of_page() macro Yury Norov
2026-03-04 1:27 ` Yury Norov
2026-03-04 1:27 ` [f2fs-dev] " Yury Norov via Linux-f2fs-devel
2026-03-04 1:27 ` [PATCH 1/8] mm: add " Yury Norov
2026-03-04 1:27 ` Yury Norov
2026-03-04 1:27 ` [f2fs-dev] " Yury Norov via Linux-f2fs-devel
2026-03-04 1:27 ` [PATCH 2/8] fs: use rest_of_page() macro where appropriate Yury Norov
2026-03-04 1:27 ` Yury Norov
2026-03-04 1:27 ` [f2fs-dev] " Yury Norov via Linux-f2fs-devel
2026-03-04 1:27 ` [PATCH 3/8] net: " Yury Norov
2026-03-04 1:27 ` Yury Norov
2026-03-04 1:27 ` [f2fs-dev] " Yury Norov via Linux-f2fs-devel
2026-03-04 1:27 ` Yury Norov [this message]
2026-03-04 1:27 ` [PATCH 4/8] core: " Yury Norov
2026-03-04 1:27 ` [f2fs-dev] " Yury Norov via Linux-f2fs-devel
2026-03-04 1:27 ` [PATCH 5/8] spi: " Yury Norov
2026-03-04 1:27 ` Yury Norov
2026-03-04 1:27 ` [f2fs-dev] " Yury Norov via Linux-f2fs-devel
2026-03-04 11:10 ` Mark Brown
2026-03-04 11:10 ` Mark Brown
2026-03-04 1:27 ` [PATCH 6/8] KVM: " Yury Norov
2026-03-04 1:27 ` Yury Norov
2026-03-04 1:27 ` [f2fs-dev] " Yury Norov via Linux-f2fs-devel
2026-03-04 1:27 ` [PATCH 7/8] drivers: ALSA: " Yury Norov
2026-03-04 1:27 ` Yury Norov
2026-03-04 1:27 ` [f2fs-dev] " Yury Norov via Linux-f2fs-devel
2026-03-04 1:27 ` [PATCH 8/8] arch: " Yury Norov
2026-03-04 1:27 ` Yury Norov
2026-03-04 1:27 ` [f2fs-dev] " Yury Norov via Linux-f2fs-devel
2026-04-02 21:58 ` Paul Walmsley
2026-04-02 21:58 ` Paul Walmsley
2026-04-02 21:58 ` [f2fs-dev] " Paul Walmsley via Linux-f2fs-devel
2026-03-04 2:21 ` ✓ i915.CI.BAT: success for mm: globalize rest_of_page() macro Patchwork
2026-03-04 2:28 ` [PATCH 0/8] " Jakub Kicinski
2026-03-04 2:28 ` Jakub Kicinski
2026-03-04 2:28 ` [f2fs-dev] " Jakub Kicinski via Linux-f2fs-devel
2026-03-04 2:42 ` Jens Axboe
2026-03-04 2:42 ` Jens Axboe
2026-03-04 2:42 ` [f2fs-dev] " Jens Axboe
2026-03-04 2:49 ` Sean Christopherson
2026-03-04 2:49 ` Sean Christopherson
2026-03-04 2:49 ` [f2fs-dev] " Sean Christopherson via Linux-f2fs-devel
2026-03-04 3:32 ` Yury Norov
2026-03-04 3:32 ` Yury Norov
2026-03-04 3:32 ` [f2fs-dev] " Yury Norov via Linux-f2fs-devel
2026-03-04 3:35 ` Jens Axboe
2026-03-04 3:35 ` Jens Axboe
2026-03-04 3:35 ` [f2fs-dev] " Jens Axboe
2026-03-04 12:48 ` Peter Zijlstra
2026-03-04 12:48 ` Peter Zijlstra
2026-03-04 12:48 ` [f2fs-dev] " Peter Zijlstra
2026-03-05 4:19 ` ✓ i915.CI.Full: success for " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260304012717.201797-5-ynorov@nvidia.com \
--to=ynorov@nvidia.com \
--cc=acme@kernel.org \
--cc=adilger.kernel@dilger.ca \
--cc=agordeev@linux.ibm.com \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alexanderduyck@fb.com \
--cc=andrew+netdev@lunn.ch \
--cc=anna@kernel.org \
--cc=anton.yakovlev@opensynergy.com \
--cc=aou@eecs.berkeley.edu \
--cc=asmadeus@codewreck.org \
--cc=aswin@linux.ibm.com \
--cc=axboe@kernel.dk \
--cc=borntraeger@linux.ibm.com \
--cc=bp@alien8.de \
--cc=brauner@kernel.org \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=cem@kernel.org \
--cc=cengku@gmail.com \
--cc=chao@kernel.org \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=dm-devel@lists.linux.dev \
--cc=dongsheng.yang@linux.dev \
--cc=dri-devel@lists.freedesktop.org \
--cc=edumazet@google.com \
--cc=ericvh@kernel.org \
--cc=frankja@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=herbert@gondor.apana.org.au \
--cc=imbrenda@linux.ibm.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jaegeuk@kernel.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=kuba@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lucho@ionkov.net \
--cc=maddy@linux.ibm.com \
--cc=miklos@szeredi.hu \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=mst@redhat.com \
--cc=namhyung@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=palmer@dabbelt.com \
--cc=pbonzini@redhat.com \
--cc=perex@perex.cz \
--cc=peterz@infradead.org \
--cc=pjw@kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=seanjc@google.com \
--cc=simona@ffwll.ch \
--cc=tglx@kernel.org \
--cc=tiwai@suse.com \
--cc=trondmy@kernel.org \
--cc=tursulin@ursulin.net \
--cc=tytso@mit.edu \
--cc=v9fs@lists.linux.dev \
--cc=viro@zeniv.linux.org.uk \
--cc=virtualization@lists.linux.dev \
--cc=will@kernel.org \
--cc=wintera@linux.ibm.com \
--cc=x86@kernel.org \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.