mm/ioremap: Use WARN_ONCE instead of printk() + WARN_ON_ONCE()
PATCH 1/1 mm/ioremap: Use WARN_ONCE instead of printk() + WARN_ON_ONCE()
WARN_ONCE is more clear and simpler. Just replace it.
--- arch/x86/mm/ioremap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/mm/ioremap.c +2 -3
@@ -172,9 +172,8 @@ static void __ioremap_check_mem(resource_size_t addr, unsigned long size,return NULL ;if (!phys_addr_valid (phys_addr)) { -printk (KERN_WARNING "ioremap: invalid physical address %llx\n" , - (unsigned long long )phys_addr); -WARN_ON_ONCE (1 ); +WARN_ONCE (1 ,"ioremap: invalid physical address %llx\n" , + (unsigned long long )phys_addr);return NULL ; }
Signature · 1 line
1.7.12.4
Borislav Petkov
maintainerQuoted 12 lines · zhong jiang
WARN_ONCEis more clear and simpler. Just replace it.Signed-off-by zhong jiang <[email protected]>--- arch/x86/mm/ioremap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)arch/x86/mm/ioremap.c +0
-0
arch/x86/mm/ioremap.c static void __ioremap_check_mem(resource_size_t addr, unsigned long size, · line 176
Quoted 8 lines
arch/x86/mm/ioremap.c +2
-3@@ -172,9 +172,8 @@ static void __ioremap_check_mem(resource_size_t addr, unsigned long size,return NULL ;if (!phys_addr_valid (phys_addr)) { -printk (KERN_WARNING "ioremap: invalid physical address %llx\n" , - (unsigned long long )phys_addr); -WARN_ON_ONCE (1 ); +WARN_ONCE (1 ,"ioremap: invalid physical address %llx\n" , + (unsigned long long )phys_addr);
Does
WARN_ONCE(!phys_addr_valid(phys_addr), "ioremap: invalid physical address %llx\n", (unsigned long long)phys_addr);
work too?
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--Quoted 22 lines · Borislav Petkov
Quoted 12 lines · zhong jiang
WARN_ONCEis more clear and simpler. Just replace it.Signed-off-by zhong jiang <[email protected]>--- arch/x86/mm/ioremap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)arch/x86/mm/ioremap.c +0
-0arch/x86/mm/ioremap.c static void __ioremap_check_mem(resource_size_t addr, unsigned long size, · line 176
Quoted 8 lines
arch/x86/mm/ioremap.c +2
-3@@ -172,9 +172,8 @@ static void __ioremap_check_mem(resource_size_t addr, unsigned long size,return NULL ;if (!phys_addr_valid (phys_addr)) { -printk (KERN_WARNING "ioremap: invalid physical address %llx\n" , - (unsigned long long )phys_addr); -WARN_ON_ONCE (1 ); +WARN_ONCE (1 ,"ioremap: invalid physical address %llx\n" , + (unsigned long long )phys_addr);Does
Quoted 6 lines
WARN_ONCE(!phys_addr_valid(phys_addr), "ioremap: invalid physical address %llx\n", (unsigned long long)phys_addr);work too?
Thanks, That is better. Will repost.
Quoted 3 lines · zhong jiang
Quoted 2 lines · Borislav Petkov
Quoted 1 line · zhong jiang
WARN_ONCEis more clear and simpler. Just replace it.
[]
Quoted 1 line
Quoted 1 line
arch/x86/mm/ioremap.c
Quoted 1 line
arch/x86/mm/ioremap.c +0
-0
[]
Quoted 14 lines
Quoted 14 lines
arch/x86/mm/ioremap.c static void __ioremap_check_mem(resource_size_t addr, unsigned long size, · line 176
Quoted 9 lines
arch/x86/mm/ioremap.c +2
-3@@ -172,9 +172,8 @@ static void __ioremap_check_mem(resource_size_t addr, unsigned long size,return NULL ;if (!phys_addr_valid (phys_addr)) { -printk (KERN_WARNING "ioremap: invalid physical address %llx\n" , - (unsigned long long )phys_addr); -WARN_ON_ONCE (1 ); +WARN_ONCE (1 ,"ioremap: invalid physical address %llx\n" , + (unsigned long long )phys_addr);Does
WARN_ONCE(!phys_addr_valid(phys_addr), "ioremap: invalid physical address %llx\n", (unsigned long long)phys_addr);
Quoted 3 lines
Quoted 2 lines
work too?
Thanks, That is better. Will repost.
Perhaps this is not good patch concept as now each invalid physical address will not be emitted.
Before:
each invalid physical address printed
one stack dump
After:
one stck dump with first invalid physical address.
Quoted 27 lines · Joe Perches
Quoted 3 lines · zhong jiang
Quoted 2 lines · Borislav Petkov
Quoted 1 line · zhong jiang
WARN_ONCEis more clear and simpler. Just replace it.[]
Quoted 1 line
Quoted 1 line
arch/x86/mm/ioremap.c
Quoted 1 line
arch/x86/mm/ioremap.c +0
-0[]
Quoted 14 lines
Quoted 14 lines
arch/x86/mm/ioremap.c static void __ioremap_check_mem(resource_size_t addr, unsigned long size, · line 176
Quoted 9 lines
arch/x86/mm/ioremap.c +2
-3@@ -172,9 +172,8 @@ static void __ioremap_check_mem(resource_size_t addr, unsigned long size,return NULL ;if (!phys_addr_valid (phys_addr)) { -printk (KERN_WARNING "ioremap: invalid physical address %llx\n" , - (unsigned long long )phys_addr); -WARN_ON_ONCE (1 ); +WARN_ONCE (1 ,"ioremap: invalid physical address %llx\n" , + (unsigned long long )phys_addr);Does
WARN_ONCE(!phys_addr_valid(phys_addr), "ioremap: invalid physical address %llx\n", (unsigned long long)phys_addr);Quoted 3 lines
Quoted 2 lines
work too?
Thanks, That is better. Will repost.
Perhaps this is not good patch concept as now each invalid physical address will not be emitted.
Quoted 7 lines
Before:
each invalid physical address printed
one stack dumpAfter:
one stck dump with first invalid physical address.
Yes, I has told that.
How you think my above patch in the mail. Thanks
Quoted 3 lines
.
Quoted 27 lines · Joe Perches
Quoted 3 lines · zhong jiang
Quoted 2 lines · Borislav Petkov
Quoted 1 line · zhong jiang
WARN_ONCEis more clear and simpler. Just replace it.[]
Quoted 1 line
Quoted 1 line
arch/x86/mm/ioremap.c
Quoted 1 line
arch/x86/mm/ioremap.c +0
-0[]
Quoted 14 lines
Quoted 14 lines
arch/x86/mm/ioremap.c static void __ioremap_check_mem(resource_size_t addr, unsigned long size, · line 176
Quoted 9 lines
arch/x86/mm/ioremap.c +2
-3@@ -172,9 +172,8 @@ static void __ioremap_check_mem(resource_size_t addr, unsigned long size,return NULL ;if (!phys_addr_valid (phys_addr)) { -printk (KERN_WARNING "ioremap: invalid physical address %llx\n" , - (unsigned long long )phys_addr); -WARN_ON_ONCE (1 ); +WARN_ONCE (1 ,"ioremap: invalid physical address %llx\n" , + (unsigned long long )phys_addr);Does
WARN_ONCE(!phys_addr_valid(phys_addr), "ioremap: invalid physical address %llx\n", (unsigned long long)phys_addr);Quoted 3 lines
Quoted 2 lines
work too?
Thanks, That is better. Will repost.
Perhaps this is not good patch concept as now each invalid physical address will not be emitted.
Quoted 7 lines
Before:
each invalid physical address printed
one stack dumpAfter:
one stck dump with first invalid physical address.
I misunderstand your meaning. You're right. My patch change its logical. Thanks for your reminder.
Sincerely,
zhong jiang
Quoted 3 lines
.
Quoted 22 lines · Borislav Petkov
Quoted 12 lines · zhong jiang
WARN_ONCEis more clear and simpler. Just replace it.Signed-off-by zhong jiang <[email protected]>--- arch/x86/mm/ioremap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)arch/x86/mm/ioremap.c +0
-0arch/x86/mm/ioremap.c static void __ioremap_check_mem(resource_size_t addr, unsigned long size, · line 176
Quoted 8 lines
arch/x86/mm/ioremap.c +2
-3@@ -172,9 +172,8 @@ static void __ioremap_check_mem(resource_size_t addr, unsigned long size,return NULL ;if (!phys_addr_valid (phys_addr)) { -printk (KERN_WARNING "ioremap: invalid physical address %llx\n" , - (unsigned long long )phys_addr); -WARN_ON_ONCE (1 ); +WARN_ONCE (1 ,"ioremap: invalid physical address %llx\n" , + (unsigned long long )phys_addr);Does
Quoted 6 lines
WARN_ONCE(!phys_addr_valid(phys_addr), "ioremap: invalid physical address %llx\n", (unsigned long long)phys_addr);work too?
Look at this again, It should not works. Because that will change the logical. if phys_addr_valid is false, we should drop out in time.
WARN_ONCE should be just visible for user not should to handle with address.
Thanks,
zhong jiang
Borislav Petkov
maintainerQuoted 2 lines · zhong jiang
Look at this again, It should not works. Because that will change the logical. if
phys_addr_validis false, we should drop out in time.
That you can do too:
arch/x86/mm/ioremap.c +3 -5
@@ -171,12 +171,10 @@ __ioremap_caller(resource_size_t phys_addr, unsigned long size,if (!size || last_addr < phys_addr)return NULL ; -if (!phys_addr_valid (phys_addr)) { -printk (KERN_WARNING "ioremap: invalid physical address %llx\n" , - (unsigned long long )phys_addr); -WARN_ON_ONCE (1 ); +if (WARN_ONCE (!phys_addr_valid (phys_addr), +"ioremap: invalid physical address %llx\n" , + (unsigned long long )phys_addr))return NULL ; - }__ioremap_check_mem (phys_addr, size, &io_desc);
---
I'm not sure whether we care about printing every invalid address, as Joe points out. Maybe we do... *shrug*
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--Quoted 13 lines · Borislav Petkov
Quoted 2 lines · zhong jiang
Look at this again, It should not works. Because that will change the logical. if
phys_addr_validis false, we should drop out in time.That you can do too:
arch/x86/mm/ioremap.c +0
-0@@ -171,12 +171,10 @@ __ioremap_caller(resource_size_t phys_addr, unsigned long size,if (!size || last_addr < phys_addr)return NULL ;
arch/x86/mm/ioremap.c __ioremap_caller(resource_size_t phys_addr, unsigned long size, · line 178
Quoted 10 lines
arch/x86/mm/ioremap.c +3
-5-if (!phys_addr_valid (phys_addr)) { -printk (KERN_WARNING "ioremap: invalid physical address %llx\n" , - (unsigned long long )phys_addr); -WARN_ON_ONCE (1 ); +if (WARN_ONCE (!phys_addr_valid (phys_addr), +"ioremap: invalid physical address %llx\n" , + (unsigned long long )phys_addr))return NULL ; - }
Yep, WARN_ONCE alway return true in that case.
Thanks,
zhong jiang
Quoted 7 lines
arch/x86/mm/ioremap.c +0
-1__ioremap_check_mem (phys_addr, size, &io_desc); ---I'm not sure whether we care about printing every invalid address, as Joe points out. Maybe we do... *shrug*
Borislav Petkov
maintainerQuoted 1 line · zhong jiang
Yep,
WARN_ONCEalway return true in that case.
Are you sure it does that always?
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--Quoted 4 lines · Borislav Petkov
Quoted 1 line · zhong jiang
Yep,
WARN_ONCEalway return true in that case.Are you sure it does that always?
WARN_ONCE will alway return true if its condition is true.:-)
Borislav Petkov
maintainerQuoted 1 line · zhong jiang
WARN_ONCEwill alway return true if its condition is true.:-)
And if its condition is false?
Lemme save you some time: WARN_ONCE() returns the @condition value so constructs like
if (WARN_ONCE(condition,...))
are possible. Grep the code for examples.
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--