Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: "Garg, Shivank" <shivankg@amd.com>,
	"tejavojjala@google.com" <tejavojjala@google.com>,
	"Rao, Bharata Bhasker" <bharata@amd.com>,
	"rppt@kernel.org" <rppt@kernel.org>,
	"david.laight.linux@gmail.com" <david.laight.linux@gmail.com>,
	"ankur.a.arora@oracle.com" <ankur.a.arora@oracle.com>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"vbabka@kernel.org" <vbabka@kernel.org>,
	"ying.huang@linux.alibaba.com" <ying.huang@linux.alibaba.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"surenb@google.com" <surenb@google.com>,
	"sashiko-reviews@lists.linux.dev"
	<sashiko-reviews@lists.linux.dev>,
	"xiangzao@linux.alibaba.com" <xiangzao@linux.alibaba.com>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"nhuhuan@google.com" <nhuhuan@google.com>,
	"Salunke, Hrushikesh" <Hrushikesh.Salunke@amd.com>,
	"tglx@kernel.org" <tglx@kernel.org>,
	"liam@infradead.org" <liam@infradead.org>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"mhocko@suse.com" <mhocko@suse.com>,
	"bp@alien8.de" <bp@alien8.de>, "ljs@kernel.org" <ljs@kernel.org>,
	"rientjes@google.com" <rientjes@google.com>,
	"pfalcato@suse.de" <pfalcato@suse.de>,
	"torvalds@linuxfoundation.org" <torvalds@linuxfoundation.org>,
	"kaitao.cheng@linux.dev" <kaitao.cheng@linux.dev>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
	"x86@kernel.org" <x86@kernel.org>
Subject: Re: [PATCH v3] mm: introduce copy_mc_highpages() and batch copy in folio_mc_copy()
Date: Thu, 19 Nov 2026 18:27:41 +0100	[thread overview]
Message-ID: <80849862-19d6-4497-902d-8acee4e2a3a8@kernel.org> (raw)
In-Reply-To: <2dd5ed03f167563d8b37a4e1ae4b17d2d8aa31a2.camel@amd.com>

On 11/17/26 06:27, Garg, Shivank wrote:
> On Sat, 2026-11-14 at 17:12 +0000, sashiko-bot@kernel.org wrote:
>> Thank you for your contribution! Sashiko AI review found no new issues
>> in this patch, but noticed 1 related pre-existing issue it does not
>> introduce:
>> - [Critical] mm: missing hwpoison check in copy_mc_user_highpage() and
>>   copy_mc_highpage() [1]
>> --
>>
>> commit fae95970ccf2607d670f06862e40d3ba9313200a
>> Author: Shivank Garg <shivankg@amd.com>
>>
>> mm: introduce copy_mc_highpages() and batch copy in folio_mc_copy()
>>
>> This commit introduces copy_mc_highpages() to copy page ranges with a
>> single copy_mc_to_kernel() call when possible and updates folio_mc_copy()
>> to use it.
>>
>>> diff --git a/include/linux/highmem.h b/include/linux/highmem.h
>>> index d7aac9de1c8a4..a79e9d68359c8 100644
>>> --- a/include/linux/highmem.h
>>> +++ b/include/linux/highmem.h
>>> @@ -484,6 +484,57 @@ static inline int copy_mc_highpage(struct page *to, struct page *from)
>>>  }
>>>  #endif
>>>  
>>> +/**
>>> + * copy_mc_highpages() - copy a page range with machine check handling
>>> + * @to: first destination page
>>> + * @from: first source page
>>> + * @nr_pages: number of pages
>>> + *
>>> + * Range variant of copy_mc_highpage(). On a machine check, the poisoned
>>> + * source page is queued for memory_failure().
>>> + *
>>> + * Context: Process context. May sleep.
>>> + * Return: 0 on success, -EHWPOISON if a machine check was handled.
>>> + */
>>> +static inline int copy_mc_highpages(struct page *to, struct page *from,
>>> +		unsigned long nr_pages)
>>> +{
>>> +	unsigned long len = nr_pages << PAGE_SHIFT;
>>> +	unsigned long i, ret;
>>> +
>>> +	might_sleep();
>>> +
>>> +	/*
>>> +	 * When copying we want to operate on the largest extent possible to
>>> +	 * allow for architecture specific extent based optimizations.
>>> +	 *
>>> +	 * copy_mc_to_kernel() does not call cond_resched(). That is fine on
>>> +	 * preemptible kernels, where the scheduler can preempt the copy at
>>> +	 * any point, so copy the whole range at once if copy_mc_to_kernel() is
>>> +	 * available and the pages are in the linear map. Otherwise, copy one
>>> +	 * page at a time and reschedule in between.
>>> +	 */
>>> +	if (IS_ENABLED(CONFIG_ARCH_HAS_COPY_MC) && IS_ENABLED(CONFIG_PREEMPTION) &&
>>> +	    !IS_ENABLED(CONFIG_HIGHMEM)) {
>>> +		ret = copy_mc_to_kernel(page_address(to), page_address(from), len);
>>> +		if (ret) {
>>> +			memory_failure_queue(page_to_pfn(from) +
>>> +					     ((len - ret) >> PAGE_SHIFT), 0);
>>> +			return -EHWPOISON;
>>> +		}
>>> +		for (i = 0; i < nr_pages; i++)
>>> +			kmsan_copy_page_meta(to + i, from + i);
>>> +		return 0;
>>> +	}
>>> +
>>> +	for (i = 0; i < nr_pages; i++) {
>>> +		cond_resched();
>>> +		if (copy_mc_highpage(to + i, from + i))
>>> +			return -EHWPOISON;
>>> +	}
>>
>> [Severity: Critical]
>> This problem wasn't introduced by this patch, but can copy_mc_highpage()
>> and copy_mc_user_highpage() (as well as the new copy_mc_highpages() fast
>> path) return 0 when the source page or its containing folio is already
>> marked PG_hwpoison [1]?
> 
> 
> Yes, the patch keeps the existing behavior. PG_hwpoison marked pages are copied without errors but Real poison issue returns non-zero and folio_mc_copy() fails! Should we consider this as blocker?
> 
> Yuanhe's patch adds the check to copy !copy_mc branch but copy_mc branch can still copy such a page. [1]
> 
> Since it's pre-existing issue, I'd prefer to keep it out of this patch.

Ack.

-- 
Cheers,

David


  reply	other threads:[~2026-11-19 17:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 17:09 [PATCH v3] mm: introduce copy_mc_highpages() and batch copy in folio_mc_copy() Shivank Garg
2026-11-14 17:12 ` sashiko-bot
2026-11-17  5:27   ` Garg, Shivank
2026-11-19 17:27     ` David Hildenbrand (Arm) [this message]
2026-11-22  7:30 ` Andrew Morton
2026-11-22 17:13   ` Garg, Shivank

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=80849862-19d6-4497-902d-8acee4e2a3a8@kernel.org \
    --to=david@kernel.org \
    --cc=Hrushikesh.Salunke@amd.com \
    --cc=akpm@linux-foundation.org \
    --cc=ankur.a.arora@oracle.com \
    --cc=bharata@amd.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=david.laight.linux@gmail.com \
    --cc=hpa@zytor.com \
    --cc=kaitao.cheng@linux.dev \
    --cc=liam@infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=mingo@redhat.com \
    --cc=nhuhuan@google.com \
    --cc=peterz@infradead.org \
    --cc=pfalcato@suse.de \
    --cc=rientjes@google.com \
    --cc=rppt@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=shivankg@amd.com \
    --cc=surenb@google.com \
    --cc=tejavojjala@google.com \
    --cc=tglx@kernel.org \
    --cc=torvalds@linuxfoundation.org \
    --cc=vbabka@kernel.org \
    --cc=x86@kernel.org \
    --cc=xiangzao@linux.alibaba.com \
    --cc=ying.huang@linux.alibaba.com \
    /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