Re: [PATCH v3 06/18] mm/huge_memory: consolidate irq and locking for folio split
From: David Hildenbrand (Arm)
Date: Thu Aug 27 2026 - 12:29:39 EST
> +
> + /*
> + * Check if the folio is present in page cache.
> + * We assume all tail are present too, if folio is there.
> + */
> + if (xas_load(xas) != folio) {
> + ret = -EAGAIN;
> + goto fail;
> + }
How can this actually happen? We locked the folio and folio->mapping is set. How
could it possibly get truncated in the meantime?
> +
> + if (!folio_ref_freeze(folio, folio_cache_ref_count(folio) + 1)) {
> + ret = -EAGAIN;
> + goto fail;
> + }
>
> if (folio_test_pmd_mappable(folio) &&
> new_order < HPAGE_PMD_ORDER) {
> @@ -4106,6 +4123,8 @@ static int __folio_freeze_split_unmapped_file(struct folio *folio, unsigned int
> if (do_lru)
> lruvec_unlock(lruvec);
>
> +fail:
> + xas_unlock_irq(xas);
> return ret;
> }
>
> @@ -4245,19 +4264,7 @@ static int __folio_split(struct folio *folio, unsigned int new_order,
>
> unmap_folio(folio);
>
> - /* block interrupt reentry in xa_lock and spinlock */
> - local_irq_disable();
> - if (mapping) {
> - /*
> - * Check if the folio is present in page cache.
> - * We assume all tail are present too, if folio is there.
> - */
> - xas_lock(&xas);
> - xas_reset(&xas);
> - if (xas_load(&xas) != folio) {
> - ret = -EAGAIN;
> - goto fail;
> - }
> + if (!is_anon) {
Ah, there it is :)
Nice!
--
Cheers,
David