This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: [PATCH]Kprobes: fix kprobes reentrancy
- From: Chuck Ebbert <76306 dot 1226 at compuserve dot com>
- To: "Keshavamurthy, Anil S" <anil dot s dot keshavamurthy at intel dot com>
- Cc: Systemtap <systemtap at sources dot redhat dot com>, Prasanna S Panchamukhi <prasanna at in dot ibm dot com>, Jim Keniston <jkenisto at us dot ibm dot com>, Ananth N Mavinakayanahalli <ananth at in dot ibm dot com>, akpm at osdl dot org
- Date: Tue, 12 Dec 2006 18:49:56 -0500
- Subject: Re: [PATCH]Kprobes: fix kprobes reentrancy
In-Reply-To: <20061212222517.GA17627@bambi.jf.intel.com>
On Tue, 12 Dec 2006 14:25:17 -0800, Keshavamurthy, Anil S wrote:
> --- 2.6.19-git19.orig/include/linux/kprobes.h
> +++ 2.6.19-git19/include/linux/kprobes.h
> @@ -188,6 +188,28 @@ static inline struct kprobe_ctlblk *get_
> return (&__get_cpu_var(kprobe_ctlblk));
> }
>
> +/* Per-CPU area for storing the previous kprobe information
> + * in case of reentrancy.
> + */
> +#define PREV_KPROBE_SIZE 4
> +DECLARE_PER_CPU(atomic_t, prev_kprobe_index);
> +DECLARE_PER_CPU(struct prev_kprobe [PREV_KPROBE_SIZE], prev_kprobe_blk);
> +
> +static inline struct prev_kprobe *get_prev_kprobe(void)
> +{
> + unsigned int i;
> + i = atomic_add_return(1, &(__get_cpu_var(prev_kprobe_index)));
> + BUG_ON(i > PREV_KPROBE_SIZE);
Can't you make it fail gracefully instead of going BUG() if this happens
(i.e. skip the kprobe or something?)
> + return (&__get_cpu_var(prev_kprobe_blk)[i-1]);
> +}
> +
> +static inline struct prev_kprobe *restore_prev_kprobe(void)
> +{
> + unsigned int i;
> + i = atomic_sub_return(1, &(__get_cpu_var(prev_kprobe_index)));
And this needs a BUG_ON() or Bad Things could happen on underflow.
> + return (&__get_cpu_var(prev_kprobe_blk)[i]);
> +}
> +
--
MBTI: IXTP