diff options
| author | David Hildenbrand (Arm) <david@kernel.org> | 2026-10-30 23:29:13 +0100 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-11-09 22:44:28 -0800 |
| commit | cd5f5bf781b4ead6a6571818d5613ea2ed0145f3 (patch) | |
| tree | 13ae8ab1145a4a30aefb2e9655511f50da4369ae /tools/perf/scripts/python | |
| parent | fc2c19648d681cc5fb00efa938b78460c2e5b44d (diff) | |
mm/memory-failure: fix folio refcount leak and min_order_for_split() locking
hwpoison code can end up calling min_order_for_split() without holding the
folio lock. There isn't really something that would prevent concurrent
truncation. Consequently folio->mapping can get set to NULL after
checking for "!folio->mapping", and if the compiler reloads
folio->mapping, mapping_min_folio_order() would try to dereference NULL.
While very unlikely to happen in practice, let's just enforce that
min_order_for_split() is called with the folio lock held. We can
significantly cleanup the calling hwpoison code, and just get rid of
try_to_split_thp_page() to hold the folio lock for a bit longer.
Just work on folios now, which further cleans up the code. We just have
to be careful about doing the page_folio() after splitting, which we have
to do already either way. Do not change the way we split for now, this
needs more thought and should be done separately.
Cleaning this up we fix another issue: in soft_offline_in_use_page(), we
would currently have leaked a folio reference.
In min_order_for_split(), document and assert that we need the folio lock.
Drop the questionable VM_BUG_ON_PAGE(!page_count(p), p) check entirely.
While updating the comment in soft_offline_in_use_page(), just drop the
"NOTE" part that does not add any value to current code.
The folio->mapping problem was identified by Sashiko, and Li Youhong
reported it by sending a proposal fix.
This likely does not really warrant CCing stable, but I expect little
conflicts when doing the backport, so let's just CC stable because of the
refcount leak.
Link: https://lore.kernel.org/20261030-try_to_split_thp_page-v2-1-c957c9b42eab@kernel.org
Fixes: 689b8986776c ("mm/memory-failure: improve large block size folio handling")
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Li Youhong <liyouhong@kylinos.cn>
Closes: https://lore.kernel.org/r/20260804035828.2684059-1-dayou5941@163.com
Acked-by: Usama Arif <usama.arif@linux.dev>
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Acked-by: Miaohe Lin <linmiaohe@huawei.com>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Wei Yang <richard.weiyang@gmail.com>
Cc: Nico Pache <nico.pache@linux.dev>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Tal Zussman <tz2294@columbia.edu>
Cc: <stable@vger.kernel.org>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
