Re: [PATCH v2 2/2] mm: initialize deferred pages with interrupts enabled

From: David Hildenbrand
Date: Thu Apr 02 2020 - 03:39:07 EST


> + /*
> + * Once we unlock here, the zone cannot be grown anymore, thus if an
> + * interrupt thread must allocate this early in boot, zone must be
> + * pre-grown prior to start of deferred page initialization.
> + */
> + pgdat_resize_unlock(pgdat, &flags);
> +
> /* Only the highest zone is deferred so find it */
> for (zid = 0; zid < MAX_NR_ZONES; zid++) {
> zone = pgdat->node_zones + zid;
> @@ -1809,11 +1816,9 @@ static int __init deferred_init_memmap(void *data)
> */
> while (spfn < epfn) {
> nr_pages += deferred_init_maxorder(&i, zone, &spfn, &epfn);
> - touch_nmi_watchdog();
> + cond_resched();

I do wonder if this change is strictly required in this patch (IOW, if
we could keep calling touch_nmi_watchdog() also without holding a spinlock)

Anyhow, it's the right thing to do.

> }
> zone_empty:
> - pgdat_resize_unlock(pgdat, &flags);
> -
> /* Sanity check that the next zone really is unpopulated */
> WARN_ON(++zid < MAX_NR_ZONES && populated_zone(++zone));
>
> @@ -1855,17 +1860,6 @@ deferred_grow_zone(struct zone *zone, unsigned int order)
>
> pgdat_resize_lock(pgdat, &flags);
>
> - /*
> - * If deferred pages have been initialized while we were waiting for
> - * the lock, return true, as the zone was grown. The caller will retry
> - * this zone. We won't return to this function since the caller also
> - * has this static branch.
> - */
> - if (!static_branch_unlikely(&deferred_pages)) {
> - pgdat_resize_unlock(pgdat, &flags);
> - return true;
> - }
> -
> /*
> * If someone grew this zone while we were waiting for spinlock, return
> * true, as there might be enough pages already.
>


I think we should also look into cleaning up deferred_grow_zone( next),
we still have that touch_nmi_watchdog() in there. We should rework
locking. (I think Michal requested that as well)

For now, this seems to survive my basic testing (RCU stalls gone)

--
Thanks,

David / dhildenb