[PATCH v2] pagevec.h: add `const` to pointer parameters of getter functions

Max Kellermann posted 1 patch 1 month ago
include/linux/pagevec.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH v2] pagevec.h: add `const` to pointer parameters of getter functions
Posted by Max Kellermann 1 month ago
For improved const-correctness.

Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
v1->v2: reduced patch to just pagevec.h upon David Hildenbrand's suggestion
---
 include/linux/pagevec.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h
index 5d3a0cccc6bf..63be5a451627 100644
--- a/include/linux/pagevec.h
+++ b/include/linux/pagevec.h
@@ -51,12 +51,12 @@ static inline void folio_batch_reinit(struct folio_batch *fbatch)
 	fbatch->i = 0;
 }
 
-static inline unsigned int folio_batch_count(struct folio_batch *fbatch)
+static inline unsigned int folio_batch_count(const struct folio_batch *fbatch)
 {
 	return fbatch->nr;
 }
 
-static inline unsigned int folio_batch_space(struct folio_batch *fbatch)
+static inline unsigned int folio_batch_space(const struct folio_batch *fbatch)
 {
 	return PAGEVEC_SIZE - fbatch->nr;
 }
-- 
2.47.2
Re: [PATCH v2] pagevec.h: add `const` to pointer parameters of getter functions
Posted by SeongJae Park 1 month ago
On Thu, 28 Aug 2025 15:03:11 +0200 Max Kellermann <max.kellermann@ionos.com> wrote:

> For improved const-correctness.
> 
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>

Acked-by: SeongJae Park <sj@kernel.org>


Thanks,
SJ

[...]
Re: [PATCH v2] pagevec.h: add `const` to pointer parameters of getter functions
Posted by Vishal Moola (Oracle) 1 month ago
On Thu, Aug 28, 2025 at 03:03:11PM +0200, Max Kellermann wrote:
> For improved const-correctness.
> 
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>

Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Re: [PATCH v2] pagevec.h: add `const` to pointer parameters of getter functions
Posted by Lorenzo Stoakes 1 month ago
+cc missing people.

Again, please run scripts/get_maintainers.pl and cc the right people, thanks.

On Thu, Aug 28, 2025 at 03:03:11PM +0200, Max Kellermann wrote:
> For improved const-correctness.
>
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>

This is fine, so:

Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

> ---
> v1->v2: reduced patch to just pagevec.h upon David Hildenbrand's suggestion
> ---
>  include/linux/pagevec.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h
> index 5d3a0cccc6bf..63be5a451627 100644
> --- a/include/linux/pagevec.h
> +++ b/include/linux/pagevec.h
> @@ -51,12 +51,12 @@ static inline void folio_batch_reinit(struct folio_batch *fbatch)
>  	fbatch->i = 0;
>  }
>
> -static inline unsigned int folio_batch_count(struct folio_batch *fbatch)
> +static inline unsigned int folio_batch_count(const struct folio_batch *fbatch)
>  {
>  	return fbatch->nr;
>  }
>
> -static inline unsigned int folio_batch_space(struct folio_batch *fbatch)
> +static inline unsigned int folio_batch_space(const struct folio_batch *fbatch)
>  {
>  	return PAGEVEC_SIZE - fbatch->nr;
>  }
> --
> 2.47.2
>
Re: [PATCH v2] pagevec.h: add `const` to pointer parameters of getter functions
Posted by Vlastimil Babka 1 month ago
On 8/28/25 15:03, Max Kellermann wrote:
> For improved const-correctness.
> 
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>

Note that your Cc list is still not according to MAINTAINERS:

./scripts/get_maintainer.pl -f include/linux/pagevec.h 
Andrew Morton <akpm@linux-foundation.org> (maintainer:MEMORY MANAGEMENT - CORE)
David Hildenbrand <david@redhat.com> (maintainer:MEMORY MANAGEMENT - CORE)
Lorenzo Stoakes <lorenzo.stoakes@oracle.com> (reviewer:MEMORY MANAGEMENT - CORE)
"Liam R. Howlett" <Liam.Howlett@oracle.com> (reviewer:MEMORY MANAGEMENT - CORE)
Vlastimil Babka <vbabka@suse.cz> (reviewer:MEMORY MANAGEMENT - CORE)
Mike Rapoport <rppt@kernel.org> (reviewer:MEMORY MANAGEMENT - CORE)
Suren Baghdasaryan <surenb@google.com> (reviewer:MEMORY MANAGEMENT - CORE)
Michal Hocko <mhocko@suse.com> (reviewer:MEMORY MANAGEMENT - CORE)
linux-mm@kvack.org (open list:MEMORY MANAGEMENT - CORE)
linux-kernel@vger.kernel.org (open list)

> ---
> v1->v2: reduced patch to just pagevec.h upon David Hildenbrand's suggestion

Assuming you don't intend to stop here, a series with multiple patches logically
gradually expanding the const scope would be better than sending a single patch?

Thanks,
Vlastimil

> ---
>  include/linux/pagevec.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h
> index 5d3a0cccc6bf..63be5a451627 100644
> --- a/include/linux/pagevec.h
> +++ b/include/linux/pagevec.h
> @@ -51,12 +51,12 @@ static inline void folio_batch_reinit(struct folio_batch *fbatch)
>  	fbatch->i = 0;
>  }
>  
> -static inline unsigned int folio_batch_count(struct folio_batch *fbatch)
> +static inline unsigned int folio_batch_count(const struct folio_batch *fbatch)
>  {
>  	return fbatch->nr;
>  }
>  
> -static inline unsigned int folio_batch_space(struct folio_batch *fbatch)
> +static inline unsigned int folio_batch_space(const struct folio_batch *fbatch)
>  {
>  	return PAGEVEC_SIZE - fbatch->nr;
>  }
Re: [PATCH v2] pagevec.h: add `const` to pointer parameters of getter functions
Posted by Max Kellermann 1 month ago
On Thu, Aug 28, 2025 at 3:23 PM Vlastimil Babka <vbabka@suse.cz> wrote:
> Note that your Cc list is still not according to MAINTAINERS:

I did, but I did this on 6.15... but master has significant additions
to the MAINTAINERS file.

> Assuming you don't intend to stop here, a series with multiple patches logically
> gradually expanding the const scope would be better than sending a single patch?

Yes, but that would mean more work, which I'm certainly willing to do,
but only if I'm confident the patches are going to be accepted. So
this tiny patch is a trial.
In v1, Lorenzo had expressed general objections to merging
const-correctness patches.
I don't want to waste time with something that's going to be rejected
anyway. I've been there so often, so often has there been one guy who
just rejects my work, after similar patches (by others) had been
merged.
Re: [PATCH v2] pagevec.h: add `const` to pointer parameters of getter functions
Posted by Matthew Wilcox 1 month ago
On Thu, Aug 28, 2025 at 03:03:11PM +0200, Max Kellermann wrote:
> For improved const-correctness.
> 
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>

Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>

I have a pending patch which constifies compound_order() and page_size()
so you needn't bother with those.