public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dipankar Sarma <dipankar@in.ibm.com>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>,
	linux-kernel@vger.kernel.org, paul.mckenney@us.ibm.com
Subject: Re: [Lse-tech] Re: RFC: patch to allow lock-free traversal of lists with insertion
Date: Sat, 13 Oct 2001 00:23:13 +0530	[thread overview]
Message-ID: <20011013002313.A30411@in.ibm.com> (raw)
In-Reply-To: <20011012132733.75734399.rusty@rustcorp.com.au> <Pine.LNX.4.33.0110120948540.31692-100000@penguin.transmeta.com>
In-Reply-To: <Pine.LNX.4.33.0110120948540.31692-100000@penguin.transmeta.com>; from torvalds@transmeta.com on Fri, Oct 12, 2001 at 09:56:58AM -0700

On Fri, Oct 12, 2001 at 09:56:58AM -0700, Linus Torvalds wrote:
> 
> Yes. With maybe
> 
> 	non_preempt()
> 	..
> 	preempt()
> 
> around it for the pre-emption patches.

Yes. While in the read side, preemption will have to be disabled
to prevent local pointers being carried across context switches.
It isn't impossible to allow preemption, but that makes the
quiescent point detection logic much more complicated.

> 
> However, you also need to make your free _free_ be aware of the count.
> Which means that the current RCU patch is really unusable for this. You
> need to have the "count" always in a generic place (put it with the hash),
> and your schedule-time free needs to do
> 
> 	if (atomic_read(&count))
> 		skip_this_do_it_next_time
> 
> which starts getting complicated (it means your RCU free now has to have a
> notion of "next time" - just leaving the RCU active will slow down
> scheduling for as long as any reader holds on to an entry). So your
> unread() path probably has to be
> 
> 	if (atomic_dec_and_test(&count))
> 		free_it()
> 
> and the act of hashing should add a count and unhashing should delete a
> count (so that the reader doesn't free it while it is hashed).

Perhaps I am missing something here but shouldn't the refcount based 
schemes anyway have to do this with or without RCU ? If you do

	unhash
	if (atomic_dec_and_test(&count))
		free_it();

the isn't it that if refcount is not 0, sometime later it will have to be 
cleaned up by some garbage collection scheme ? Whatever that scheme is, 
it still needs to be made certain that the element is not back in the 
hash table.  It seems to me that with RCU the same logic can be made use of.
So instead of doing 

	if (atomic_dec_and_test(&count))
		rcu_free_it()

you may do 

	if (atomic_dec_and_test(&count))
		free_it();


where in free_it()

	if (atomic_read(&count))
		return;
	rcu_free_it();

Of course, there may be more complicated freeing schemes for which
we may need additional logic just like you suggested.

> 
> Do that, and the RCU patches may start looking usable for the real world.
> 

One RCU example for refcount + hash table is at
http://lse.sourceforge.net/locking/patches/rt_rcu-2.4.6-02.patch
(ipv4 route cache). 

Thanks
Dipankar
-- 
Dipankar Sarma  <dipankar@in.ibm.com> Project: http://lse.sourceforge.net
Linux Technology Center, IBM Software Lab, Bangalore, India.

  reply	other threads:[~2001-10-12 18:50 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-10 10:06 [Lse-tech] Re: RFC: patch to allow lock-free traversal of lists with insertion Dipankar Sarma
2001-10-10 10:18 ` Linus Torvalds
2001-10-10 11:43   ` Dipankar Sarma
2001-10-12  3:27   ` Rusty Russell
2001-10-12 16:56     ` Linus Torvalds
2001-10-12 18:53       ` Dipankar Sarma [this message]
2001-10-13  7:25       ` Rusty Russell
  -- strict thread matches above, loose matches on Subject: below --
2001-10-13 14:42 Paul McKenney
2001-10-13 17:23 ` Linus Torvalds
2001-10-13 17:28   ` Linus Torvalds
2001-10-14  7:25     ` Dipankar Sarma
2001-10-13 18:42   ` Andi Kleen
2001-10-13 19:15     ` Alexander Viro
2001-10-13 20:44     ` Rusty Russell
2001-10-13 21:19   ` Rusty Russell
2001-10-11 10:34 Dipankar Sarma
2001-10-10 21:44 Paul McKenney
2001-10-10 16:00 Paul McKenney
2001-10-10 15:24 Paul McKenney
2001-10-10 16:58 ` Andrea Arcangeli
2001-10-10 17:25   ` Linus Torvalds
2001-10-12  5:06     ` Rusty Russell
2001-10-12 16:28       ` Linus Torvalds
2001-10-12 19:50         ` Al Dunsmuir
2001-10-13  1:07         ` Paul Mackerras
2001-10-13  1:54           ` Davide Libenzi
2001-10-13  2:04             ` Linus Torvalds
2001-10-13  2:31               ` Davide Libenzi
2001-10-13  2:46                 ` Davide Libenzi
2001-10-13  3:30                 ` Linus Torvalds
2001-10-13  2:49               ` Paul Mackerras
2001-10-13  2:00           ` Linus Torvalds
2001-10-13  7:38         ` Rusty Russell
     [not found] <20011010182730.0077454b.rusty@rustcorp.com.au>
2001-10-10  9:36 ` Linus Torvalds
2001-10-11  6:50   ` Rusty Russell
2001-10-10  7:58 Dipankar Sarma
2001-10-10  7:06 Dipankar Sarma
2001-10-10  7:21 ` BALBIR SINGH
2001-10-10  9:06   ` Dipankar Sarma
2001-10-10  6:54 Dipankar Sarma
2001-10-10  4:43 Paul McKenney
2001-10-09 15:45 Paul McKenney
2001-10-10  2:05 ` [Lse-tech] " Andrea Arcangeli
2001-10-10  5:05   ` Linus Torvalds
2001-10-10  5:17     ` BALBIR SINGH
2001-10-10  5:29       ` Davide Libenzi
2001-10-10  5:46       ` Linus Torvalds
2001-10-10  6:01         ` BALBIR SINGH
2001-10-10 15:23           ` Victor Yodaiken
2001-10-10  6:16     ` Paul Mackerras
2001-10-10  6:30       ` Linus Torvalds
2001-10-10  7:36     ` Paul Mackerras
2001-10-10 15:54       ` Victor Yodaiken
2001-10-10 21:56         ` Keith Owens
2001-10-10 22:24           ` Victor Yodaiken
2001-10-10 23:46             ` David S. Miller
2001-10-11  0:24               ` Davide Libenzi
2001-10-10 11:54     ` Keith Owens
2001-10-10 13:24   ` Ivan Kokshaysky
2001-10-10 13:41     ` Andrea Arcangeli

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=20011013002313.A30411@in.ibm.com \
    --to=dipankar@in.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul.mckenney@us.ibm.com \
    --cc=rusty@rustcorp.com.au \
    --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