All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Ebbert <76306.1226@compuserve.com>
To: David Smith <dsmith@redhat.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
	Prasanna S Panchamukhi <prasanna@in.ibm.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Rusty Russell <rusty@rustcorp.com.au>,
	Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH] module interface improvement for kprobes
Date: Fri, 4 Aug 2006 19:00:33 -0400	[thread overview]
Message-ID: <200608041902_MC3-1-C71C-6FC9@compuserve.com> (raw)

In-Reply-To: <1154721061.15967.31.camel@dhcp-2.hsv.redhat.com>

On Fri, 04 Aug 2006 14:51:01 -0500, David Smith wrote:

> > > I've added a new function, module_get_byname(), that looks up a module
> > > by name and returns the module reference.  Note that module_get_byname()
> > > also increments the module reference count.  It does this so that the
> > > module won't be unloaded between the time that module_get_byname() is
> > > called and register_kprobe() is called.

Your patch is word-wrapped.

Also:

> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -291,7 +291,27 @@ static struct module *find_module(const 
>       }
>       return NULL;
>  }
> +  
> +int module_get_byname(const char *mod_name, struct module **mod)
> +{
> +     *mod = NULL;
>  
> +     /* We must hold module_mutex before calling find_module(). */
> +     if (mutex_lock_interruptible(&module_mutex) != 0)
> +             return -EINTR;
> +
> +     *mod = find_module(mod_name);
> +     mutex_unlock(&module_mutex);
> +     if (*mod) {
> +             if (!strong_try_module_get(*mod)) {

What keeps the module from going away between the mutex_unlock() and
strong_try_module_get()? It needs to be something like this:

        *mod = find_module(mod_name);
        if (*mod)
                ret = strong_try_module_get(*mod);
        mutex_unlock(&module_mutex);
        if (!ret) {
                *mod = NULL;
                return -EINVAL;
        }

> +                     *mod = NULL;
> +                     return -EINVAL;
> +             }
> +     }
> +     return 0;
> +}
> +EXPORT_SYMBOL_GPL(module_get_byname);
> + 
>  #ifdef CONFIG_SMP
>  /* Number of blocks used and allocated. */
>  static unsigned int pcpu_num_used, pcpu_num_allocated;

-- 
Chuck


             reply	other threads:[~2006-08-04 23:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-04 23:00 Chuck Ebbert [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-08-04 15:17 [PATCH] module interface improvement for kprobes David Smith
2006-08-04 15:57 ` Christoph Hellwig
2006-08-04 18:30   ` David Smith
2006-08-05 11:35     ` Christoph Hellwig
2006-08-05 21:10       ` Frank Ch. Eigler
2006-08-07  4:52   ` Ananth N Mavinakayanahalli
2006-08-07  5:05     ` Ananth N Mavinakayanahalli
2006-08-08 15:39     ` David Smith
2006-08-04 16:00 ` Randy.Dunlap
2006-08-04 19:51   ` David Smith
2006-08-05  2:28 ` Rusty Russell

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=200608041902_MC3-1-C71C-6FC9@compuserve.com \
    --to=76306.1226@compuserve.com \
    --cc=ananth@in.ibm.com \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=davem@davemloft.net \
    --cc=dsmith@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=prasanna@in.ibm.com \
    --cc=rusty@rustcorp.com.au \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.