public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <hiramatu@sdl.hitachi.co.jp>
To: systemtap@sources.redhat.com
Cc: Masami Hiramatsu <hiramatu@sdl.hitachi.co.jp>,
	Satoshi Oshima <soshima@redhat.com>,
	Yumiko Sugita <sugita@sdl.hitachi.co.jp>,
	Hideo Aoki <haoki@redhat.com>
Subject: Re: [Fwd: [RFC][PATCH 3/3]Djprobe (Direct Jump Probe) for 2.6.14-rc5-mm1]
Date: Fri, 04 Nov 2005 13:29:00 -0000	[thread overview]
Message-ID: <436B624A.8000108@sdl.hitachi.co.jp> (raw)
In-Reply-To: <43681C3B.6000605@sdl.hitachi.co.jp>

Hi,

Masami Hiramatsu wrote:
> +
> +static DEFINE_SPINLOCK(djprobe_handler_lock);
> +
> +/* djprobe handler : switch to a bypass code */
> +int __kprobes djprobe_pre_handler(struct kprobe * kp, struct pt_regs * regs)
> +{
> +	struct djprobe_instance *djpi =
> +		container_of(kp,struct djprobe_instance, kp);
> +	kprobe_opcode_t *stub = djpi->stub.insn;
> +
> +	spin_lock(&djprobe_handler_lock);
> +	if (DJPI_EMPTY(djpi)) {
> +		kp->ainsn.insn[0] = kp->opcode;
> +		return 0;
> +	} else {
> +		regs->eip = (unsigned long)stub;
> +		regs->eflags |= TF_MASK;
> +		regs->eflags &= ~IF_MASK;
> +		kp->ainsn.insn[0] = RETURN_INSTRUCTION;
> +		return 1; /* already prepared */
> +	}
> +}
> +
> +void __kprobes djprobe_post_handler(struct kprobe * kp, struct pt_regs * regs,
> +				    unsigned long flags)
> +{
> +	spin_unlock(&djprobe_handler_lock);
> +}

I learned from kretprobe that I can remove this spinlock and
a trick of instruction buffer. Here is a new pseudo-program.

djprobe_pre_handler()
{
	if (!DJPI_EMPTY(djpi)) {
		regs->eip = (unsigned long)djpi->stub.insn;
		reset_current_kprobe();
		preempt_enable_no_resched();
		return 1;
	}
	return 0;
}

I will send fixed patches again. Please review it.

-- 
Masami HIRAMATSU
2nd Research Dept.
Hitachi, Ltd., Systems Development Laboratory
E-mail: hiramatu@sdl.hitachi.co.jp

  reply	other threads:[~2005-11-04 13:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-02  1:14 [Fwd: [RFC][PATCH 0/3]Djprobe " Masami Hiramatsu
2005-11-02  1:51 ` [Fwd: [RFC][PATCH 1/3]Djprobe " Masami Hiramatsu
2005-11-02  1:52   ` [Fwd: [RFC][PATCH 2/3]Djprobe " Masami Hiramatsu
2005-11-02  1:54     ` [Fwd: [RFC][PATCH 3/3]Djprobe " Masami Hiramatsu
2005-11-04 13:29       ` Masami Hiramatsu [this message]
2005-11-08 13:26         ` [Patch 1/3][Djprobe] Djprobe update for linux-2.6.14-mm1 Masami Hiramatsu
2005-11-08 13:26         ` [Patch 3/3][Djprobe] " Masami Hiramatsu
2005-11-08 13:26         ` [Patch 2/3][Djprobe] " Masami Hiramatsu
2005-11-08 13:26         ` [Patch 0/3][Djprobe] " Masami Hiramatsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=436B624A.8000108@sdl.hitachi.co.jp \
    --to=hiramatu@sdl.hitachi.co.jp \
    --cc=haoki@redhat.com \
    --cc=soshima@redhat.com \
    --cc=sugita@sdl.hitachi.co.jp \
    --cc=systemtap@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).