All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>, Ingo Molnar <mingo@elte.hu>,
	LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Li Zefan <lizf@cn.fujitsu.com>
Subject: Re: [RFC][PATCH] tracing/module: Move tracepoint out of module.h
Date: Thu, 29 Mar 2012 15:54:34 +1030	[thread overview]
Message-ID: <87limkx9m5.fsf@rustcorp.com.au> (raw)
In-Reply-To: <1332994964.3402.17.camel@edumazet-laptop>

On Thu, 29 Mar 2012 06:22:44 +0200, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> Le mercredi 01 février 2012 à 17:18 +1030, Rusty Russell a écrit :
> 
> >  
> > +void __module_get(struct module *module)
> > +{
> > +	if (module) {
> > +		preempt_disable();
> > +		__this_cpu_inc(module->refptr->incs);
> > +		trace_module_get(module, _RET_IP_);
> > +		preempt_enable();
> > +	}
> > +}
> > +EXPORT_SYMBOL(__module_get);
> > +
> 
> Hi Rusty
> 
> I am wondering why preempt_disable()/preempt_enable() is needed in this
> code.
> 
> this_cpu_inc(module->refptr->incs) is preempt safe...

I agree, it's overkill here:

> @@ -907,10 +907,8 @@ static struct module_attribute modinfo_refcnt =
>  void __module_get(struct module *module)
>  {
>  	if (module) {
> -		preempt_disable();
> -		__this_cpu_inc(module->refptr->incs);
> +		this_cpu_inc(module->refptr->incs);
>  		trace_module_get(module, _RET_IP_);
> -		preempt_enable();
>  	}
>  }
>  EXPORT_SYMBOL(__module_get);

But this one is required:

> @@ -920,15 +918,11 @@ bool try_module_get(struct module *module)
>  	bool ret = true;
>  
>  	if (module) {
> -		preempt_disable();
> -
>  		if (likely(module_is_live(module))) {
> -			__this_cpu_inc(module->refptr->incs);
> +			this_cpu_inc(module->refptr->incs);
>  			trace_module_get(module, _RET_IP_);
>  		} else
>  			ret = false;
> -
> -		preempt_enable();
>  	}
>  	return ret;
>  }

This is to protect against module removal's stop_machine.

> @@ -937,15 +931,13 @@ EXPORT_SYMBOL(try_module_get);
>  void module_put(struct module *module)
>  {
>  	if (module) {
> -		preempt_disable();
>  		smp_wmb(); /* see comment in module_refcount */
> -		__this_cpu_inc(module->refptr->decs);
> +		this_cpu_inc(module->refptr->decs);
>  
>  		trace_module_put(module, _RET_IP_);
>  		/* Maybe they're waiting for us to drop reference? */
>  		if (unlikely(!module_is_live(module)))
>  			wake_up_process(module->waiter);
> -		preempt_enable();
>  	}
>  }
>  EXPORT_SYMBOL(module_put);

Without the preempt disable, module can vanish immediately
after that increment.

Cheers,
Rusty.
-- 
  How could I marry someone with more hair than me?  http://baldalex.org

  reply	other threads:[~2012-03-29  5:51 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-16 22:57 [PATCH][GIT PULL][v3.3] tracing: Add header wrappers event_headers_start.h and event_headers_end.h Steven Rostedt
2012-01-17  9:54 ` Ingo Molnar
2012-01-17 13:32   ` Steven Rostedt
2012-01-18 12:07     ` Ingo Molnar
2012-01-18 17:56       ` Steven Rostedt
2012-01-22 22:59         ` Rusty Russell
2012-01-26  2:41           ` [RFC][PATCH] tracing/module: Move tracepoint out of module.h Steven Rostedt
2012-01-26  2:45             ` Steven Rostedt
2012-01-26 10:28             ` Ingo Molnar
2012-01-26 13:52               ` Steven Rostedt
2012-01-26 13:55                 ` Ingo Molnar
2012-01-26 14:04                   ` Steven Rostedt
2012-01-26 14:07                     ` Steven Rostedt
2012-01-26 14:36                     ` Steven Rostedt
2012-01-26 18:39                       ` Ingo Molnar
2012-01-27  3:02                         ` Rusty Russell
2012-01-30 11:52                           ` Steven Rostedt
2012-01-30 17:28                             ` Steven Rostedt
2012-01-31  3:58                             ` Rusty Russell
2012-01-31 12:20                               ` Ingo Molnar
2012-01-31 12:50                                 ` Steven Rostedt
2012-02-01  6:48                                   ` Rusty Russell
2012-02-01 13:27                                     ` Steven Rostedt
2012-02-01 13:49                                     ` Ingo Molnar
2012-02-01 14:25                                       ` Steven Rostedt
2012-03-29  4:22                                     ` Eric Dumazet
2012-03-29  5:24                                       ` Rusty Russell [this message]
2012-02-01  1:10                                 ` Rusty Russell
2012-02-01  7:09                                   ` Ingo Molnar
2012-01-30  6:40                       ` Li Zefan
2012-02-17 13:46       ` [tip:perf/core] tracing/softirq: Move __raise_softirq_irqoff() out of header tip-bot for Steven Rostedt

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=87limkx9m5.fsf@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=akpm@linux-foundation.org \
    --cc=eric.dumazet@gmail.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    /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.