The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Kiryl Shutsemau <kas@kernel.org>
To: Breno Leitao <leitao@debian.org>
Cc: 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>,
	 Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	 Michal Hocko <mhocko@suse.com>,
	Baoquan He <baoquan.he@linux.dev>,
	 Pasha Tatashin <pasha.tatashin@soleen.com>,
	Pratyush Yadav <pratyush@kernel.org>,
	 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
Subject: Re: [PATCH v3] kexec: keep the next kernel off hardware-poisoned pages
Date: Tue, 4 Aug 2026 15:36:47 +0100	[thread overview]
Message-ID: <anH1JdVtiM9VoXMH@thinkstation> (raw)
In-Reply-To: <20260803-kexec_posioned-v3-1-83aa6ede0351@debian.org>

On Mon, Aug 03, 2026 at 05:41:10AM -0700, Breno Leitao wrote:
> @@ -504,6 +505,15 @@ static int locate_mem_hole_top_down(unsigned long start, unsigned long end,
>  			continue;
>  		}
>  
> +		poison = range_last_hwpoison(temp_start, kbuf->memsz);
> +		if (poison != PHYS_ADDR_MAX) {
> +			/* we hit a poisoned page */
> +			if (poison < kbuf->memsz)
> +				return 0;
> +			temp_start = poison - kbuf->memsz;
> +			continue;
> +		}
> +

Hm. Don't we want range_first_hwpoison() for top-down walk? Otherwise
the end of range would land on poison.

>  		/* We found a suitable memory range */
>  		break;
>  	} while (1);

...

> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index a8b03e2920ba8..ef0e989c25d93 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -96,6 +96,31 @@ void num_poisoned_pages_sub(unsigned long pfn, long i)
>  		memblk_nr_poison_sub(pfn, i);
>  }
>  
> +/*
> + * Return the address of the last hardware-poisoned online page in
> + * [start, start + size), or PHYS_ADDR_MAX if the range is clean.
> + */
> +phys_addr_t range_last_hwpoison(phys_addr_t start, unsigned long size)
> +{
> +	phys_addr_t poison = PHYS_ADDR_MAX;
> +	unsigned long pfn, end_pfn;
> +
> +	if (!size || !atomic_long_read(&num_poisoned_pages))
> +		return poison;
> +
> +	end_pfn = PHYS_PFN(start + size - 1);
> +	for (pfn = PHYS_PFN(start); pfn <= end_pfn; pfn++) {
> +		struct page *page = pfn_to_online_page(pfn);
> +
> +		if (page && PageHWPoison(page))
> +			poison = PFN_PHYS(pfn);

Oh... I think it will not work for hugetlb pages. It will give
false-negative.

We cannot just set the bit hugetlb pages as we don't always have memory
for tail page -- look at HugeTLB Vmemmap Optimization (HVO). Hugetlb
uses a trick to encode poison page. See code that uses _hugetlb_hwpoison
in struct folio.

I think we need special-case hugetlb here. (One more reminder why I hate
HugeTLB).

> +
> +		cond_resched();
> +	}
> +
> +	return poison;
> +}
> +
>  /**
>   * MF_ATTR_RO - Create sysfs entry for each memory failure statistics.
>   * @_name: name of the file in the per NUMA sysfs directory.
> 
-- 
  Kiryl Shutsemau / Kirill A. Shutemov

  reply	other threads:[~2026-08-04 14:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03 12:41 [PATCH v3] kexec: keep the next kernel off hardware-poisoned pages Breno Leitao
2026-08-04 14:36 ` Kiryl Shutsemau [this message]
2026-08-06 14:59   ` Breno Leitao

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=anH1JdVtiM9VoXMH@thinkstation \
    --to=kas@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=baoquan.he@linux.dev \
    --cc=david@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kexec@lists.infradead.org \
    --cc=leitao@debian.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