From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754839Ab1JSV5e (ORCPT ); Wed, 19 Oct 2011 17:57:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12288 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752957Ab1JSV5d (ORCPT ); Wed, 19 Oct 2011 17:57:33 -0400 Date: Wed, 19 Oct 2011 23:52:26 +0200 From: Oleg Nesterov To: Srikar Dronamraju Cc: Peter Zijlstra , Ingo Molnar , Steven Rostedt , Linux-mm , Arnaldo Carvalho de Melo , Linus Torvalds , Jonathan Corbet , Masami Hiramatsu , Hugh Dickins , Christoph Hellwig , Ananth N Mavinakayanahalli , Thomas Gleixner , Andi Kleen , Andrew Morton , Jim Keniston , Roland McGrath , LKML Subject: [PATCH 9/X] uprobes: introduce UTASK_SSTEP_ACK state Message-ID: <20111019215226.GC16395@redhat.com> References: <20110920115938.25326.93059.sendpatchset@srdronam.in.ibm.com> <20111015190007.GA30243@redhat.com> <20111019215139.GA16395@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20111019215139.GA16395@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce the new state, UTASK_SSTEP_ACK. uprobe_post_notifier() sets this state like uprobe_bkpt_notifier() sets UTASK_BP_HIT. Change uprobe_notify_resume() to always do the post_xol() logic if state != UTASK_BP_HIT and WARN() if the utask->state is wrong. This makes the state transitions more explicit. The current code returns silently if, say, state == UTASK_RUNNING. But this must not happen, we should complain in this case. And, with the new state we know for sure that DIE_DEBUG was triggered. --- include/linux/uprobes.h | 3 ++- kernel/uprobes.c | 15 ++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/linux/uprobes.h b/include/linux/uprobes.h index a407d17..1591c7c 100644 --- a/include/linux/uprobes.h +++ b/include/linux/uprobes.h @@ -74,7 +74,8 @@ struct uprobe { enum uprobe_task_state { UTASK_RUNNING, UTASK_BP_HIT, - UTASK_SSTEP + UTASK_SSTEP, + UTASK_SSTEP_ACK, }; /* diff --git a/kernel/uprobes.c b/kernel/uprobes.c index 135b9a2..5fd72b8 100644 --- a/kernel/uprobes.c +++ b/kernel/uprobes.c @@ -1365,10 +1365,13 @@ void uprobe_notify_resume(struct pt_regs *regs) else /* Cannot Singlestep; re-execute the instruction. */ goto cleanup_ret; - } else if (utask->state == UTASK_SSTEP) { + } else { u = utask->active_uprobe; - post_xol(u, regs); /* TODO: check result? */ + if (utask->state == UTASK_SSTEP_ACK) + post_xol(u, regs); /* TODO: check result? */ + else + WARN_ON_ONCE(1); put_uprobe(u); utask->active_uprobe = NULL; @@ -1416,15 +1419,13 @@ int uprobe_bkpt_notifier(struct pt_regs *regs) */ int uprobe_post_notifier(struct pt_regs *regs) { - struct uprobe *uprobe; - struct uprobe_task *utask; + struct uprobe_task *utask = current->utask; - if (!current->mm || !current->utask || !current->utask->active_uprobe) + if (!current->mm || !utask || !utask->active_uprobe) /* task is currently not uprobed */ return 0; - utask = current->utask; - uprobe = utask->active_uprobe; + utask->state = UTASK_SSTEP_ACK; set_thread_flag(TIF_UPROBE); return 1; } -- 1.5.5.1