public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
To: Masami Hiramatsu <hiramatu@sdl.hitachi.co.jp>
Cc: systemtap@sources.redhat.com, Satoshi Oshima <soshima@redhat.com>,
	Hideo Aoki <haoki@redhat.com>,
	sugita@sdl.hitachi.co.jp
Subject: Re: [Patch 2/5][Djprobe]Djprobe Coexist with Kprobes
Date: Thu, 29 Sep 2005 14:32:00 -0000	[thread overview]
Message-ID: <20050929143149.GA3682@in.ibm.com> (raw)
In-Reply-To: <433BE533.9080501@sdl.hitachi.co.jp>

On Thu, Sep 29, 2005 at 09:59:31PM +0900, Masami Hiramatsu wrote:

Few comments on first glance...

[...]

> +int __kprobes register_djprobe(struct djprobe * djp)
> +{
> +	struct djprobe_instance *djpi;
> +	struct kprobe *kp;
> +	int ret = 0, i;
> +	
> +	if (djp == NULL || djp->addr == NULL ||
> +	    djp->size > ARCH_STUB_INSN_MAX ||
> +	    djp->size < ARCH_STUB_INSN_MIN ||
> +	    djp->inst != NULL)
> +		return -EINVAL;
> +
> +	if ((ret = in_kprobes_functions((unsigned long) djp->addr)) != 0)
> +		return ret;
> +
> +	spin_lock(&djprobe_lock);

Please use _irqsave/_irqrestore versions at all places.

> +	/* check confliction with other djprobes */
> +	djpi = __get_djprobe_instance(djp->addr, djp->size);
> +	if (djpi) {
> +		if (djpi->kp.addr == djp->addr && DJPI_EMPTY(djpi)) {
> +			djp->inst = djpi;
> +			djpi->djp = djp; /*TODO: use list*/
> +			goto out;
> +		} else {
> +			ret = -EEXIST; /* a djprobe were inserted */
> +			goto out;
> +		}
> +	}
> +	/* check confliction with kprobes */
> +	for ( i=0; i < djp->size; i++) {
> +		kp = get_kprobe((void*)((long)djp->addr+i));
> +		if (kp != NULL) {
> +			ret = -EEXIST; /* a kprobes were inserted */
> +			goto out;
> +		}
> +	}
> +	/* make a new instance */
> +	djpi = kmalloc(sizeof(struct djprobe_instance),GFP_KERNEL);

You are under a spinlock... this kmalloc may sleep.

> +	if (djpi == NULL) {
> +		ret = -ENOMEM; /* memory allocation error */
> +		goto out;
> +	}
> +	memset(djpi, 0, sizeof(struct djprobe_instance)); /* for kprobe */
> +	/* attach */
> +	djp->inst = djpi;
> +	djpi->djp = djp; /*TODO: use list*/
> +	djpi->kp.addr = djp->addr;
> +	INIT_LIST_HEAD(&djpi->list);
> +	list_add(&djpi->list, &djprobe_list);
> +
> +	/* prepare stub */
> +	djpi->stub.insn = __get_insn_slot(&djprobe_insn_pages);
> +	if (djpi->stub.insn == NULL) {
> +		kfree(djpi);
> +		ret = -ENOMEM; /* memory allocation error */
> +		goto out;
> +	}
> +	djpi->kp.pre_handler = djprobe_bypass_handler;
> +	arch_prepare_djprobe_instance(djpi, djp->size); /*TODO : remove size*/
> +
> +	ret = install_djprobe_instance(djpi);
> +	if (ret < 0) { /* failed to install */
> +		djp->inst = NULL;
> +		djpi->kp.addr = NULL;
> +		__free_djprobe_instance(djpi);
> +	}
> +out:
> +	spin_unlock(&djprobe_lock);
> +	return ret;
> +}
> +
> +void __kprobes unregister_djprobe(struct djprobe * djp)
> +{
> +	struct djprobe_instance *djpi;
> +	if (djp == NULL || djp->inst == NULL)
> +		return ;
> +
> +	djpi = djp->inst;
> +	spin_lock(&djprobe_lock);
> +	djp->inst = NULL;
> +	djpi->djp = NULL; /*TODO: use list*/
> +	if (DJPI_EMPTY(djpi)) {
> +		uninstall_djprobe_instance(djpi);
> +	}
> +	spin_unlock(&djprobe_lock);
> +}
> +
> +#else /* ARCH_SUPPORTS_DJPROBES */
> +int __kprobes register_djprobe(struct djprobe *p)
> +{
> +	if (p!=NULL) {

Follow CodingStyle please! There are a few other places in the existing
kprobes code that also need a CodingStyle cleanup, but that is for a
later patch.

Ananth

  reply	other threads:[~2005-09-29 14:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-29 13:01 Masami Hiramatsu
2005-09-29 14:32 ` Ananth N Mavinakayanahalli [this message]
2005-10-03  0:36   ` Masami Hiramatsu
2005-10-17 13:47   ` Masami Hiramatsu
2005-10-17 14:28     ` Ananth N Mavinakayanahalli
2005-10-03 23:29 ` Keshavamurthy Anil S
2005-10-06  2:50   ` Masami Hiramatsu
2005-10-06 19:57     ` Keshavamurthy Anil S
2005-10-13 10:12       ` Masami Hiramatsu
2005-10-19  3:58         ` Keshavamurthy Anil S
2005-10-19 13:30           ` Masami Hiramatsu
2005-10-19 18:26             ` Keshavamurthy Anil S

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=20050929143149.GA3682@in.ibm.com \
    --to=ananth@in.ibm.com \
    --cc=haoki@redhat.com \
    --cc=hiramatu@sdl.hitachi.co.jp \
    --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).