From: Ran Xiaokai <ran.xiaokai@zte.com.cn>
Constify folio_order()/folio_test_pmd_mappable().
No functional changes, just a preparation for the next patch.
Signed-off-by: Ran Xiaokai <ran.xiaokai@zte.com.cn>
---
include/linux/huge_mm.h | 2 +-
include/linux/mm.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index 2aa986a5cd1b..8d66e4eaa1bc 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -377,7 +377,7 @@ static inline spinlock_t *pud_trans_huge_lock(pud_t *pud,
* folio_test_pmd_mappable - Can we map this folio with a PMD?
* @folio: The folio to test
*/
-static inline bool folio_test_pmd_mappable(struct folio *folio)
+static inline bool folio_test_pmd_mappable(const struct folio *folio)
{
return folio_order(folio) >= HPAGE_PMD_ORDER;
}
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 9a5652c5fadd..b1c11371a2a3 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1105,7 +1105,7 @@ static inline unsigned int compound_order(struct page *page)
*
* Return: The order of the folio.
*/
-static inline unsigned int folio_order(struct folio *folio)
+static inline unsigned int folio_order(const struct folio *folio)
{
if (!folio_test_large(folio))
return 0;
--
2.15.2
On Tue Jun 25, 2024 at 10:49 PM EDT, ran xiaokai wrote:
> From: Ran Xiaokai <ran.xiaokai@zte.com.cn>
>
> Constify folio_order()/folio_test_pmd_mappable().
> No functional changes, just a preparation for the next patch.
What warning/error are you seeing when you just apply patch 2? I wonder why it
did not show up in other places. Thanks.
>
> Signed-off-by: Ran Xiaokai <ran.xiaokai@zte.com.cn>
> ---
> include/linux/huge_mm.h | 2 +-
> include/linux/mm.h | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
> index 2aa986a5cd1b..8d66e4eaa1bc 100644
> --- a/include/linux/huge_mm.h
> +++ b/include/linux/huge_mm.h
> @@ -377,7 +377,7 @@ static inline spinlock_t *pud_trans_huge_lock(pud_t *pud,
> * folio_test_pmd_mappable - Can we map this folio with a PMD?
> * @folio: The folio to test
> */
> -static inline bool folio_test_pmd_mappable(struct folio *folio)
> +static inline bool folio_test_pmd_mappable(const struct folio *folio)
> {
> return folio_order(folio) >= HPAGE_PMD_ORDER;
> }
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 9a5652c5fadd..b1c11371a2a3 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -1105,7 +1105,7 @@ static inline unsigned int compound_order(struct page *page)
> *
> * Return: The order of the folio.
> */
> -static inline unsigned int folio_order(struct folio *folio)
> +static inline unsigned int folio_order(const struct folio *folio)
> {
> if (!folio_test_large(folio))
> return 0;
--
Best Regards,
Yan, Zi
> On Tue Jun 25, 2024 at 10:49 PM EDT, ran xiaokai wrote:
> > From: Ran Xiaokai <ran.xiaokai@zte.com.cn>
> >
> > Constify folio_order()/folio_test_pmd_mappable().
> > No functional changes, just a preparation for the next patch.
>
> What warning/error are you seeing when you just apply patch 2? I wonder why it
> did not show up in other places. Thanks.
fs/proc/page.c: In function 'stable_page_flags':
fs/proc/page.c:152:35: warning: passing argument 1 of 'folio_test_pmd_mappable' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
152 | else if (folio_test_pmd_mappable(folio)) {
| ^~~~~
In file included from include/linux/mm.h:1115,
from include/linux/memblock.h:12,
from fs/proc/page.c:2:
include/linux/huge_mm.h:380:58: note: expected 'struct folio *' but argument is of type 'const struct folio *'
380 | static inline bool folio_test_pmd_mappable(struct folio *folio)
u64 stable_page_flags(const struct page *page)
{
const struct folio *folio; // the const definition causes the warning
...
}
As almost all the folio_test_XXX(flags) have converted to received
a const parameter, it is Ok to also do this for folio_order()?
> >
> > Signed-off-by: Ran Xiaokai <ran.xiaokai@zte.com.cn>
> > ---
> > include/linux/huge_mm.h | 2 +-
> > include/linux/mm.h | 2 +-
> > 2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
> > index 2aa986a5cd1b..8d66e4eaa1bc 100644
> > --- a/include/linux/huge_mm.h
> > +++ b/include/linux/huge_mm.h
> > @@ -377,7 +377,7 @@ static inline spinlock_t *pud_trans_huge_lock(pud_t *pud,
> > * folio_test_pmd_mappable - Can we map this folio with a PMD?
> > * @folio: The folio to test
> > */
> > -static inline bool folio_test_pmd_mappable(struct folio *folio)
> > +static inline bool folio_test_pmd_mappable(const struct folio *folio)
> > {
> > return folio_order(folio) >= HPAGE_PMD_ORDER;
> > }
> > diff --git a/include/linux/mm.h b/include/linux/mm.h
> > index 9a5652c5fadd..b1c11371a2a3 100644
> > --- a/include/linux/mm.h
> > +++ b/include/linux/mm.h
> > @@ -1105,7 +1105,7 @@ static inline unsigned int compound_order(struct page *page)
> > *
> > * Return: The order of the folio.
> > */
> > -static inline unsigned int folio_order(struct folio *folio)
> > +static inline unsigned int folio_order(const struct folio *folio)
> > {
> > if (!folio_test_large(folio))
> > return 0;
On Wed Jun 26, 2024 at 12:30 AM EDT, ran xiaokai wrote:
> > On Tue Jun 25, 2024 at 10:49 PM EDT, ran xiaokai wrote:
> > > From: Ran Xiaokai <ran.xiaokai@zte.com.cn>
> > >
> > > Constify folio_order()/folio_test_pmd_mappable().
> > > No functional changes, just a preparation for the next patch.
> >
> > What warning/error are you seeing when you just apply patch 2? I wonder why it
> > did not show up in other places. Thanks.
>
> fs/proc/page.c: In function 'stable_page_flags':
> fs/proc/page.c:152:35: warning: passing argument 1 of 'folio_test_pmd_mappable' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
> 152 | else if (folio_test_pmd_mappable(folio)) {
> | ^~~~~
> In file included from include/linux/mm.h:1115,
> from include/linux/memblock.h:12,
> from fs/proc/page.c:2:
> include/linux/huge_mm.h:380:58: note: expected 'struct folio *' but argument is of type 'const struct folio *'
> 380 | static inline bool folio_test_pmd_mappable(struct folio *folio)
>
> u64 stable_page_flags(const struct page *page)
> {
> const struct folio *folio; // the const definition causes the warning
> ...
Please include the warning in the commit log to explain the change.
> }
>
> As almost all the folio_test_XXX(flags) have converted to received
> a const parameter, it is Ok to also do this for folio_order()?
Yes.
© 2016 - 2025 Red Hat, Inc.