Re: [PATCH 3/3] lib/bitmap: use bytes_to_page_end() helper
From: Yury Norov
Date: Mon May 18 2026 - 11:34:21 EST
On Sun, May 17, 2026 at 02:34:31PM +0200, Thorsten Blum wrote:
> bitmap-str.c includes linux/mm.h for offset_in_page() and kfree().
And there's nothing wrong with that because it's a .c file, right?
> Instead, include linux/page_helpers.h and linux/slab.h directly, and
> use bytes_to_page_end() to simplify the code.
I'm OK about narrowing down inclusions in broadly-used headers. But
here in a regular .c file it doesn't look like it fixes anything.
Maybe some circular dependency you've not mentioned?
> Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
> ---
> lib/bitmap-str.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/lib/bitmap-str.c b/lib/bitmap-str.c
> index be745209507a..bf245a3eae4a 100644
> --- a/lib/bitmap-str.c
> +++ b/lib/bitmap-str.c
> @@ -7,7 +7,8 @@
> #include <linux/export.h>
> #include <linux/hex.h>
> #include <linux/kernel.h>
> -#include <linux/mm.h>
> +#include <linux/page_helpers.h>
> +#include <linux/slab.h>
> #include <linux/string.h>
>
> #include "kstrtox.h"
> @@ -58,7 +59,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 = bytes_to_page_end(buf);
Don't worry about this function - it's on a schedule for deletion in
this cycle. Now that you're fixing the only user that is going to
disappear anyways, this new macro is going to become a dead code.
Can you please check the other ~90 users over the kernel. I already
mentioned the series taking care of them.
https://lore.kernel.org/all/20260304012717.201797-1-ynorov@xxxxxxxxxx/
Maybe just start from there?
Thanks,
Yury
> return list ? scnprintf(buf, len, "%*pbl\n", nmaskbits, maskp) :
> scnprintf(buf, len, "%*pb\n", nmaskbits, maskp);