[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250917144418.25cb9117d64b32cb0c7908d9@linux-foundation.org>
Date: Wed, 17 Sep 2025 14:44:18 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Ankur Arora <ankur.a.arora@...cle.com>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org, x86@...nel.org,
david@...hat.com, bp@...en8.de, dave.hansen@...ux.intel.com, hpa@...or.com,
mingo@...hat.com, mjguzik@...il.com, luto@...nel.org, peterz@...radead.org,
acme@...nel.org, namhyung@...nel.org, tglx@...utronix.de,
willy@...radead.org, raghavendra.kt@....com, boris.ostrovsky@...cle.com,
konrad.wilk@...cle.com
Subject: Re: [PATCH v7 13/16] mm: memory: support clearing page ranges
On Wed, 17 Sep 2025 08:24:15 -0700 Ankur Arora <ankur.a.arora@...cle.com> wrote:
> Change folio_zero_user() to clear contiguous page ranges instead of
> clearing using the current page-at-a-time approach. Exposing the largest
> feasible length can be useful in enabling processors to optimize based
> on extent.
This patch is something which MM developers might care to take a closer
look at.
> However, clearing in large chunks can have two problems:
>
> - cache locality when clearing small folios (< MAX_ORDER_NR_PAGES)
> (larger folios don't have any expectation of cache locality).
>
> - preemption latency when clearing large folios.
>
> Handle the first by splitting the clearing in three parts: the
> faulting page and its immediate locality, its left and right
> regions; with the local neighbourhood cleared last.
Has this optimization been shown to be beneficial?
If so, are you able to share some measurements?
If not, maybe it should be removed?
> ...
>
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -7021,40 +7021,80 @@ static inline int process_huge_page(
> return 0;
> }
>
> -static void clear_gigantic_page(struct folio *folio, unsigned long addr_hint,
> - unsigned int nr_pages)
> +/*
> + * Clear contiguous pages chunking them up when running under
> + * non-preemptible models.
> + */
> +static void clear_contig_highpages(struct page *page, unsigned long addr,
> + unsigned int npages)
Called "_highpages" because it wraps clear_user_highpages(). It really
should be called clear_contig_user_highpages() ;) (Not serious)
> {
> - unsigned long addr = ALIGN_DOWN(addr_hint, folio_size(folio));
> - int i;
> + unsigned int i, count, unit;
>
> - might_sleep();
> - for (i = 0; i < nr_pages; i++) {
> + unit = preempt_model_preemptible() ? npages : PAGE_CONTIG_NR;
Almost nothing uses preempt_model_preemptible() and I'm not usefully
familiar with it. Will this check avoid all softlockup/rcu/etc
detections in all situations (ie, configs)?
> + for (i = 0; i < npages; ) {
> + count = min(unit, npages - i);
> + clear_user_highpages(nth_page(page, i),
> + addr + i * PAGE_SIZE, count);
> + i += count;
> cond_resched();
> - clear_user_highpage(folio_page(folio, i), addr + i * PAGE_SIZE);
> }
> }
Powered by blists - more mailing lists