]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
mm: memory-hotplug: check folio ref count first in do_migrate_range
authorMa Wupeng <mawupeng1@huawei.com>
Mon, 17 Feb 2025 01:43:28 +0000 (09:43 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Mar 2025 12:02:00 +0000 (13:02 +0100)
commit2e66d699417d3d95145fe18278dec20620e76364
tree8b6900bbda48c164e284d43fe0943234ae9615f9
parent576a2f4c437c19bec7d05d05b5990f178d2b0f40
mm: memory-hotplug: check folio ref count first in do_migrate_range

commit 773b9a6aa6d38894b95088e3ed6f8a701d9f50fd upstream.

If a folio has an increased reference count, folio_try_get() will acquire
it, perform necessary operations, and then release it.  In the case of a
poisoned folio without an elevated reference count (which is unlikely for
memory-failure), folio_try_get() will simply bypass it.

Therefore, relocate the folio_try_get() function, responsible for checking
and acquiring this reference count at first.

Link: https://lkml.kernel.org/r/20250217014329.3610326-3-mawupeng1@huawei.com
Signed-off-by: Ma Wupeng <mawupeng1@huawei.com>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Miaohe Lin <linmiaohe@huawei.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
mm/memory_hotplug.c