Re: [PATCH v2 5/7] mm/mglru: make LRU folio prefetch helper an inline function
From: Lian Wang
Date: Sun Aug 30 2026 - 03:44:29 EST
On Fri, 28 Aug 2026 07:47:02 +0800 "Barry Song (Xiaomi)" <baohua@xxxxxxxxxx> wrote:
> `prefetchw_prev_lru_folio()` is currently implemented as a macro with a
> potentially unused argument. This makes the helper harder to read and can
> also trigger checkpatch warnings about unused macro arguments.
>
> Make it a `static inline` function and remove the unnecessary `_field`
> argument. The helper always prefetches the previous folio's `flags`, so
> there is no need to make the field configurable.
>
> Signed-off-by: Barry Song (Xiaomi) <baohua@xxxxxxxxxx>
> Tested-by: Xueyuan Chen <xueyuan.chen21@xxxxxxxxx>
> ---
> mm/vmscan.c | 26 +++++++++++++++-----------
> 1 file changed, 15 insertions(+), 11 deletions(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 2b33d3f44682..81f95a968447 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -182,17 +182,21 @@ struct scan_control {
> };
>
> #ifdef ARCH_HAS_PREFETCHW
> -#define prefetchw_prev_lru_folio(_folio, _base, _field) \
> - do { \
> - if ((_folio)->lru.prev != _base) { \
> - struct folio *prev; \
> - \
> - prev = lru_to_folio(&(_folio->lru)); \
> - prefetchw(&prev->_field); \
> - } \
> - } while (0)
> +static inline void prefetchw_prev_lru_folio(struct folio *folio,
> + struct list_head *base)
> +{
> + if (folio->lru.prev != base) {
> + struct folio *prev;
> +
> + prev = lru_to_folio(&folio->lru);
> + prefetchw(&prev->flags);
> + }
> +}
> #else
> -#define prefetchw_prev_lru_folio(_folio, _base, _field) do { } while (0)
> +static inline void prefetchw_prev_lru_folio(struct folio *folio,
> + struct list_head *base)
> +{
> +}
> #endif
>
> /*
> @@ -1695,7 +1699,7 @@ static unsigned long isolate_lru_folios(unsigned long nr_to_scan,
> struct folio *folio;
>
> folio = lru_to_folio(src);
> - prefetchw_prev_lru_folio(folio, src, flags);
> + prefetchw_prev_lru_folio(folio, src);
>
> nr_pages = folio_nr_pages(folio);
> total_scan += nr_pages;
> --
> 2.34.1
This preserves the prefetch behavior while making the helper
interface clearer. Looks good to me.
Reviewed-by: Lian Wang <lianux.mm@xxxxxxxxx>