RE: [PATCH v2 13/13] mm: zswap: Compress batching with Intel IAA in zswap_store() of large folios.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Dan,

> -----Original Message-----
> From: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> Sent: Monday, November 4, 2024 12:31 AM
> To: oe-kbuild@xxxxxxxxxxxxxxx; Sridhar, Kanchana P
> <kanchana.p.sridhar@xxxxxxxxx>; linux-kernel@xxxxxxxxxxxxxxx; linux-
> mm@xxxxxxxxx; hannes@xxxxxxxxxxx; yosryahmed@xxxxxxxxxx;
> nphamcs@xxxxxxxxx; chengming.zhou@xxxxxxxxx;
> usamaarif642@xxxxxxxxx; ryan.roberts@xxxxxxx; Huang, Ying
> <ying.huang@xxxxxxxxx>; 21cnbao@xxxxxxxxx; akpm@xxxxxxxxxxxxxxxxxxxx;
> linux-crypto@xxxxxxxxxxxxxxx; herbert@xxxxxxxxxxxxxxxxxxx;
> davem@xxxxxxxxxxxxx; clabbe@xxxxxxxxxxxx; ardb@xxxxxxxxxx;
> ebiggers@xxxxxxxxxx; surenb@xxxxxxxxxx; Accardi, Kristen C
> <kristen.c.accardi@xxxxxxxxx>; zanussi@xxxxxxxxxx
> Cc: lkp <lkp@xxxxxxxxx>; oe-kbuild-all@xxxxxxxxxxxxxxx; Feghali, Wajdi K
> <wajdi.k.feghali@xxxxxxxxx>; Gopal, Vinodh <vinodh.gopal@xxxxxxxxx>;
> Sridhar, Kanchana P <kanchana.p.sridhar@xxxxxxxxx>
> Subject: Re: [PATCH v2 13/13] mm: zswap: Compress batching with Intel IAA
> in zswap_store() of large folios.
> 
> Hi Kanchana,
> 
> kernel test robot noticed the following build warnings:
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Kanchana-P-
> Sridhar/crypto-acomp-Define-two-new-interfaces-for-compress-decompress-
> batching/20241103-112337
> base:   5c4cf96cd70230100b5d396d45a5c9a332539d19
> patch link:    https://lore.kernel.org/r/20241103032111.333282-14-
> kanchana.p.sridhar%40intel.com
> patch subject: [PATCH v2 13/13] mm: zswap: Compress batching with Intel
> IAA in zswap_store() of large folios.
> config: x86_64-randconfig-161-20241104 (https://download.01.org/0day-
> ci/archive/20241104/202411040859.2z0MfFkR-lkp@xxxxxxxxx/config)
> compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
> | Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> | Closes: https://lore.kernel.org/r/202411040859.2z0MfFkR-lkp@xxxxxxxxx/
> 
> smatch warnings:
> mm/zswap.c:1788 zswap_store_propagate_errors() warn: variable
> dereferenced before check 'sbp->entry' (see line 1785)
> 
> vim +1788 mm/zswap.c
> 
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1771  static
> __always_inline void zswap_store_propagate_errors(
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1772  	struct
> zswap_store_pipeline_state *zst,
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1773  	u8
> error_batch_idx)
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1774  {
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1775  	u8 i;
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1776
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1777  	if (zst-
> >errors[error_batch_idx])
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1778
> 	return;
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1779
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1780  	for (i = 0; i <
> zst->nr_comp_pages; ++i) {
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1781
> 	struct zswap_store_sub_batch_page *sbp = &zst->sub_batch[i];
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1782
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1783  		if
> (sbp->batch_idx == error_batch_idx) {
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1784
> 	if (!sbp->error) {
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02 @1785
> 		if (!IS_ERR_VALUE(sbp->entry->handle))
>                                                                                                   ^^^^^^^^^^^^^^^^^^
> Dereferenced
> 
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1786
> 			zpool_free(zst->pool->zpool, sbp->entry->handle);
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1787
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02 @1788
> 		if (sbp->entry) {
>                                                                                     ^^^^^^^^^^
> Checked too late

Thanks for pointing this out.  The implementation makes sure that all
sbp->entry values are valid before it gets to zswap_store_propagate_errors().
That said, I agree, the sbp->entry check can be done earlier to make the
code more correct/readable. I will fix this in v3.

Thanks,
Kanchana

> 
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1789
> 			zswap_entry_cache_free(sbp->entry);
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1790
> 			sbp->entry = NULL;
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1791
> 		}
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1792
> 		sbp->error = -EINVAL;
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1793
> 	}
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1794  		}
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1795  	}
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1796
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1797  	/*
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1798  	 * Set zswap
> status for the folio to "error"
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1799  	 * for use in
> swap_writepage.
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1800  	 */
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1801  	zst-
> >errors[error_batch_idx] = -EINVAL;
> c1252ac91d6a6a Kanchana P Sridhar 2024-11-02  1802  }
> 
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki






[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux