RE: [PATCH v8 14/14] mm: zswap: Compress batching with request chaining in zswap_store() of large folios.

Sridhar, Kanchana P
2025-03-03T21:34:39Z

> -----Original Message-----
> From: Nhat Pham <nphamcs@gmail.com>
> Sent: Monday, March 3, 2025 10:22 AM
> To: lkp <lkp@intel.com>
> Cc: Sridhar, Kanchana P <kanchana.p.sridhar@intel.com>; linux-
> kernel@vger.kernel.org; linux-mm@kvack.org; hannes@cmpxchg.org;
> yosry.ahmed@linux.dev; chengming.zhou@linux.dev;
> usamaarif642@gmail.com; ryan.roberts@arm.com; 21cnbao@gmail.com;
> ying.huang@linux.alibaba.com; akpm@linux-foundation.org; linux-
> crypto@vger.kernel.org; herbert@gondor.apana.org.au;
> davem@davemloft.net; clabbe@baylibre.com; ardb@kernel.org;
> ebiggers@google.com; surenb@google.com; Accardi, Kristen C
> <kristen.c.accardi@intel.com>; llvm@lists.linux.dev; oe-kbuild-
> all@lists.linux.dev; Feghali, Wajdi K <wajdi.k.feghali@intel.com>; Gopal,
> Vinodh <vinodh.gopal@intel.com>
> Subject: Re: [PATCH v8 14/14] mm: zswap: Compress batching with request
> chaining in zswap_store() of large folios.
>
> On Mon, Mar 3, 2025 at 3:07 AM kernel test robot <lkp@intel.com> wrote:
> >
> > Hi Kanchana,
> >
> > kernel test robot noticed the following build errors:
> >
> > > 1166 prefetchw(entries[j]);
> > --
>
> Why are we doing this anyway? Does it have a notable performance
> difference? At the very least, leave a comment explaining why we're
> prefetching this (although the build error suggests that we have to
> remove it anyway).

Hi Nhat,

Yes, it does. The use of prefetchw reduces sys time by ~1.5% because
it minimizes cache-miss latency by moving the zswap entry to the cache
before it is written to.

This is data with kernel compilation test, v8 without prefetchw and v8 as-is:

--------------------------------------------------------------------------------
Kernel compile v8 without v8 v8 without v8
allmodconfig prefetchw prefetchw
2M folios
--------------------------------------------------------------------------------
zswap compressor deflate-iaa deflate-iaa zstd zstd
--------------------------------------------------------------------------------
real_sec 732.89 735.63 768.53 758.21
user_sec 15,708.37 15,699.84 15,702.64 15,678.73
sys_sec 4,632.58 4,563.70 5,735.06 5,635.69
--------------------------------------------------------------------------------
Max_Res_Set_Size_KB 1,874,672 1,867,516 1,874,684 1,872,888
--------------------------------------------------------------------------------
memcg_high 0 0 0 0
memcg_swap_fail 0 0 0 0
zswpout 114,742,930 112,836,725 92,904,961 89,596,085
zswpin 41,184,897 39,983,793 31,018,149 29,163,932
pswpout 625 1,069 558 1,059
pswpin 599 1,056 540 1,051
thp_swpout 1 2 1 2
thp_swpout_fallback 10,967 10,195 6,918 6,141
pgmajfault 42,588,331 41,349,069 31,931,882 30,006,422
ZSWPOUT-2048kB 7,661 8,710 6,799 7,480
SWPOUT-2048kB 1 2 1 2
--------------------------------------------------------------------------------

Sure, I will add a comment, and also "#include <linux/prefetch.h>" in zswap.c
that will resolve the build error. This is similar to how these files handle prefetchw:
mm/vmscan.c, kernel/locking/qspinlock.c, include/asm-generic/xor.h, etc.

Thanks,
Kanchana