]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm/madvise: use is_memory_failure() from madvise_do_behavior()
authorSeongJae Park <sj@kernel.org>
Wed, 12 Mar 2025 16:47:47 +0000 (09:47 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 18 Mar 2025 05:07:03 +0000 (22:07 -0700)
commit9ecd2f839b2596aaa510f20e18d496c2e3e0fa56
tree5b1a8c7e8ab7fcd9e2040f814bf354d48f39b1ad
parent15766485e4a51bec2dcce304c089a95550720033
mm/madvise: use is_memory_failure() from madvise_do_behavior()

Patch series "mm/madvise: cleanup requests validations and classifications".

Cleanup madvise entry level code for cleaner request validations and
classifications.

This patch (of 4):

To reduce redundant open-coded checks of CONFIG_MEMORY_FAILURE and
MADV_{HWPOISON,SOFT_OFFLINE} in madvise_[un]lock(), is_memory_failure() is
introduced.  madvise_do_behavior() is still doing the same open-coded
check, though.  Use is_memory_failure() instead.

To avoid build failure on !CONFIG_MEMORY_FAILURE case, implement an empty
madvise_inject_error() under the config.  Also move the definition of
is_memory_failure() inside #ifdef CONFIG_MEMORY_FAILURE clause for
madvise_inject_error() definition, to reduce duplicated ifdef clauses.

Link: https://lkml.kernel.org/r/20250312164750.59215-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20250312164750.59215-2-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Shakeel Butt <shakeel.butt@linux.dev>
Cc: David Hildenbrand <david@redhat.com>
Cc: Liam R. Howlett <howlett@gmail.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/madvise.c