Skip to content

Commit 4e018b4

Browse files
nhoriguchitorvalds
authored andcommitted
mm/memory-failure: prioritize prctl(PR_MCE_KILL) over vm.memory_failure_early_kill
Patch series "hwpoison: fixes signaling on memory error" This is a small patchset to solve issues in memory error handler to send SIGBUS to proper process/thread as expected in configuration. Please see descriptions in individual patches for more details. This patch (of 2): Early-kill policy is controlled from two types of settings, one is per-process setting prctl(PR_MCE_KILL) and the other is system-wide setting vm.memory_failure_early_kill. Users expect per-process setting to override system-wide setting as many other settings do, but early-kill setting doesn't work as such. For example, if a system configures vm.memory_failure_early_kill to 1 (enabled), a process receives SIGBUS even if it's configured to explicitly disable PF_MCE_KILL by prctl(). That's not desirable for applications with their own policies. This patch is suggesting to change the priority of these two types of settings, by checking sysctl_memory_failure_early_kill only when a given process has the default kill policy. Note that this patch is solving a thread choice issue too. Originally, collect_procs() always chooses the main thread when vm.memory_failure_early_kill is 1, even if the process has a dedicated thread for memory error handling. SIGBUS should be sent to the dedicated thread if early-kill is enabled via vm.memory_failure_early_kill as we are doing for PR_MCE_KILL_EARLY processes. Signed-off-by: Naoya Horiguchi <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Cc: Tony Luck <[email protected]> Cc: Pankaj Gupta <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 623f6dc commit 4e018b4

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

mm/memory-failure.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,15 @@ static struct task_struct *find_early_kill_thread(struct task_struct *tsk)
402402
{
403403
struct task_struct *t;
404404

405-
for_each_thread(tsk, t)
406-
if ((t->flags & PF_MCE_PROCESS) && (t->flags & PF_MCE_EARLY))
407-
return t;
405+
for_each_thread(tsk, t) {
406+
if (t->flags & PF_MCE_PROCESS) {
407+
if (t->flags & PF_MCE_EARLY)
408+
return t;
409+
} else {
410+
if (sysctl_memory_failure_early_kill)
411+
return t;
412+
}
413+
}
408414
return NULL;
409415
}
410416

@@ -417,17 +423,11 @@ static struct task_struct *find_early_kill_thread(struct task_struct *tsk)
417423
static struct task_struct *task_early_kill(struct task_struct *tsk,
418424
int force_early)
419425
{
420-
struct task_struct *t;
421426
if (!tsk->mm)
422427
return NULL;
423428
if (force_early)
424429
return tsk;
425-
t = find_early_kill_thread(tsk);
426-
if (t)
427-
return t;
428-
if (sysctl_memory_failure_early_kill)
429-
return tsk;
430-
return NULL;
430+
return find_early_kill_thread(tsk);
431431
}
432432

433433
/*

0 commit comments

Comments
 (0)