diff mbox series

zram: Use atomic_long_read() to read atomic_long_t

Message ID 20230225121523.3288544-1-geert+renesas@glider.be (mailing list archive)
State New, archived
Headers show
Series zram: Use atomic_long_read() to read atomic_long_t | expand

Commit Message

Geert Uytterhoeven Feb. 25, 2023, 12:15 p.m. UTC
On 32-bit:

    drivers/block/zram/zram_drv.c: In function ‘mm_stat_show’:
    drivers/block/zram/zram_drv.c:1234:23: error: passing argument 1 of ‘atomic64_read’ from incompatible pointer type [-Werror=incompatible-pointer-types]
     1234 |    (u64)atomic64_read(&pool_stats.objs_moved));
	  |                       ^~~~~~~~~~~~~~~~~~~~~~
	  |                       |
	  |                       atomic_long_t * {aka struct <anonymous> *}
    In file included from ./include/linux/atomic.h:82,
		     from ./include/linux/mm_types_task.h:13,
		     from ./include/linux/mm_types.h:5,
		     from ./include/linux/buildid.h:5,
		     from ./include/linux/module.h:14,
		     from drivers/block/zram/zram_drv.c:18:
    ./include/linux/atomic/atomic-instrumented.h:644:33: note: expected ‘const atomic64_t *’ {aka ‘const struct <anonymous> *’} but argument is of type ‘atomic_long_t *’ {aka ‘struct <anonymous> *’}
      644 | atomic64_read(const atomic64_t *v)
	  |               ~~~~~~~~~~~~~~~~~~^

Fix this by using atomic_long_read() instead.

Reported-by; noreply@ellerman.id.au
Fixes: b7d89654a988a2a4 ("zram: show zsmalloc objs_moved stat in mm_stat")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/block/zram/zram_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Sergey Senozhatsky Feb. 26, 2023, 3:38 a.m. UTC | #1
On (23/02/25 13:15), Geert Uytterhoeven wrote:
> On 32-bit:
> 
>     drivers/block/zram/zram_drv.c: In function ‘mm_stat_show’:
>     drivers/block/zram/zram_drv.c:1234:23: error: passing argument 1 of ‘atomic64_read’ from incompatible pointer type [-Werror=incompatible-pointer-types]
>      1234 |    (u64)atomic64_read(&pool_stats.objs_moved));
> 	  |                       ^~~~~~~~~~~~~~~~~~~~~~
> 	  |                       |
> 	  |                       atomic_long_t * {aka struct <anonymous> *}
>     In file included from ./include/linux/atomic.h:82,
> 		     from ./include/linux/mm_types_task.h:13,
> 		     from ./include/linux/mm_types.h:5,
> 		     from ./include/linux/buildid.h:5,
> 		     from ./include/linux/module.h:14,
> 		     from drivers/block/zram/zram_drv.c:18:
>     ./include/linux/atomic/atomic-instrumented.h:644:33: note: expected ‘const atomic64_t *’ {aka ‘const struct <anonymous> *’} but argument is of type ‘atomic_long_t *’ {aka ‘struct <anonymous> *’}
>       644 | atomic64_read(const atomic64_t *v)
> 	  |               ~~~~~~~~~~~~~~~~~~^
> 
> Fix this by using atomic_long_read() instead.

Hi Geert,
The patch that cause the warning probably will be droppped from
the series in v3.
Andrew Morton Feb. 26, 2023, 4:30 a.m. UTC | #2
On Sat, 25 Feb 2023 13:15:23 +0100 Geert Uytterhoeven <geert+renesas@glider.be> wrote:

> On 32-bit:
> 
>     drivers/block/zram/zram_drv.c: In function ‘mm_stat_show’:
>     drivers/block/zram/zram_drv.c:1234:23: error: passing argument 1 of ‘atomic64_read’ from incompatible pointer type [-Werror=incompatible-pointer-types]
>      1234 |    (u64)atomic64_read(&pool_stats.objs_moved));
> 	  |                       ^~~~~~~~~~~~~~~~~~~~~~
> 	  |                       |
> 	  |                       atomic_long_t * {aka struct <anonymous> *}
>     In file included from ./include/linux/atomic.h:82,
> 		     from ./include/linux/mm_types_task.h:13,
> 		     from ./include/linux/mm_types.h:5,
> 		     from ./include/linux/buildid.h:5,
> 		     from ./include/linux/module.h:14,
> 		     from drivers/block/zram/zram_drv.c:18:
>     ./include/linux/atomic/atomic-instrumented.h:644:33: note: expected ‘const atomic64_t *’ {aka ‘const struct <anonymous> *’} but argument is of type ‘atomic_long_t *’ {aka ‘struct <anonymous> *’}
>       644 | atomic64_read(const atomic64_t *v)
> 	  |               ~~~~~~~~~~~~~~~~~~^
> 
> Fix this by using atomic_long_read() instead.
> 
> Reported-by; noreply@ellerman.id.au

That's an interesting one.  Was this mpe@?

I like it when a Reported-by: is followed by a Link: to the report, so
I can go hunt down such things.
Andrew Morton Feb. 26, 2023, 4:57 a.m. UTC | #3
On Sat, 25 Feb 2023 20:30:52 -0800 Andrew Morton <akpm@linux-foundation.org> wrote:

> > Fix this by using atomic_long_read() instead.
> > 
> > Reported-by; noreply@ellerman.id.au
> 
> That's an interesting one.  Was this mpe@?
> 
> I like it when a Reported-by: is followed by a Link: to the report, so
> I can go hunt down such things.

I found this, and added it to the changelog:

Reported-by: kernel test robot <lkp@intel.com>
  Link: https://lore.kernel.org/oe-kbuild-all/202302241840.nwdXqE5r-lkp@intel.com/
Geert Uytterhoeven Feb. 26, 2023, 9:45 a.m. UTC | #4
Hi Andrew,

On Sun, Feb 26, 2023 at 5:57 AM Andrew Morton <akpm@linux-foundation.org> wrote:
> On Sat, 25 Feb 2023 20:30:52 -0800 Andrew Morton <akpm@linux-foundation.org> wrote:
> > > Fix this by using atomic_long_read() instead.
> > >
> > > Reported-by; noreply@ellerman.id.au
> >
> > That's an interesting one.  Was this mpe@?

No, from the kisskb build bot, which sends private emails to the
architecture maintainers when one of their builds fail:

----8<-------------------------------------------------------------------------------------------
Subject: kisskb: FAILED linux-next/m68k-defconfig/m68k-gcc8 Sat Feb 25, 14:34
From: noreply@ellerman.id.au
To: geert@linux-m68k.org
Date: Sat, 25 Feb 2023 03:35:59 -0000
Message-ID: <20230225033559.1.93322@37da20578230>

FAILED linux-next/m68k-defconfig/m68k-gcc8 Sat Feb 25, 14:34

http://kisskb.ellerman.id.au/kisskb/buildresult/14885627/

Commit:   Add linux-next specific files for 20230225
          8232539f864ca60474e38eb42d451f5c26415856
Compiler: m68k-linux-gcc (GCC) 8.5.0 / GNU ld (GNU Binutils) 2.36.1

Possible errors
---------------

drivers/block/zram/zram_drv.c:1234:23: error: passing argument 1 of
'atomic64_read' from incompatible pointer type
[-Werror=incompatible-pointer-types]
cc1: some warnings being treated as errors
make[5]: *** [scripts/Makefile.build:252: drivers/block/zram/zram_drv.o] Error 1
make[4]: *** [scripts/Makefile.build:494: drivers/block/zram] Error 2
make[3]: *** [scripts/Makefile.build:494: drivers/block] Error 2
make[2]: *** [scripts/Makefile.build:494: drivers] Error 2
make[1]: *** [Makefile:2028: .] Error 2
make: *** [Makefile:226: __sub-make] Error 2

Possible warnings (1)
----------------------

include/linux/list.h:74:12: warning: 'seed_devices' may be used
uninitialized in this function [-Wmaybe-uninitialized]
------------------------------------------------------------------------------------------>8-----

> > I like it when a Reported-by: is followed by a Link: to the report, so
> > I can go hunt down such things.
>
> I found this, and added it to the changelog:
>
> Reported-by: kernel test robot <lkp@intel.com>
>   Link: https://lore.kernel.org/oe-kbuild-all/202302241840.nwdXqE5r-lkp@intel.com/

That's a different bot ;-)

Gr{oetje,eeting}s,

                        Geert
diff mbox series

Patch

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 3194e9254c6f3a04..8fff358c9cbace17 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1221,7 +1221,7 @@  static ssize_t mm_stat_show(struct device *dev,
 	max_used = atomic_long_read(&zram->stats.max_used_pages);
 
 	ret = scnprintf(buf, PAGE_SIZE,
-			"%8llu %8llu %8llu %8lu %8ld %8llu %8lu %8llu %8llu %8llu\n",
+			"%8llu %8llu %8llu %8lu %8ld %8llu %8lu %8llu %8llu %8lu\n",
 			orig_size << PAGE_SHIFT,
 			(u64)atomic64_read(&zram->stats.compr_data_size),
 			mem_used << PAGE_SHIFT,
@@ -1231,7 +1231,7 @@  static ssize_t mm_stat_show(struct device *dev,
 			atomic_long_read(&pool_stats.pages_compacted),
 			(u64)atomic64_read(&zram->stats.huge_pages),
 			(u64)atomic64_read(&zram->stats.huge_pages_since),
-			(u64)atomic64_read(&pool_stats.objs_moved));
+			atomic_long_read(&pool_stats.objs_moved));
 	up_read(&zram->init_lock);
 
 	return ret;