public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* re: zswap: do not shrink if cgroup may not zswap
@ 2023-06-02 12:38 Colin King (gmail)
  2023-06-02 13:47 ` Johannes Weiner
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King (gmail) @ 2023-06-02 12:38 UTC (permalink / raw)
  To: Nhat Pham, Seth Jennings, Dan Streetman, Vitaly Wool,
	Andrew Morton, Johannes Weiner, Linux-MM
  Cc: linux-kernel@vger.kernel.org

Hi,

static analysis with clang scan build has detected an issue in the 
following commit:

commit 6804144bf1cfa3978ad98e625d8a1d2a4b80cbee
Author: Nhat Pham <nphamcs@gmail.com>
Date:   Tue May 30 15:24:40 2023 -0700

     zswap: do not shrink if cgroup may not zswap


The issue is as follows in function zswap_frontswap_store in mm/zswap.c:

         /*
          * XXX: zswap reclaim does not work with cgroups yet. Without a
          * cgroup-aware entry LRU, we will push out entries system-wide 
based on
          * local cgroup limits.
          */
         objcg = get_obj_cgroup_from_page(page);
         if (objcg && !obj_cgroup_may_zswap(objcg))
                 goto reject;

mm/zswap.c:1210:6: warning: variable 'ret' is used uninitialized 
whenever 'if' condition is true [-Wsometimes-uninitialized]

The goto reject path ends up returning ret, however, ret at this point 
has not been initialized, so a garbage return value is being returned
by function zswap_frontswap_store

Colin

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

* Re: zswap: do not shrink if cgroup may not zswap
  2023-06-02 12:38 zswap: do not shrink if cgroup may not zswap Colin King (gmail)
@ 2023-06-02 13:47 ` Johannes Weiner
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Weiner @ 2023-06-02 13:47 UTC (permalink / raw)
  To: Colin King (gmail)
  Cc: Nhat Pham, Seth Jennings, Dan Streetman, Vitaly Wool,
	Andrew Morton, Linux-MM, linux-kernel@vger.kernel.org

On Fri, Jun 02, 2023 at 01:38:44PM +0100, Colin King (gmail) wrote:
> Hi,
> 
> static analysis with clang scan build has detected an issue in the following
> commit:
> 
> commit 6804144bf1cfa3978ad98e625d8a1d2a4b80cbee
> Author: Nhat Pham <nphamcs@gmail.com>
> Date:   Tue May 30 15:24:40 2023 -0700
> 
>     zswap: do not shrink if cgroup may not zswap
> 
> 
> The issue is as follows in function zswap_frontswap_store in mm/zswap.c:
> 
>         /*
>          * XXX: zswap reclaim does not work with cgroups yet. Without a
>          * cgroup-aware entry LRU, we will push out entries system-wide
> based on
>          * local cgroup limits.
>          */
>         objcg = get_obj_cgroup_from_page(page);
>         if (objcg && !obj_cgroup_may_zswap(objcg))
>                 goto reject;
> 
> mm/zswap.c:1210:6: warning: variable 'ret' is used uninitialized whenever
> 'if' condition is true [-Wsometimes-uninitialized]
> 
> The goto reject path ends up returning ret, however, ret at this point has
> not been initialized, so a garbage return value is being returned
> by function zswap_frontswap_store

Thanks Colin. Andrew has picked up a fixlet for this, and it should be
rectified in the next iteration:

https://lore.kernel.org/mm-commits/CAJD7tkZGYj2yiwk5qd=_bqqnxT-Zd+BtFdqRV_xHk2iX+2Rh_g@mail.gmail.com/T/#

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

end of thread, other threads:[~2023-06-02 13:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-02 12:38 zswap: do not shrink if cgroup may not zswap Colin King (gmail)
2023-06-02 13:47 ` Johannes Weiner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox