Re: [PATCH v2] mm/highmem: refuse to copy hwpoisoned folios in the !copy_mc fallbacks

From: Huang, Ying

Date: Thu Oct 29 2026 - 07:12:37 EST


Yuanhe Shu <xiangzao@xxxxxxxxxxxxxxxxx> writes:

> The !copy_mc fallbacks of copy_mc_user_highpage() and
> copy_mc_highpage() return 0 after a plain copy. With PG_hwpoison
> set while the data stays readable, there is no fault to recover
> from: the copy completes, the destination folio carries no poison
> marker, and the poison is consumed silently.

IIUC, in all cases except debugging, reading poisoned memory will cause
an MCE (x86), an SEA (arm), or similar. Otherwise, copy_mc on x86
would not work either.

If so, we should only check is_page_hwpoison() before copying.

> Check the source page with is_page_hwpoison() in both fallbacks,
> before and after the copy, and return PAGE_SIZE, the
> not-copied-bytes convention of the real copy_mc paths, so the
> callers take their existing error paths. On archs with copy_mc
> this code does not compile.
>
> Measured on arm64, where the fallback code compiles (10 rounds
> each): COW copy throughput 1043.67 MB/s before and 1043.26 MB/s
> after the patch, fork latency 348 vs 359 us, forced migration 57396
> vs 57654 MB/s - all within run-to-run noise.

Could you implement a micro-benchmark in kernel to test your copy_mc
functions?

[snip]

---
Best Regards,
Huang, Ying