powerpc: Use printk instead of WARN in change_memory_attr
Ritesh Harjani (IBM)
reviewerPATCH 1/1 powerpc: Use printk instead of WARN in change_memory_attr
Use pr_warn_once instead of WARN_ON_ONCE as discussed here [1] for printing possible use of set_memory_* on linear map on Hash.
[1]: https://lore.kernel.org/all/[email protected]/#t
--- arch/powerpc/mm/pageattr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/powerpc/mm/pageattr.c +4 -1
@@ -94,8 +94,11 @@ int change_memory_attr(unsigned long addr, int numpages, long action)if (!radix_enabled ()) {int region =get_region_id (addr); -if (WARN_ON_ONCE (region !=VMALLOC_REGION_ID && region !=IO_REGION_ID )) +if (region !=VMALLOC_REGION_ID && region !=IO_REGION_ID ) { +pr_warn_once ("%s: possible use of set_memory_* on linear map on Hash from (%ps)\n" , + __func__,__builtin_return_address (0 ));return -EINVAL ; + } }#endif
--
2.39.2
Le 27/08/2024 à 11:12, Ritesh Harjani (IBM) a écrit :
Quoted 17 lines
[Vous ne recevez pas souvent de courriers de [email protected]. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
Use
pr_warn_onceinstead ofWARN_ON_ONCEas discussed here [1] for printing possible use of set_memory_* on linear map on Hash.[1]: https://lore.kernel.org/all/[email protected]/#t
Signed-off-by Ritesh Harjani (IBM) <[email protected]>--- arch/powerpc/mm/pageattr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)arch/powerpc/mm/pageattr.c +0
-0
arch/powerpc/mm/pageattr.c int change_memory_attr(unsigned long addr, int numpages, long action) · line 99
Quoted 7 lines
arch/powerpc/mm/pageattr.c +3
-1@@ -94,8 +94,11 @@ int change_memory_attr(unsigned long addr, int numpages, long action)if (!radix_enabled ()) {int region =get_region_id (addr); -if (WARN_ON_ONCE (region !=VMALLOC_REGION_ID && region !=IO_REGION_ID )) +if (region !=VMALLOC_REGION_ID && region !=IO_REGION_ID ) { +pr_warn_once ("%s: possible use of set_memory_* on linear map on Hash from (%ps)\n" , + __func__,__builtin_return_address (0 ));
Is it really only linear map ?
What about "possible user of set_memory_* outside of vmalloc or io region.
Maybe a show_stack() would also be worth it ?
But in principle I think it would be better to keep the WARN_ONCE until we can add __must_check to set_memory_xxx() functions to be sure all callers check the result, as mandated by https://github.com/KSPP/linux/issues/7
Christophe
Ritesh Harjani (IBM)
reviewerQuoted 21 lines · Christophe Leroy
Le 27/08/2024 à 11:12, Ritesh Harjani (IBM) a écrit :
Quoted 20 lines
[Vous ne recevez pas souvent de courriers de [email protected]. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
Use
pr_warn_onceinstead ofWARN_ON_ONCEas discussed here [1] for printing possible use of set_memory_* on linear map on Hash.[1]: https://lore.kernel.org/all/[email protected]/#t
Signed-off-by Ritesh Harjani (IBM) <[email protected]>--- arch/powerpc/mm/pageattr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)arch/powerpc/mm/pageattr.c +0
-0@@ -94,8 +94,11 @@ int change_memory_attr(unsigned long addr, int numpages, long action)if (!radix_enabled ()) {int region =get_region_id (addr);
Quoted 8 lines
arch/powerpc/mm/pageattr.c int change_memory_attr(unsigned long addr, int numpages, long action) · line 99
Quoted 4 lines
arch/powerpc/mm/pageattr.c +3
-1-if (WARN_ON_ONCE (region !=VMALLOC_REGION_ID && region !=IO_REGION_ID )) +if (region !=VMALLOC_REGION_ID && region !=IO_REGION_ID ) { +pr_warn_once ("%s: possible use of set_memory_* on linear map on Hash from (%ps)\n" , + __func__,__builtin_return_address (0 ));Is it really only linear map ?
What about "possible user of set_memory_* outside of vmalloc or io region.
"warning: possible user of set_memory_* outside of vmalloc and io region."
I am thinking of adding a word "warning" too. I can make above change and send v2.
Quoted 2 lines
Maybe a
show_stack()would also be worth it ?
IMO, since we have the caller, we need not pollute the dmesg with the entire call stack. Besides I am not aware of dump_stack_once() style prints.
Quoted 6 lines
But in principle I think it would be better to keep the
WARN_ONCEuntil we can add__must_checktoset_memory_xxx()functions to be sure all callers check the result, as mandated by
https://github.com/KSPP/linux/issues/7
Fixing the callers to check the return value is something that need not depend on this change no?
The intention of this change is to mainly remove the heavy WARN_ON_ONCE from powerpc specific change_memory_attr() and convert to printk warn.
-ritesh
Michael Ellerman
reviewerQuoted 21 lines · Christophe Leroy
Le 27/08/2024 à 11:12, Ritesh Harjani (IBM) a écrit :
Quoted 20 lines
[Vous ne recevez pas souvent de courriers de [email protected]. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
Use
pr_warn_onceinstead ofWARN_ON_ONCEas discussed here [1] for printing possible use of set_memory_* on linear map on Hash.[1]: https://lore.kernel.org/all/[email protected]/#t
Signed-off-by Ritesh Harjani (IBM) <[email protected]>--- arch/powerpc/mm/pageattr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)arch/powerpc/mm/pageattr.c +0
-0@@ -94,8 +94,11 @@ int change_memory_attr(unsigned long addr, int numpages, long action)if (!radix_enabled ()) {int region =get_region_id (addr);
Quoted 8 lines
arch/powerpc/mm/pageattr.c int change_memory_attr(unsigned long addr, int numpages, long action) · line 99
Quoted 4 lines
arch/powerpc/mm/pageattr.c +3
-1-if (WARN_ON_ONCE (region !=VMALLOC_REGION_ID && region !=IO_REGION_ID )) +if (region !=VMALLOC_REGION_ID && region !=IO_REGION_ID ) { +pr_warn_once ("%s: possible use of set_memory_* on linear map on Hash from (%ps)\n" , + __func__,__builtin_return_address (0 ));Is it really only linear map ?
What about "possible user of set_memory_* outside of vmalloc or io region.
Yeah that's more accurate. Can drop "possible" too I think? We're pretty sure that's what happened.
Quoted 7 lines
Maybe a
show_stack()would also be worth it ?But in principle I think it would be better to keep the
WARN_ONCEuntil we can add__must_checktoset_memory_xxx()functions to be sure all callers check the result, as mandated by
https://github.com/KSPP/linux/issues/7
Will that help in this case though?
If the caller checks the return value they'll see that the call failed, and presumably error out, possibly breaking boot or something else crucial.
Unless we change change_memory_attr() to return EOPNOTSUPP or something in this case, and expect callers to handle that.
cheers