All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dipankar Sarma <dipankar@in.ibm.com>
To: Jesse Barnes <jbarnes@engr.sgi.com>
Cc: William Lee Irwin III <wli@holomorphy.com>,
	Jack Steiner <steiner@sgi.com>,
	linux-kernel@vger.kernel.org, edwardsg@sgi.com,
	levon@movementarian.org
Subject: Re: contention on profile_lock
Date: Fri, 5 Nov 2004 03:46:55 +0530	[thread overview]
Message-ID: <20041104221655.GA4099@in.ibm.com> (raw)
In-Reply-To: <200411041355.27228.jbarnes@engr.sgi.com>

On Thu, Nov 04, 2004 at 01:55:27PM -0800, Jesse Barnes wrote:
> On Thursday, November 4, 2004 12:49 pm, Jesse Barnes wrote:
> > John pointed out that this breaks modules.  Would registering and
>  
>  static void timer_stop(void)
>  {
> -	unregister_profile_notifier(&timer_notifier);
> +	/* Tear down the callback pointer after sync_kernel */
> +	synchronize_kernel();
> +	oprofile_timer_notify = NULL;
>  }
>  
>  
> +/* Oprofile timer tick hook */
> +int (*oprofile_timer_notify)(struct pt_regs *);
> +
>  static atomic_t *prof_buffer;
>  static unsigned long prof_len, prof_shift;
>  static int prof_on;
> @@ -168,38 +172,6 @@
>  	return err;
>  }
>  


> -void profile_hook(struct pt_regs * regs)
> -{
> -	read_lock(&profile_lock);
> -	notifier_call_chain(&profile_listeners, 0, regs);
> -	read_unlock(&profile_lock);
> -}
> -
> -EXPORT_SYMBOL_GPL(register_profile_notifier);
> -EXPORT_SYMBOL_GPL(unregister_profile_notifier);
>  EXPORT_SYMBOL_GPL(task_handoff_register);
>  EXPORT_SYMBOL_GPL(task_handoff_unregister);
>  
> @@ -394,8 +366,8 @@
>  
>  void profile_tick(int type, struct pt_regs *regs)
>  {
> -	if (type == CPU_PROFILING)
> -		profile_hook(regs);
> +	if (type == CPU_PROFILING && oprofile_timer_notify)
> +		oprofile_timer_notify(regs);
>  	if (!user_mode(regs) && cpu_isset(smp_processor_id(), prof_cpu_mask))
>  		profile_hit(type, (void *)profile_pc(regs));
>  }


Or you could just do -

void profile_tick(int type, struct pt_regs *regs)
{
	int (*timer_notify)(struct pt_regs *);

	timer_notify = oprofile_timer_notify;
	smp_read_barrier_depends();
	if (type == CPU_PROFILING && timer_notify) {
		timer_notify(regs);
	}
	if (!user_mode(regs) && cpu_isset(smp_processor_id(), prof_cpu_mask))
		profile_hit(type, (void *)profile_pc(regs));
}

And avoid the synchronize_kernel(). But I think the synchronize_kernel()
thing is cleaner.

I am looking at the notifier chain mechanism itself and its
lack of proper locking. That is a different story.

Thanks
Dipankar

  reply	other threads:[~2004-11-04 22:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-02 19:52 contention on profile_lock Jesse Barnes
2004-11-02 20:02 ` Jack Steiner
2004-11-02 21:42   ` Jesse Barnes
2004-11-04 19:56     ` Jesse Barnes
2004-11-04 20:12       ` William Lee Irwin III
2004-11-04 20:49         ` Jesse Barnes
2004-11-04 21:51           ` John Levon
2004-11-04 22:08             ` Jesse Barnes
2004-11-04 21:55           ` Jesse Barnes
2004-11-04 22:16             ` Dipankar Sarma [this message]
2004-11-04 22:21             ` John Levon
2004-11-04 22:27               ` Jesse Barnes
2004-11-04 22:52                 ` John Levon

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=20041104221655.GA4099@in.ibm.com \
    --to=dipankar@in.ibm.com \
    --cc=edwardsg@sgi.com \
    --cc=jbarnes@engr.sgi.com \
    --cc=levon@movementarian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=steiner@sgi.com \
    --cc=wli@holomorphy.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 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.