mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Vamsi Krishna S ." <vamsi@in.ibm.com>
To: Stephen Hemminger <shemminger@osdl.org>
Cc: Linus Torvalds <torvalds@transmeta.com>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Kernel List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] (4/5) improved notifier callback mechanism - read copy update
Date: Thu, 19 Dec 2002 18:19:29 +0530	[thread overview]
Message-ID: <20021219181929.A5265@in.ibm.com> (raw)
In-Reply-To: <1040249652.14364.192.camel@dell_ss3.pdx.osdl.net>; from shemminger@osdl.org on Wed, Dec 18, 2002 at 11:06:08PM +0000

Hi Stephen,

On Wed, Dec 18, 2002 at 11:06:08PM +0000, Stephen Hemminger wrote:
> The notifier interface was only partially locked. The
> notifier_call_chain needs to be called in places where it is impossible
> to safely without having deadlocks; for example, NMI watchdog timeout.
> 
> This patch uses read-copy-update to manage the list.  One extra bit of
> safety is using a reference count on the notifier_blocks to allow for
> cases like oprofile which need to sleep in a callback.
> 
<snip>
>   
>  int notifier_call_chain(struct list_head *list, unsigned long val, void
> *v)
>  {
> -	struct list_head *p;
> +	struct list_head *p, *nxtp;
>  	int ret = NOTIFY_DONE;
>  
> -	list_for_each(p, list) {
> +	rcu_read_lock();
> +	list_for_each_safe_rcu(p, nxtp, list) {
>  		struct notifier_block *nb =
>  			list_entry(p, struct notifier_block, link);
>  
> +		atomic_inc(&nb->inuse);
>  		ret = nb->notifier_call(nb,val,v);
> +		atomic_dec(&nb->inuse);
> +

There could be a small problem here. When rcu_read_lock() is called,
it bumps the preempt_count, so when the called handler attempts
to sleep, it will oops with "Bad: scheduling in atomic region".

-- 
Vamsi Krishna S.
Linux Technology Center,
IBM Software Lab, Bangalore.
Ph: +91 80 5044959
Internet: vamsi@in.ibm.com

  reply	other threads:[~2002-12-19 12:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-18 22:14 Stephen Hemminger
2002-12-19 12:49 ` Vamsi Krishna S . [this message]
2002-12-19 17:37   ` Stephen Hemminger
2002-12-19 18:08     ` John Levon
2002-12-19 23:07   ` [PATCH] (4/5) notifier callback mechanism - read copy update V2 Stephen Hemminger
2002-12-19 23:09   ` [PATCH] (5/5) improved notifier callback mechanism -- remove old locking V2 Stephen Hemminger

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=20021219181929.A5265@in.ibm.com \
    --to=vamsi@in.ibm.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shemminger@osdl.org \
    --cc=torvalds@transmeta.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

Powered by JetHome