Re: [PATCH] mm/memory-failure.c: support dedicated thread to handle SIGBUS(BUS_MCEERR_AO) thread

From: Tony Luck
Date: Wed May 28 2014 - 18:00:20 EST


On Wed, May 28, 2014 at 11:47 AM, Naoya Horiguchi
<n-horiguchi@xxxxxxxxxxxxx> wrote:
> Could you take a look?

It looks good - and should be a workable API for
application writers to use.

> @@ -84,6 +84,11 @@ PR_MCE_KILL
> PR_MCE_KILL_EARLY: Early kill
> PR_MCE_KILL_LATE: Late kill
> PR_MCE_KILL_DEFAULT: Use system global default
> + Note that if you want to have a dedicated thread which handles
> + the SIGBUS(BUS_MCEERR_AO) on behalf of the process, you should
> + call prctl() on the thread. Otherwise, the SIGBUS is sent to
> + the main thread.

Perhaps be more explicit here that the user should call
prctl(PR_MCE_KILL_EARLY) on the designated thread
to get this behavior? The user could also mark more than
one thread in this way - in which case the kernel will pick
the first one it sees (is that oldest, or newest?) that is marked.
Not sure if this would ever be useful unless you want to pass
responsibility around in an application that is dynamically
creating and removing threads.

> + if (t->flags & PF_MCE_PROCESS && t->flags & PF_MCE_EARLY)

This is correct - but made me twitch to add extra brackets:

if ((t->flags & PF_MCE_PROCESS) && (t->flags & PF_MCE_EARLY))

or
if ((t->flags & (PF_MCE_PROCESS|PF_MCE_EARLY)) ==
PF_MCE_PROCESS|PF_MCE_EARLY)

[oops, no ... that's too long and no clearer]

-Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/