Re: [RFC PATCH] rcu: introduce kfree_rcu()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Lai Jiangshan
Date: Thursday, September 18, 2008 - 1:59 am

How to usage kfree_rcu:

struct my_struct {
	int data;
	struct rcu_head rcu;
};

----------------original code:--------------------------
void my_struct_release_rcu(struct rcu_head *rcu)
{
	struct my_struct *p;

	item = container_of(rcu, struct my_struct, rcu);
	kfree(p);
}

void some_fuction()
{
	struct my_struct *p;
	.....;
	call_rcu(&p->rcu, my_struct_release_rcu);
	.....;
}
---end---

-----------------after use kfree_rcu:--------------------

/* my_struct_release_rcu() was removed */

void some_fuction()
{
	struct my_struct *p;
	.....;
	kfree_rcu(p, &p->rcu);
	.....;
}
---end---

1) unloadable modules:
   A) use my_struct_release_rcu():
      when we unload this modules, we need call rcu_barrier() to wait
      all my_struct_release_rcu() had called.
   B) use kfree_rcu():
      if all trivial callback are removed and kfree_rcu() are used instead,
      we do not need to wait anything. just quick finish unloading.

2) duplicate code:
   A) use my_struct_release_rcu():
      All trivial callback are very like my_struct_release_rcu(),
      all are duplicate code.
   B) use kfree_rcu():
      all trivial callback are removed, not duplicate code like
      my_struct_release_rcu().

3) cache:
   A) use my_struct_release_rcu():
      my_struct_release_rcu() is called rarely, when my_struct_release_rcu()
      is being called, cache missing will occur.
   B) use kfree_rcu():
      my_struct_release_rcu() is removed, not such cache missing.

4) future:
   A) use my_struct_release_rcu():
      when new user use rcu, the most callback is trivial callback
      like my_struct_release_rcu(). this is the common of using rcu.
      so the problems of above are more and more heavy.
   B) use kfree_rcu():
      fix these problems for ever.


Paul E. McKenney wrote:

uses kfree_rcu() instead of trivial callback, not rcu_barrier()


we done need wait anything if not callback is defined in this module.


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC PATCH] rcu: introduce kfree_rcu(), Lai Jiangshan, (Wed Sep 17, 9:18 pm)
Re: [RFC PATCH] rcu: introduce kfree_rcu(), Andrew Morton, (Wed Sep 17, 9:37 pm)
Re: [RFC PATCH] rcu: introduce kfree_rcu(), Paul E. McKenney, (Wed Sep 17, 11:44 pm)
Re: [RFC PATCH] rcu: introduce kfree_rcu(), Lai Jiangshan, (Thu Sep 18, 1:59 am)
Re: [RFC PATCH] rcu: introduce kfree_rcu(), Manfred Spraul, (Thu Sep 18, 9:52 am)
Re: [RFC PATCH] rcu: introduce kfree_rcu(), Manfred Spraul, (Thu Sep 18, 9:56 am)
Re: [RFC PATCH] rcu: introduce kfree_rcu(), Paul E. McKenney, (Thu Sep 18, 10:15 am)
Re: [RFC PATCH] rcu: introduce kfree_rcu(), Paul E. McKenney, (Thu Sep 18, 10:46 am)
Re: [RFC PATCH] rcu: introduce kfree_rcu(), Lai Jiangshan, (Thu Sep 18, 6:04 pm)
Re: [RFC PATCH] rcu: introduce kfree_rcu(), Lai Jiangshan, (Thu Sep 18, 7:31 pm)
Re: [RFC PATCH] rcu: introduce kfree_rcu(), Paul E. McKenney, (Thu Sep 18, 8:58 pm)
Re: [RFC PATCH] rcu: introduce kfree_rcu(), Manfred Spraul, (Fri Sep 19, 9:03 am)