public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@us.ibm.com>
To: Roman Zippel <zippel@linux-m68k.org>
Cc: Dipankar Sarma <dipankar@in.ibm.com>,
	Oleg Nesterov <oleg@tv-sign.ru>, Kirill Korotaev <dev@sw.ru>,
	Andrew Morton <akpm@osdl.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Christoph Hellwig <hch@infradead.org>,
	Pavel Emelianov <xemul@openvz.org>, Andrey Savochkin <saw@sw.ru>,
	devel@openvz.org, Rik van Riel <riel@redhat.com>,
	Andi Kleen <ak@suse.de>, Alexey Dobriyan <adobriyan@mail.ru>,
	Matt Helsley <matthltc@us.ibm.com>,
	CKRM-Tech <ckrm-tech@lists.sourceforge.net>
Subject: Re: [PATCH 1/7] introduce atomic_dec_and_lock_irqsave()
Date: Thu, 31 Aug 2006 15:58:28 -0700	[thread overview]
Message-ID: <20060831225828.GB4927@us.ibm.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0608301918260.6761@scrub.home>

On Wed, Aug 30, 2006 at 07:25:07PM +0200, Roman Zippel wrote:
> Hi,
> 
> On Wed, 30 Aug 2006, Dipankar Sarma wrote:
> 
> > > > uidhash_lock can be taken from irq context. For example, delayed_put_task_struct()
> > > > does __put_task_struct()->free_uid().
> > > 
> > > AFAICT it's called via rcu, does that mean anything released via rcu has 
> > > to be protected against interrupts?
> > 
> > No. You need protection only if you have are using some 
> > data that can also be used by the RCU callback. For example,
> > if your RCU callback just calls kfree(), you don't have to 
> > do a spin_lock_bh().
> 
> In this case kfree() does its own interrupt synchronization. I didn't 
> realize before that rcu had this (IMO serious) limitation. I think there 
> should be two call_rcu() variants, one that queues the callback in a soft 
> irq and a second which queues it in a thread context.

How about just using synchronize_rcu() in the second situation?
This primitive blocks until the grace period completes, allowing you to
do the remaining processing in thread context.  As a bonus, RCU code
that uses synchronize_rcu() is usually quite a bit simpler than code
using call_rcu().

Using synchronize_rcu():

	list_del_rcu(p);
	synchronize_rcu();
	kfree(p);

Using call_rcu():

	static void rcu_callback_func(struct rcu_head *rcu)
	{
		struct foo *p = container_of(rcu, struct foo, rcu);

		kfree(p);
	}

	list_del_rcu(p);
	call_rcu(&p->rcu, rcu_callback_func);

Furthermore, the call_rcu() approach requires a struct rcu_head somewhere
in the data structure, so use of synchronize_rcu() saves a bit of memory,
as well.

But if you have a situation where neither synchronize_srcu() nor
call_rcu() is working out for you, let's hear it!

						Thanx, Paul

  reply	other threads:[~2006-08-31 22:57 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-29 14:33 [PATCH] BC: resource beancounters (v3) Kirill Korotaev
2006-08-29 14:49 ` [PATCH 1/7] introduce atomic_dec_and_lock_irqsave() Kirill Korotaev
2006-08-30  9:59   ` Roman Zippel
2006-08-30 14:57     ` Oleg Nesterov
2006-08-30 10:51       ` Roman Zippel
2006-08-30 15:51         ` Oleg Nesterov
2006-08-30 11:54           ` Roman Zippel
2006-08-30 16:58         ` Dipankar Sarma
2006-08-30 17:25           ` Roman Zippel
2006-08-31 22:58             ` Paul E. McKenney [this message]
2006-08-29 14:51 ` [PATCH 2/7] BC: kconfig Kirill Korotaev
2006-08-30  4:05   ` Randy.Dunlap
2006-08-29 14:53 ` [PATCH 3/7] BC: beancounters core (API) Kirill Korotaev
2006-08-30 18:58   ` [ckrm-tech] " Chandra Seetharaman
2006-08-30 19:47     ` Andrew Morton
2006-08-29 14:54 ` [PATCH 4/7] BC: context inheriting and changing Kirill Korotaev
2006-08-30 19:11   ` [ckrm-tech] " Chandra Seetharaman
2006-08-29 14:55 ` [PATCH 5/7] BC: user interface (syscalls) Kirill Korotaev
2006-08-30 19:15   ` [ckrm-tech] " Chandra Seetharaman
2006-08-29 14:58 ` [PATCH 6/7] BC: kernel memory (core) Kirill Korotaev
2006-08-29 18:41   ` Balbir Singh
2006-09-04 12:21     ` Kirill Korotaev
2006-09-04 15:45       ` Balbir Singh
2006-08-29 20:29   ` [ckrm-tech] " Dave Hansen
2006-09-04 12:23     ` Kirill Korotaev
2006-09-05 16:21       ` Dave Hansen
2006-08-30 19:25   ` Chandra Seetharaman
2006-08-29 14:58 ` [PATCH 7/7] BC: kernel memory (marks) Kirill Korotaev

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=20060831225828.GB4927@us.ibm.com \
    --to=paulmck@us.ibm.com \
    --cc=adobriyan@mail.ru \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=ckrm-tech@lists.sourceforge.net \
    --cc=dev@sw.ru \
    --cc=devel@openvz.org \
    --cc=dipankar@in.ibm.com \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthltc@us.ibm.com \
    --cc=oleg@tv-sign.ru \
    --cc=riel@redhat.com \
    --cc=saw@sw.ru \
    --cc=xemul@openvz.org \
    --cc=zippel@linux-m68k.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox