[PATCH -next] mm/hugetlb.c: fix printk format warning for 32-bit phys_addr_t

From: Randy Dunlap
Date: Wed Mar 18 2020 - 17:33:22 EST


From: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>

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@xxxxxxxxxxxxx>
---
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;
}