Skip to contentSkip to conversation

pagevec.h: add `const` to pointer parameters of getter functions

PATCH In review Max Kellermann 6 participants 7 messages Aug 28, 2025 Memory management

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 pagevec.h: add `const` to pointer parameters of getter functions

For improved const-correctness.

---
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(-)
include/linux/pagevec.h +2 -2
index 5d3a0cccc6bf..63be5a451627 100644
@@ -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;
 }
Signature · 1 line
2.47.2
#2 lore raw
In reply to Max Kellermann
Quoted 3 lines · Max Kellermann

For improved const-correctness.

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

./scripts/get_maintainer.pl -f include/linux/pagevec.h
Andrew Morton <[email protected]> (maintainer:MEMORY MANAGEMENT - CORE) David Hildenbrand <[email protected]> (maintainer:MEMORY MANAGEMENT - CORE) Lorenzo Stoakes <[email protected]> (reviewer:MEMORY MANAGEMENT - CORE) "Liam R. Howlett" <[email protected]> (reviewer:MEMORY MANAGEMENT - CORE) Vlastimil Babka <[email protected]> (reviewer:MEMORY MANAGEMENT - CORE) Mike Rapoport <[email protected]> (reviewer:MEMORY MANAGEMENT - CORE) Suren Baghdasaryan <[email protected]> (reviewer:MEMORY MANAGEMENT - CORE) Michal Hocko <[email protected]> (reviewer:MEMORY MANAGEMENT - CORE) [email protected] (open list:MEMORY MANAGEMENT - CORE) [email protected] (open list)

Quoted 2 lines

---
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

Quoted 23 lines
---
 include/linux/pagevec.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/pagevec.h +2 -2
index 5d3a0cccc6bf..63be5a451627 100644
@@ -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;
 }
#3 lore raw
Quoted 1 line · Vlastimil Babka

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.

Quoted 2 lines

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.

Reviewed-by on v2 1/1
#4 lore raw
In reply to Max Kellermann

+cc missing people.

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

Quoted 3 lines · Max Kellermann

For improved const-correctness.

This is fine, so:

Quoted 28 lines

---
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(-)
include/linux/pagevec.h +2 -3
index 5d3a0cccc6bf..63be5a451627 100644
@@ -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