[PATCH] dbg: inject nosplit

From: Huang Ying
Date: Mon Sep 19 2022 - 21:37:53 EST


---
mm/migrate.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/mm/migrate.c b/mm/migrate.c
index 571d8c9fd5bc..d4ee76c285b2 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -57,6 +57,11 @@

#include "internal.h"

+static noinline bool error_inject_nosplit(void)
+{
+ return false;
+}
+
int isolate_movable_page(struct page *page, isolate_mode_t mode)
{
const struct movable_operations *mops;
@@ -1412,6 +1417,9 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page,
bool nosplit = (reason == MR_NUMA_MISPLACED);
bool no_subpage_counting = false;

+ if (error_inject_nosplit())
+ nosplit = true;
+
trace_mm_migrate_pages_start(mode, reason);

thp_subpage_migration:
--
2.35.1
----------------------------------------------------------

With the help of the above patch, the following bpftrace script can
inject the expected error,

--------------------ENOMEM THP + nosplit---------
kprobe:migrate_pages { @in_migrate_pages++; }
kretprobe:migrate_pages { @in_migrate_pages--; }
kprobe:should_fail_alloc_page / @in_migrate_pages > 0 && arg1 == 9 / {
override(1);
}
kprobe:error_inject_nosplit / @in_migrate_pages > 0 / {
override(1);
}
-------------------------------------------------

Although some hack patches are needed. This is still simpler than my
original hand-made error injection solution. So I will recommend
developers to use it in the error path testing in the future.

Best Regards,
Huang, Ying