On Mon, Jun 30, 2014 at 01:36:06PM -0400, Naoya Horiguchi wrote: > > The patch below does not apply to the 3.4-stable tree. > > If someone wants it applied there, or to any other stable or longterm > > tree, then please email the backport, including the original git commit > > id to <stable@xxxxxxxxxxxxxxx>. > > Yes, we have a conflict when we try to apply on stable-3.4. This is > because the patch contains anon_vma_interval_tree_foreach() and > vma_interval_tree_foreach() in the diff context, but these macros were > introduced at 3.7, so we can make it applicable by simply changing > the context lines to the older context lines. > > Here is the backport patch below, could you try this? > # This patch depends on commit 74614de17db6 "mm/memory-failure.c: don't > # let collect_procs() skip over processes for MF_ACTION_REQUIRED" > > Thanks, > Naoya Horiguchi > --- > From: Naoya Horiguchi <n-horiguchi@xxxxxxxxxxxxx> > Date: Mon, 30 Jun 2014 12:45:07 -0400 > Subject: [PATCH] mm/memory-failure.c: support use of a dedicated thread to > handle SIGBUS(BUS_MCEERR_AO) > > commit 3ba08129e38437561df44c36b7ea9081185d5333 upstream. > > Currently memory error handler handles action optional errors in the > deferred manner by default. And if a recovery aware application wants > to handle it immediately, it can do it by setting PF_MCE_EARLY flag. > However, such signal can be sent only to the main thread, so it's > problematic if the application wants to have a dedicated thread to > handler such signals. > > So this patch adds dedicated thread support to memory error handler. We > have PF_MCE_EARLY flags for each thread separately, so with this patch > AO signal is sent to the thread with PF_MCE_EARLY flag set, not the main > thread. If you want to implement a dedicated thread, you call prctl() > to set PF_MCE_EARLY on the thread. > > Memory error handler collects processes to be killed, so this patch lets > it check PF_MCE_EARLY flag on each thread in the collecting routines. > > No behavioral change for all non-early kill cases. > > Tony said: > > : The old behavior was crazy - someone with a multithreaded process might > : well expect that if they call prctl(PF_MCE_EARLY) in just one thread, then > : that thread would see the SIGBUS with si_code = BUS_MCEERR_A0 - even if > : that thread wasn't the main thread for the process. > > [n-horiguchi@xxxxxxxxxxxxx: resolved conflict for stable] > [akpm@xxxxxxxxxxxxxxxxxxxx: coding-style fixes] > Signed-off-by: Naoya Horiguchi <n-horiguchi@xxxxxxxxxxxxx> > Reviewed-by: Tony Luck <tony.luck@xxxxxxxxx> > Cc: Kamil Iskra <iskra@xxxxxxxxxxx> > Cc: Andi Kleen <andi@xxxxxxxxxxxxxx> > Cc: Borislav Petkov <bp@xxxxxxx> > Cc: Chen Gong <gong.chen@xxxxxxxxxxxxxxxxxx> > Cc: <stable@xxxxxxxxxxxxxxx> [3.2+] > Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> > Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> > --- > Documentation/vm/hwpoison.txt | 5 ++++ > mm/memory-failure.c | 55 +++++++++++++++++++++++++++++++++---------- > 2 files changed, 48 insertions(+), 12 deletions(-) > > diff --git a/Documentation/vm/hwpoison.txt b/Documentation/vm/hwpoison.txt > index 550068466605..6ae89a9edf2a 100644 > --- a/Documentation/vm/hwpoison.txt > +++ b/Documentation/vm/hwpoison.txt > @@ -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(PR_MCE_KILL_EARLY) on the designated thread. Otherwise, > + the SIGBUS is sent to the main thread. > + > PR_MCE_KILL_GET > return current mode > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index e88db79be1f0..ebe18360cf58 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -382,15 +382,44 @@ static void kill_procs(struct list_head *to_kill, int forcekill, int trapno, > } > } > > -static int task_early_kill(struct task_struct *tsk, int force_early) > +/* > + * Find a dedicated thread which is supposed to handle SIGBUS(BUS_MCEERR_AO) > + * on behalf of the thread group. Return task_struct of the (first found) > + * dedicated thread if found, and return NULL otherwise. > + * > + * We already hold read_lock(&tasklist_lock) in the caller, so we don't > + * have to call rcu_read_lock/unlock() in this function. > + */ > +static struct task_struct *find_early_kill_thread(struct task_struct *tsk) > { > + struct task_struct *t; > + > + for_each_thread(tsk, t) > + if ((t->flags & PF_MCE_PROCESS) && (t->flags & PF_MCE_EARLY)) > + return t; 3.4-stable does not have for_each_thread() so this will not build properly :( -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html