The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: Pratyush Yadav <pratyush@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>,
	 Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>,
	 Lorenzo Stoakes <ljs@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	 Vlastimil Babka <vbabka@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	 Michal Hocko <mhocko@suse.com>,
	Baoquan He <baoquan.he@linux.dev>,
	 Pasha Tatashin <pasha.tatashin@soleen.com>,
	Miaohe Lin <linmiaohe@huawei.com>,
	 Naoya Horiguchi <nao.horiguchi@gmail.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	 kexec@lists.infradead.org, rmikey@meta.com, riel@surriel.com,
	kernel-team@meta.com,  Kiryl Shutsemau <kas@kernel.org>
Subject: Re: [PATCH v5] kexec: keep the next kernel off hardware-poisoned pages
Date: Wed, 12 Aug 2026 04:11:54 -0700	[thread overview]
Message-ID: <anxUnuML9UTepBTu@gmail.com> (raw)
In-Reply-To: <2vxzldac51om.fsf@kernel.org>

On Tue, Aug 11, 2026 at 01:36:25PM +0200, Pratyush Yadav wrote:
> On Tue, Aug 11 2026, Breno Leitao wrote:
> 
> > On Mon, Aug 10, 2026 at 07:32:41PM +0300, Mike Rapoport wrote:
> >> Hi Breno,
> >> 
> >> On Mon, Aug 10, 2026 at 06:32:04AM -0700, Breno Leitao wrote:
> [...]
> >> > +	for (pfn = PHYS_PFN(start); pfn <= end_pfn; pfn++) {
> >> > +
> >> > +		cond_resched();
> >> 
> >> cond_resched() for every pfn is too much, isn't it?
> >
> > It is what the other pfn walkers do: the kpageflags read loop in
> > fs/proc/page.c and read_page_owner() in mm/page_owner.c both call it
> > once per pfn. 
> >
> > But I honestly don't have a strong opinion here, though, happy to batch
> > it if you prefer. Would this one look better?:
> >
> > 	if (!(pfn % MAX_ORDER_NR_PAGES))
> > 		cond_resched();
> >
> 
> Now that we are looking at this, Sashiko also complains about a race
> with memory hotunplug.
> 
>     Can the page pointer become invalid here due to concurrent memory hotplug?
> 
>     The loop retrieves the struct page pointer using pfn_to_online_page() and
>     then yields the CPU with cond_resched(). Since this iteration runs without
>     holding get_online_mems(), could a concurrent memory hot-unplug event offline
>     and remove the memory section while the thread is sleeping?
> 
>     If the vmemmap backing the struct page is freed and its page tables torn
>     down, dereferencing the pointer in is_page_hwpoison(page) upon waking
>     could cause a use-after-free regression.
> 
> Kind of makes sense at first glance but I didn't go and look. Perhaps it
> is better to do the cond_resched() at the end of the loop?

Agree. I was calling cond_resched() earlier because I wanted to call it
before the "continue", but it is rather unusal. Let me move it at the
end of the loop.

Thanks for the review,
--breno

  reply	other threads:[~2026-08-12 11:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10 13:32 [PATCH v5] kexec: keep the next kernel off hardware-poisoned pages Breno Leitao
2026-08-10 14:01 ` Pratyush Yadav
2026-08-10 14:42 ` Bradley Morgan
2026-08-10 14:59 ` Kiryl Shutsemau
2026-08-10 16:32 ` Mike Rapoport
2026-08-11 11:17   ` Breno Leitao
2026-08-11 11:36     ` Pratyush Yadav
2026-08-12 11:11       ` Breno Leitao [this message]
2026-08-11 13:34     ` Mike Rapoport
2026-08-11 14:21       ` Kiryl Shutsemau
2026-08-11 14:51         ` Rik van Riel

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=anxUnuML9UTepBTu@gmail.com \
    --to=leitao@debian.org \
    --cc=akpm@linux-foundation.org \
    --cc=baoquan.he@linux.dev \
    --cc=david@kernel.org \
    --cc=kas@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kexec@lists.infradead.org \
    --cc=liam@infradead.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=nao.horiguchi@gmail.com \
    --cc=pasha.tatashin@soleen.com \
    --cc=pratyush@kernel.org \
    --cc=riel@surriel.com \
    --cc=rmikey@meta.com \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.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