linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] mm/hugetlb.c: fix printk format warning for 32-bit phys_addr_t
@ 2020-03-18 21:33 Randy Dunlap
  2020-03-19  2:04 ` Joe Perches
  0 siblings, 1 reply; 6+ messages in thread
From: Randy Dunlap @ 2020-03-18 21:33 UTC (permalink / raw)
  To: Linux MM, Andrew Morton, LKML

From: Randy Dunlap <rdunlap@infradead.org>

Fix printk format warnings when phys_addr_t is 32 bits, i.e.,
CONFIG_PHYS_ADDR_T_64BIT is not set/enabled.

Fixes these build warnings:
  CC      mm/hugetlb.o
In file included from ../include/linux/printk.h:7:0,
                 from ../include/linux/kernel.h:15,
                 from ../include/linux/list.h:9,
                 from ../mm/hugetlb.c:6:
../mm/hugetlb.c: In function ‘hugetlb_cma_reserve’:
../include/linux/kern_levels.h:5:18: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘unsigned int’ [-Wformat=]
 #define KERN_SOH "\001"  /* ASCII Start Of Header */
                  ^
../include/linux/kern_levels.h:12:22: note: in expansion of macro ‘KERN_SOH’
 #define KERN_WARNING KERN_SOH "4" /* warning conditions */
                      ^~~~~~~~
../include/linux/printk.h:306:9: note: in expansion of macro ‘KERN_WARNING’
  printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
         ^~~~~~~~~~~~
../mm/hugetlb.c:5472:4: note: in expansion of macro ‘pr_warn’
    pr_warn("hugetlb_cma: reservation failed: err %d, node %d, [%llu, %llu)",
    ^~~~~~~
../mm/hugetlb.c:5472:67: note: format string is defined here
    pr_warn("hugetlb_cma: reservation failed: err %d, node %d, [%llu, %llu)",
                                                                ~~~^
                                                                %u
In file included from ../include/linux/printk.h:7:0,
                 from ../include/linux/kernel.h:15,
                 from ../include/linux/list.h:9,
                 from ../mm/hugetlb.c:6:
../include/linux/kern_levels.h:5:18: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 5 has type ‘unsigned int’ [-Wformat=]
 #define KERN_SOH "\001"  /* ASCII Start Of Header */
                  ^
../include/linux/kern_levels.h:12:22: note: in expansion of macro ‘KERN_SOH’
 #define KERN_WARNING KERN_SOH "4" /* warning conditions */
                      ^~~~~~~~
../include/linux/printk.h:306:9: note: in expansion of macro ‘KERN_WARNING’
  printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
         ^~~~~~~~~~~~
../mm/hugetlb.c:5472:4: note: in expansion of macro ‘pr_warn’
    pr_warn("hugetlb_cma: reservation failed: err %d, node %d, [%llu, %llu)",
    ^~~~~~~
../mm/hugetlb.c:5472:73: note: format string is defined here
    pr_warn("hugetlb_cma: reservation failed: err %d, node %d, [%llu, %llu)",
                                                                      ~~~^
                                                                      %u

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
---
 mm/hugetlb.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- linux-next-20200318.orig/mm/hugetlb.c
+++ linux-next-20200318/mm/hugetlb.c
@@ -5469,8 +5469,10 @@ void __init hugetlb_cma_reserve(int orde
 					     0, false,
 					     "hugetlb", &hugetlb_cma[nid]);
 		if (res) {
-			pr_warn("hugetlb_cma: reservation failed: err %d, node %d, [%llu, %llu)",
-				res, nid, PFN_PHYS(min_pfn), PFN_PHYS(max_pfn));
+			phys_addr_t begpa = PFN_PHYS(min_pfn);
+			phys_addr_t endpa = PFN_PHYS(max_pfn);
+			pr_warn("hugetlb_cma: reservation failed: err %d, node %d, [%pap, %pap)",
+				res, nid, &begpa, &endpa);
 			break;
 		}
 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH -next] mm/hugetlb.c: fix printk format warning for 32-bit phys_addr_t
  2020-03-18 21:33 [PATCH -next] mm/hugetlb.c: fix printk format warning for 32-bit phys_addr_t Randy Dunlap
@ 2020-03-19  2:04 ` Joe Perches
  2020-03-19  2:11   ` Randy Dunlap
  0 siblings, 1 reply; 6+ messages in thread
From: Joe Perches @ 2020-03-19  2:04 UTC (permalink / raw)
  To: Randy Dunlap, Linux MM, Andrew Morton, LKML

On Wed, 2020-03-18 at 14:33 -0700, Randy Dunlap wrote:
> From: Randy Dunlap <rdunlap@infradead.org>
> 
> Fix printk format warnings when phys_addr_t is 32 bits, i.e.,
> CONFIG_PHYS_ADDR_T_64BIT is not set/enabled.
[]
> ../mm/hugetlb.c:5472:73: note: format string is defined here
>     pr_warn("hugetlb_cma: reservation failed: err %d, node %d, [%llu, %llu)",
>                                                                       ~~~^
[]
> --- linux-next-20200318.orig/mm/hugetlb.c
> +++ linux-next-20200318/mm/hugetlb.c
> @@ -5469,8 +5469,10 @@ void __init hugetlb_cma_reserve(int orde
>  					     0, false,
>  					     "hugetlb", &hugetlb_cma[nid]);
>  		if (res) {
> -			pr_warn("hugetlb_cma: reservation failed: err %d, node %d, [%llu, %llu)",
> -				res, nid, PFN_PHYS(min_pfn), PFN_PHYS(max_pfn));
> +			phys_addr_t begpa = PFN_PHYS(min_pfn);
> +			phys_addr_t endpa = PFN_PHYS(max_pfn);
> +			pr_warn("hugetlb_cma: reservation failed: err %d, node %d, [%pap, %pap)",
> +				res, nid, &begpa, &endpa);

You might correct the odd use of an open bracket
then close parenthesis and add a new line too

Perhaps:
			pr_warn("%s: reservation failed: err %d, node %d, [%pap, %pap]\n",
				__func__, res, nid, &begpa, &endpa);




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH -next] mm/hugetlb.c: fix printk format warning for 32-bit phys_addr_t
  2020-03-19  2:04 ` Joe Perches
@ 2020-03-19  2:11   ` Randy Dunlap
  2020-03-19  2:37     ` Joe Perches
  0 siblings, 1 reply; 6+ messages in thread
From: Randy Dunlap @ 2020-03-19  2:11 UTC (permalink / raw)
  To: Joe Perches, Linux MM, Andrew Morton, LKML

On 3/18/20 7:04 PM, Joe Perches wrote:
> On Wed, 2020-03-18 at 14:33 -0700, Randy Dunlap wrote:
>> From: Randy Dunlap <rdunlap@infradead.org>
>>
>> Fix printk format warnings when phys_addr_t is 32 bits, i.e.,
>> CONFIG_PHYS_ADDR_T_64BIT is not set/enabled.
> []
>> ../mm/hugetlb.c:5472:73: note: format string is defined here
>>     pr_warn("hugetlb_cma: reservation failed: err %d, node %d, [%llu, %llu)",
>>                                                                       ~~~^
> []
>> --- linux-next-20200318.orig/mm/hugetlb.c
>> +++ linux-next-20200318/mm/hugetlb.c
>> @@ -5469,8 +5469,10 @@ void __init hugetlb_cma_reserve(int orde
>>  					     0, false,
>>  					     "hugetlb", &hugetlb_cma[nid]);
>>  		if (res) {
>> -			pr_warn("hugetlb_cma: reservation failed: err %d, node %d, [%llu, %llu)",
>> -				res, nid, PFN_PHYS(min_pfn), PFN_PHYS(max_pfn));
>> +			phys_addr_t begpa = PFN_PHYS(min_pfn);
>> +			phys_addr_t endpa = PFN_PHYS(max_pfn);
>> +			pr_warn("hugetlb_cma: reservation failed: err %d, node %d, [%pap, %pap)",
>> +				res, nid, &begpa, &endpa);
> 
> You might correct the odd use of an open bracket
> then close parenthesis and add a new line too

Definitely needs a newline char.

I'm fairly sure that the [begin, end) notation is done on purpose, meaning
<begin> is included in the range and <end> is not included in the range.

> 
> Perhaps:
> 			pr_warn("%s: reservation failed: err %d, node %d, [%pap, %pap]\n",
> 				__func__, res, nid, &begpa, &endpa);
> 
> 

thanks.
-- 
~Randy



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH -next] mm/hugetlb.c: fix printk format warning for 32-bit phys_addr_t
  2020-03-19  2:11   ` Randy Dunlap
@ 2020-03-19  2:37     ` Joe Perches
  2020-03-20  1:03       ` Randy Dunlap
  0 siblings, 1 reply; 6+ messages in thread
From: Joe Perches @ 2020-03-19  2:37 UTC (permalink / raw)
  To: Randy Dunlap, Linux MM, Andrew Morton, LKML

On Wed, 2020-03-18 at 19:11 -0700, Randy Dunlap wrote:
> On 3/18/20 7:04 PM, Joe Perches wrote:
> > On Wed, 2020-03-18 at 14:33 -0700, Randy Dunlap wrote:
> > > From: Randy Dunlap <rdunlap@infradead.org>
> > > 
> > > Fix printk format warnings when phys_addr_t is 32 bits, i.e.,
> > > CONFIG_PHYS_ADDR_T_64BIT is not set/enabled.
> > []
> > > ../mm/hugetlb.c:5472:73: note: format string is defined here
> > >     pr_warn("hugetlb_cma: reservation failed: err %d, node %d, [%llu, %llu)",
> > >                                                                       ~~~^
> > []
> > > --- linux-next-20200318.orig/mm/hugetlb.c
> > > +++ linux-next-20200318/mm/hugetlb.c
> > > @@ -5469,8 +5469,10 @@ void __init hugetlb_cma_reserve(int orde
> > >  					     0, false,
> > >  					     "hugetlb", &hugetlb_cma[nid]);
> > >  		if (res) {
> > > -			pr_warn("hugetlb_cma: reservation failed: err %d, node %d, [%llu, %llu)",
> > > -				res, nid, PFN_PHYS(min_pfn), PFN_PHYS(max_pfn));
> > > +			phys_addr_t begpa = PFN_PHYS(min_pfn);
> > > +			phys_addr_t endpa = PFN_PHYS(max_pfn);
> > > +			pr_warn("hugetlb_cma: reservation failed: err %d, node %d, [%pap, %pap)",
> > > +				res, nid, &begpa, &endpa);
> > 
> > You might correct the odd use of an open bracket
> > then close parenthesis and add a new line too
> 
> Definitely needs a newline char.
> 
> I'm fairly sure that the [begin, end) notation is done on purpose, meaning
> <begin> is included in the range and <end> is not included in the range.

OK, that seems a pretty obscure and not obvious use of
interval notation, at least to me. (18 uses treewide ?)

Maybe it could be documented somewhere?

It's an odd pattern to grep.  Maybe I missed some.

$ git grep -P '".*[\[\{]\s*%\d*[ldux]+\s*[/:,\.\-]?\s*%\d*[ldux]+\).*"'
arch/x86/kernel/alternative.c:  DUMP_BYTES(instr, a->instrlen, "%px: [%d:%d) optimized NOPs: ",
drivers/clk/qcom/clk-alpha-pll.c:               pr_err("%s: Rounded rate %lu not within range [%lu, %lu)\n",
fs/ext4/extents_status.c:               printk(KERN_DEBUG " [%u/%u) %llu %x",
fs/ext4/extents_status.c:                       es_debug("%u cached by [%u/%u) %llu %x\n",
fs/ext4/extents_status.c:       es_debug("add [%u/%u) %llu %x to extent status tree of inode %lu\n",
fs/ext4/extents_status.c:                       es_debug("%u cached by [%u/%u)\n",
fs/ext4/extents_status.c:       es_debug("remove [%u/%u) from extent status tree of inode %lu\n",
fs/nilfs2/cpfile.c:                       "cannot delete checkpoints: invalid range [%llu, %llu)",
fs/nilfs2/dat.c:                          "%s: invalid vblocknr = %llu, [%llu, %llu)",
include/trace/events/ext4.h:    TP_printk("dev %d,%d ino %lu es [%u/%u) mapped %llu status %s",
include/trace/events/ext4.h:    TP_printk("dev %d,%d ino %lu es [%lld/%lld)",
include/trace/events/ext4.h:    TP_printk("dev %d,%d ino %lu es [%u/%u) mapped %llu status %s",
include/trace/events/ext4.h:    TP_printk("dev %d,%d ino %lu found %d [%u/%u) %llu %s",
include/trace/events/ext4.h:    TP_printk("dev %d,%d ino %lu es [%u/%u) mapped %llu status %s "
mm/hugetlb.c:                   pr_warn("hugetlb_cma: reservation failed: err %d, node %d, [%llu, %llu)",
mm/kasan/report.c:              pr_err(" [%lu, %lu) '%s'", offset, offset + size, token);
mm/page_alloc.c:                pr_info_ratelimited("%s: [%lx, %lx) PFNs busy\n",
tools/testing/selftests/kvm/demand_paging_test.c:               PER_VCPU_DEBUG("Added VCPU %d with test mem gpa [%lx, %lx)\n",



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH -next] mm/hugetlb.c: fix printk format warning for 32-bit phys_addr_t
  2020-03-19  2:37     ` Joe Perches
@ 2020-03-20  1:03       ` Randy Dunlap
  2020-03-20  1:06         ` Joe Perches
  0 siblings, 1 reply; 6+ messages in thread
From: Randy Dunlap @ 2020-03-20  1:03 UTC (permalink / raw)
  To: Joe Perches, Linux MM, Andrew Morton, LKML

On 3/18/20 7:37 PM, Joe Perches wrote:
> On Wed, 2020-03-18 at 19:11 -0700, Randy Dunlap wrote:
>> On 3/18/20 7:04 PM, Joe Perches wrote:
>>> On Wed, 2020-03-18 at 14:33 -0700, Randy Dunlap wrote:
>>>> From: Randy Dunlap <rdunlap@infradead.org>
>>>>
>>>> Fix printk format warnings when phys_addr_t is 32 bits, i.e.,
>>>> CONFIG_PHYS_ADDR_T_64BIT is not set/enabled.
>>> []
>>>> ../mm/hugetlb.c:5472:73: note: format string is defined here
>>>>     pr_warn("hugetlb_cma: reservation failed: err %d, node %d, [%llu, %llu)",
>>>>                                                                       ~~~^
>>> []
>>>> --- linux-next-20200318.orig/mm/hugetlb.c
>>>> +++ linux-next-20200318/mm/hugetlb.c
>>>> @@ -5469,8 +5469,10 @@ void __init hugetlb_cma_reserve(int orde
>>>>  					     0, false,
>>>>  					     "hugetlb", &hugetlb_cma[nid]);
>>>>  		if (res) {
>>>> -			pr_warn("hugetlb_cma: reservation failed: err %d, node %d, [%llu, %llu)",
>>>> -				res, nid, PFN_PHYS(min_pfn), PFN_PHYS(max_pfn));
>>>> +			phys_addr_t begpa = PFN_PHYS(min_pfn);
>>>> +			phys_addr_t endpa = PFN_PHYS(max_pfn);
>>>> +			pr_warn("hugetlb_cma: reservation failed: err %d, node %d, [%pap, %pap)",
>>>> +				res, nid, &begpa, &endpa);
>>>
>>> You might correct the odd use of an open bracket
>>> then close parenthesis and add a new line too
>>
>> Definitely needs a newline char.
>>
>> I'm fairly sure that the [begin, end) notation is done on purpose, meaning
>> <begin> is included in the range and <end> is not included in the range.
> 
> OK, that seems a pretty obscure and not obvious use of
> interval notation, at least to me. (18 uses treewide ?)
> 
> Maybe it could be documented somewhere?

I thought about where to put that and came up empty.

> It's an odd pattern to grep.  Maybe I missed some.

It's probably not used much more than this.

> $ git grep -P '".*[\[\{]\s*%\d*[ldux]+\s*[/:,\.\-]?\s*%\d*[ldux]+\).*"'
> arch/x86/kernel/alternative.c:  DUMP_BYTES(instr, a->instrlen, "%px: [%d:%d) optimized NOPs: ",
> drivers/clk/qcom/clk-alpha-pll.c:               pr_err("%s: Rounded rate %lu not within range [%lu, %lu)\n",
> fs/ext4/extents_status.c:               printk(KERN_DEBUG " [%u/%u) %llu %x",
> fs/ext4/extents_status.c:                       es_debug("%u cached by [%u/%u) %llu %x\n",
> fs/ext4/extents_status.c:       es_debug("add [%u/%u) %llu %x to extent status tree of inode %lu\n",
> fs/ext4/extents_status.c:                       es_debug("%u cached by [%u/%u)\n",
> fs/ext4/extents_status.c:       es_debug("remove [%u/%u) from extent status tree of inode %lu\n",
> fs/nilfs2/cpfile.c:                       "cannot delete checkpoints: invalid range [%llu, %llu)",
> fs/nilfs2/dat.c:                          "%s: invalid vblocknr = %llu, [%llu, %llu)",
> include/trace/events/ext4.h:    TP_printk("dev %d,%d ino %lu es [%u/%u) mapped %llu status %s",
> include/trace/events/ext4.h:    TP_printk("dev %d,%d ino %lu es [%lld/%lld)",
> include/trace/events/ext4.h:    TP_printk("dev %d,%d ino %lu es [%u/%u) mapped %llu status %s",
> include/trace/events/ext4.h:    TP_printk("dev %d,%d ino %lu found %d [%u/%u) %llu %s",
> include/trace/events/ext4.h:    TP_printk("dev %d,%d ino %lu es [%u/%u) mapped %llu status %s "
> mm/hugetlb.c:                   pr_warn("hugetlb_cma: reservation failed: err %d, node %d, [%llu, %llu)",
> mm/kasan/report.c:              pr_err(" [%lu, %lu) '%s'", offset, offset + size, token);
> mm/page_alloc.c:                pr_info_ratelimited("%s: [%lx, %lx) PFNs busy\n",
> tools/testing/selftests/kvm/demand_paging_test.c:               PER_VCPU_DEBUG("Added VCPU %d with test mem gpa [%lx, %lx)\n",
> 
> 

thanks.

-- 
~Randy



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH -next] mm/hugetlb.c: fix printk format warning for 32-bit phys_addr_t
  2020-03-20  1:03       ` Randy Dunlap
@ 2020-03-20  1:06         ` Joe Perches
  0 siblings, 0 replies; 6+ messages in thread
From: Joe Perches @ 2020-03-20  1:06 UTC (permalink / raw)
  To: Randy Dunlap, Linux MM, Andrew Morton, LKML

On Thu, 2020-03-19 at 18:03 -0700, Randy Dunlap wrote:
> On 3/18/20 7:37 PM, Joe Perches wrote:
> > On Wed, 2020-03-18 at 19:11 -0700, Randy Dunlap wrote:

> > > I'm fairly sure that the [begin, end) notation is done on purpose, meaning
> > > 
> > > <begin> is included in the range and <end> is not included in the range.
> > 
> > OK, that seems a pretty obscure and not obvious use of
> > interval notation, at least to me. (18 uses treewide ?)
> > 
> > Maybe it could be documented somewhere?
> 
> I thought about where to put that and came up empty.

No worries then, it's likely not _too_ obscure
to anyone that's sent a log for analysis.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-03-20  1:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-18 21:33 [PATCH -next] mm/hugetlb.c: fix printk format warning for 32-bit phys_addr_t Randy Dunlap
2020-03-19  2:04 ` Joe Perches
2020-03-19  2:11   ` Randy Dunlap
2020-03-19  2:37     ` Joe Perches
2020-03-20  1:03       ` Randy Dunlap
2020-03-20  1:06         ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).