From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25873 invoked by alias); 21 Nov 2006 06:57:53 -0000 Received: (qmail 25862 invoked by uid 22791); 21 Nov 2006 06:57:53 -0000 X-Spam-Status: No, hits=0.3 required=5.0 tests=AWL,BAYES_00,TW_DJ,TW_JP,UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org Received: from mail9.hitachi.co.jp (HELO mail9.hitachi.co.jp) (133.145.228.44) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 21 Nov 2006 06:57:46 +0000 Received: from mlsv4.hitachi.co.jp (unknown [133.144.234.166]) by mail9.hitachi.co.jp (Postfix) with ESMTP id EB1A937CB4 for ; Tue, 21 Nov 2006 15:57:43 +0900 (JST) Received: from mfilter-s3.hitachi.co.jp by mlsv4.hitachi.co.jp (8.12.10/8.12.10) id kAL6vicj023790; Tue, 21 Nov 2006 15:57:44 +0900 Received: from vshuts4.hitachi.co.jp (unverified) by mfilter-s3.hitachi.co.jp (Content Technologies SMTPRS 4.3.17) with SMTP id ; Tue, 21 Nov 2006 15:57:43 +0900 Received: from hsdlgw92.sdl.hitachi.co.jp ([133.144.7.20]) by vshuts4.hitachi.co.jp with SMTP id M2006112115574131796 ; Tue, 21 Nov 2006 15:57:42 +0900 Received: from vgate2.sdl.hitachi.co.jp by hsdlgw92.sdl.hitachi.co.jp (8.13.1/3.7W06092911) id kAL6vaa2008037; Tue, 21 Nov 2006 15:57:41 +0900 Received: from maila.sdl.hitachi.co.jp ([133.144.14.196]) by vgate2.sdl.hitachi.co.jp (SAVSMTP 3.1.1.32) with SMTP id M2006112115574122090 ; Tue, 21 Nov 2006 15:57:41 +0900 Received: from [127.0.0.1] ([10.232.9.172]) by maila.sdl.hitachi.co.jp (8.13.1/3.7W04031011) with ESMTP id kAL6vecI022806; Tue, 21 Nov 2006 15:57:41 +0900 Message-ID: <4562A364.3020105@hitachi.com> Date: Tue, 21 Nov 2006 06:59:00 -0000 From: Masami Hiramatsu Organization: Systems Development Lab., Hitachi, Ltd., Japan User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) MIME-Version: 1.0 To: Masami Hiramatsu Cc: "Keshavamurthy, Anil S" , Ingo Molnar , SystemTAP , Ananth N Mavinakayanahalli , Prasanna S Panchamukhi , Satoshi Oshima , Hideo Aoki , Yumiko Sugita , Jim Keniston , Martin Bligh , Greg Kroah-Hartman Subject: [RFC][PATCH 4/4][kprobe](djprobe) delayed invoking commit_kprobes() References: <4562A150.2030606@hitachi.com> In-Reply-To: <4562A150.2030606@hitachi.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2006-q4/txt/msg00487.txt.bz2 Hi, This patch invokes commit_kprobes() function from a worker. This worker is scheduled automatically by register/ unregister_kprobe() functions (if registered/unregistered kprobes can be optimized) and is executed in 0.1 second. If the worker fails freezing processes, it will try again after 0.1 second. And if it fails 10 times, it will stop trying. Thanks, -- Masami HIRAMATSU Linux Technology Center Hitachi, Ltd., Systems Development Laboratory E-mail: masami.hiramatsu.pt@hitachi.com --- kernel/kprobes.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) Index: linux-2.6.19-rc5-mm2/kernel/kprobes.c =================================================================== --- linux-2.6.19-rc5-mm2.orig/kernel/kprobes.c +++ linux-2.6.19-rc5-mm2/kernel/kprobes.c @@ -600,6 +600,15 @@ static int __kprobes __register_kprobe_c #ifdef ARCH_SUPPORTS_DJPROBES static LIST_HEAD(registering_list); static LIST_HEAD(unregistering_list); +static void commit_work_fn(void * data); +static DECLARE_WORK(commit_work, commit_work_fn, 0); +#define KPROBE_COMMIT_DELAY (HZ/10) +#define MAX_COMMIT_RETRY 10 + +static __always_inline void kick_delayed_commit(void) +{ + schedule_delayed_work(&commit_work, KPROBE_COMMIT_DELAY); +} /* Switch to stub buffer : this handler is invoked before inserting a jump */ static int __kprobes djprobe_pre_handler(struct kprobe *kp, @@ -667,6 +676,7 @@ static int __kprobes register_djprobe(st goto out; } list_add(&djpi->list, ®istering_list); + kick_delayed_commit(); register_aggr_kprobe(&djpi->kp, p); out: @@ -694,6 +704,7 @@ static void __kprobes unregister_djprobe struct djprobe_instance *djpi; djpi = container_of(p, struct djprobe_instance, kp); list_add(&djpi->list, &unregistering_list); + kick_delayed_commit(); } /* Called with kprobe_mutex held */ @@ -733,16 +744,27 @@ static int __kprobes __commit_djprobes(v return 0; } +static atomic_t try_count = ATOMIC_INIT(0); /* * Commit to optimize kprobes and remove optimized kprobes. */ int __kprobes commit_kprobes(void) { - int ret = 0; + atomic_set(&try_count, 0); + commit_work_fn(NULL); + return 0; +} + +static void commit_work_fn(void * data) +{ + if (atomic_inc_return(&try_count) > MAX_COMMIT_RETRY) return; mutex_lock(&kprobe_mutex); - ret = __commit_djprobes(); + if (__commit_djprobes() == -EAGAIN) { + kick_delayed_commit(); /* try again */ + } else { + atomic_set(&try_count, 0); + } mutex_unlock(&kprobe_mutex); - return ret; } #else /* ARCH_SUPPORTS_DJPROBES */