linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Waiman Long <longman@redhat.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Clark Williams <clrkwllms@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	linux-rt-devel@lists.linux.dev,
	Wei Yang <richard.weiyang@gmail.com>,
	David Hildenbrand <david@kernel.org>,
	"Paul E . McKenney" <paulmck@kernel.org>
Subject: Re: [PATCH v3] mm/mm_init: Don't cond_resched() in deferred_init_memmap_chunk() if called from deferred_grow_zone()
Date: Fri, 23 Jan 2026 10:46:44 +0200	[thread overview]
Message-ID: <aXM1dF6o3wwJltiV@kernel.org> (raw)
In-Reply-To: <20260122112920.2b435873a0cc5f396df5d1a7@linux-foundation.org>

On Thu, Jan 22, 2026 at 11:29:20AM -0800, Andrew Morton wrote:
> On Thu, 22 Jan 2026 13:43:43 -0500 Waiman Long <longman@redhat.com> wrote:
> 
> > Commit 3acb913c9d5b ("mm/mm_init: use deferred_init_memmap_chunk()
> > in deferred_grow_zone()") made deferred_grow_zone() call
> > deferred_init_memmap_chunk() within a pgdat_resize_lock() critical
> > section with irqs disabled.
> >
> > It did check for irqs_disabled() in
> > deferred_init_memmap_chunk() to avoid calling cond_resched(). For a
> > PREEMPT_RT kernel build, however, spin_lock_irqsave() does not disable
> > interrupt but rcu_read_lock() is called. This leads to the following
> > bug report.
> > 
> >   BUG: sleeping function called from invalid context at mm/mm_init.c:2091
> >   in_atomic(): 0, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper/0
> >   preempt_count: 0, expected: 0
> >
> > @@ -2085,10 +2085,10 @@ deferred_init_memmap_chunk(unsigned long start_pfn, unsigned long end_pfn,
> >  
> >  			spfn = chunk_end;
> >  
> > -			if (irqs_disabled())
> > -				touch_nmi_watchdog();
> > -			else
> > +			if (can_resched)
> >  				cond_resched();
> > +			else
> > +				touch_nmi_watchdog();
> >  		}
> >  	}
> 
> Disables the cond_resched() in some situations.  Can this reintroduce
> the watchdog warnings which that cond_resched() was intended to
> prevent?
> 
> The cond_resched() was added by <dig, dig> da97f2d56bbd ("mm: call
> cond_resched() from deferred_init_memmap()").
> 
> Pasha's 2020 patch replaced touch_nmi_watchdog() with cond_resched() to
> prevent RCU stall warnings.  So I think the answer to my question is
> yes, going back to touch_nmi_watchdog() could reintroduce those RCU
> warnings.

Before 3acb913c9d5b ("mm/mm_init: use deferred_init_memmap_chunk() we had
touch_nmi_watchdog() in deferred_grow_zone() and cond_resched() in the
deferred_init_memmap()->deferred_init_memmap_chunk() that ran in a thread context.

I thought irqs_disabled() would be enough to differentiate these cases
because deferred_grow_zone() takes a spinlock, but I missed that with RT
spinlock also sleeps.

Using a boolean essentially restores the behaviour we had before the
refactoring.

-- 
Sincerely yours,
Mike.


  parent reply	other threads:[~2026-01-23  8:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-22 18:43 Waiman Long
2026-01-22 19:29 ` Andrew Morton
2026-01-22 20:56   ` Waiman Long
2026-01-23  8:46   ` Mike Rapoport [this message]
2026-01-23  7:24 ` Sebastian Andrzej Siewior
2026-01-23  8:47 ` Mike Rapoport

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aXM1dF6o3wwJltiV@kernel.org \
    --to=rppt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=bigeasy@linutronix.de \
    --cc=clrkwllms@kernel.org \
    --cc=david@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=longman@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=richard.weiyang@gmail.com \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox