A task that gets a fatal signal during MADV_COLLAPSE keeps collapsing the rest of the range. Consequently, the exit of the task can be delayed for a while for a large range. Let's fix it by checking for a fatal signal before each PMD, simply breaking out of the loop. User space will never see the return value, so no need to return -EINTR. This has low urgency, as it only delays the exit of the task. No need to CC stable. Fixes: 7d8faaf15545 ("mm/madvise: introduce MADV_COLLAPSE sync hugepage collapse") Reported-by: Chris Mason Signed-off-by: David Hildenbrand (Arm) --- mm/khugepaged.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 091e4136ba037..0495fb1a9e31c 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -3372,6 +3373,9 @@ int madvise_collapse(struct vm_area_struct *vma, unsigned long start, for (addr = hstart; addr < hend; addr += HPAGE_PMD_SIZE) { enum scan_result result = SCAN_FAIL; + if (fatal_signal_pending(current)) + break; + if (mmap_unlocked) { cond_resched(); mmap_read_lock(mm); -- 2.56.1