Re: [PATCH] mm/debug: add a cast to u64 for atomic64_read()

From: Qian Cai
Date: Mon Mar 11 2019 - 10:00:28 EST


On Mon, 2019-03-11 at 12:21 +0000, Jason Gunthorpe wrote:
> On Sun, Mar 10, 2019 at 08:58:15PM -0700, Davidlohr Bueso wrote:
> > On Sun, 10 Mar 2019, Qian Cai wrote:
> >
> > > atomic64_read() on ppc64le returns "long int", so fix the same way as
> > > the commit d549f545e690 ("drm/virtio: use %llu format string form
> > > atomic64_t") by adding a cast to u64, which makes it work on all arches.
> > >
> > > In file included from ./include/linux/printk.h:7,
> > > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂfrom ./include/linux/kernel.h:15,
> > > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂfrom mm/debug.c:9:
> > > mm/debug.c: In function 'dump_mm':
> > > ./include/linux/kern_levels.h:5:18: warning: format '%llx' expects
> > > argument of type 'long long unsigned int', but argument 19 has type
> > > 'long int' [-Wformat=]
> > > #define KERN_SOH "\001"ÂÂ/* ASCII Start Of Header */
> > > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ^~~~~~
> > > ./include/linux/kern_levels.h:8:20: note: in expansion of macro
> > > 'KERN_SOH'
> > > #define KERN_EMERG KERN_SOH "0" /* system is unusable */
> > > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ^~~~~~~~
> > > ./include/linux/printk.h:297:9: note: in expansion of macro 'KERN_EMERG'
> > > Âprintk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
> > > ÂÂÂÂÂÂÂÂ^~~~~~~~~~
> > > mm/debug.c:133:2: note: in expansion of macro 'pr_emerg'
> > > Âpr_emerg("mm %px mmap %px seqnum %llu task_size %lu\n"
> > > Â^~~~~~~~
> > > mm/debug.c:140:17: note: format string is defined here
> > > Â "pinned_vm %llx data_vm %lx exec_vm %lx stack_vm %lx\n"
> > > ÂÂÂÂÂÂÂÂÂÂÂÂÂ~~~^
> > > ÂÂÂÂÂÂÂÂÂÂÂÂÂ%lx
> > >
> > > Fixes: 70f8a3ca68d3 ("mm: make mm->pinned_vm an atomic64 counter")
> > > Signed-off-by: Qian Cai <cai@xxxxxx>
> >
> > Acked-by: Davidlohr Bueso <dbueso@xxxxxxx>
>
> Not saying this patch shouldn't go ahead..
>
> But is there a special reason the atomic64*'s on ppc don't use the u64
> type like other archs? Seems like a better thing to fix than adding
> casts all over the place.
>

A bit of history here,

https://patchwork.kernel.org/patch/7344011/#15495901