History

HWPOISON: Add PR_MCE_KILL prctl to control early kill behaviour per process

This allows processes to override their early/late kill behaviour on hardware memory errors. Typically applications which are memory error aware is better of with early kill (see the error as soon as possible), all others with late kill (only see the error when the error is really impacting execution) There's a global sysctl, but this way an application can set its specific policy. We're using two bits, one to signify that the process stated its intention and that I also made the prctl future proof by enforcing the unused arguments are 0. The state is inherited to children. Note this makes us officially run out of process flags on 32bit, but the next patch can easily add another field. Manpage patch will be supplied separately.

Andi Kleen committed 17 years ago

Commit 4db96cf1 parent 6746aff3 files · +26 −0Browse files

Showing the changes to kernel/sys.c (1 of 3 files). Show all

Unified · Split

kernel/sys.c+22−0
@@ -1528,6 +1528,28 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, · 1527 unmodified lines
15281528 current->timer_slack_ns = arg2;
15291529 error = 0;
15301530 break;
1531+ case PR_MCE_KILL:
1532+ if (arg4 | arg5)
1533+ return -EINVAL;
1534+ switch (arg2) {
1535+ case 0:
1536+ if (arg3 != 0)
1537+ return -EINVAL;
1538+ current->flags &= ~PF_MCE_PROCESS;
1539+ break;
1540+ case 1:
1541+ current->flags |= PF_MCE_PROCESS;
1542+ if (arg3 != 0)
1543+ current->flags |= PF_MCE_EARLY;
1544+ else
1545+ current->flags &= ~PF_MCE_EARLY;
1546+ break;
1547+ default:
1548+ return -EINVAL;
1549+ }
1550+ error = 0;
1551+ break;
1552+
15311553 default:
15321554 error = -EINVAL;
15331555 break;