2011-05-02 21:42:14

by Paul E. McKenney

[permalink] [raw]
Subject: [PATCH tip/core/rcu 0/7] More uses of kfree_rcu

Hello!

This patchset replaces call_rcu() with kfree_rcu() in a few more places.

Thanx, Paul

include/net/sock.h | 4 +---
kernel/sysctl.c | 11 +++--------
net/batman-adv/gateway_client.c | 10 +---------
net/batman-adv/originator.c | 10 +---------
net/batman-adv/soft-interface.c | 10 +---------
net/core/filter.c | 12 ------------
net/ipv6/sit.c | 7 +------
net/netfilter/xt_RATEEST.c | 8 +-------
8 files changed, 9 insertions(+), 63 deletions(-)


2011-05-02 21:36:59

by Paul E. McKenney

[permalink] [raw]
Subject: [PATCH tip/core/rcu 1/7] net,rcu: convert call_rcu(sk_filter_release_rcu) to kfree_rcu

The RCU callback sk_filter_release_rcu just calls kfree(), so we use
kfree_rcu() instead of call_rcu().

Signed-off-by: Paul E. McKenney <[email protected]>
Cc: Patrick McHardy <[email protected]>
Cc: David S. Miller <[email protected]>
---
include/net/sock.h | 4 +---
net/core/filter.c | 12 ------------
2 files changed, 1 insertions(+), 15 deletions(-)

diff --git a/include/net/sock.h b/include/net/sock.h
index 01810a3..60caa06 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1179,8 +1179,6 @@ extern void sk_common_release(struct sock *sk);
/* Initialise core socket variables */
extern void sock_init_data(struct socket *sock, struct sock *sk);

-extern void sk_filter_release_rcu(struct rcu_head *rcu);
-
/**
* sk_filter_release - release a socket filter
* @fp: filter to remove
@@ -1191,7 +1189,7 @@ extern void sk_filter_release_rcu(struct rcu_head *rcu);
static inline void sk_filter_release(struct sk_filter *fp)
{
if (atomic_dec_and_test(&fp->refcnt))
- call_rcu(&fp->rcu, sk_filter_release_rcu);
+ kfree_rcu(fp, rcu);
}

static inline void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp)
diff --git a/net/core/filter.c b/net/core/filter.c
index afb8afb..7195ce0 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -631,18 +631,6 @@ int sk_chk_filter(struct sock_filter *filter, int flen)
EXPORT_SYMBOL(sk_chk_filter);

/**
- * sk_filter_release_rcu - Release a socket filter by rcu_head
- * @rcu: rcu_head that contains the sk_filter to free
- */
-void sk_filter_release_rcu(struct rcu_head *rcu)
-{
- struct sk_filter *fp = container_of(rcu, struct sk_filter, rcu);
-
- kfree(fp);
-}
-EXPORT_SYMBOL(sk_filter_release_rcu);
-
-/**
* sk_attach_filter - attach a socket filter
* @fprog: the filter program
* @sk: the socket to use
--
1.7.3.2

2011-05-02 21:37:03

by Paul E. McKenney

[permalink] [raw]
Subject: [PATCH tip/core/rcu 2/7] sysctl,rcu: convert call_rcu(free_head) to kfree

The RCU callback free_head just calls kfree(), so we can use kfree_rcu()
instead of call_rcu().

Signed-off-by: Paul E. McKenney <[email protected]>
Cc: Andrew Morton <[email protected]>
---
kernel/sysctl.c | 11 +++--------
1 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index c0bb324..39dbad0 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1574,16 +1574,11 @@ void sysctl_head_get(struct ctl_table_header *head)
spin_unlock(&sysctl_lock);
}

-static void free_head(struct rcu_head *rcu)
-{
- kfree(container_of(rcu, struct ctl_table_header, rcu));
-}
-
void sysctl_head_put(struct ctl_table_header *head)
{
spin_lock(&sysctl_lock);
if (!--head->count)
- call_rcu(&head->rcu, free_head);
+ kfree_rcu(head, rcu);
spin_unlock(&sysctl_lock);
}

@@ -1955,10 +1950,10 @@ void unregister_sysctl_table(struct ctl_table_header * header)
start_unregistering(header);
if (!--header->parent->count) {
WARN_ON(1);
- call_rcu(&header->parent->rcu, free_head);
+ kfree_rcu(header->parent, rcu);
}
if (!--header->count)
- call_rcu(&header->rcu, free_head);
+ kfree_rcu(header, rcu);
spin_unlock(&sysctl_lock);
}

--
1.7.3.2

2011-05-02 21:37:00

by Paul E. McKenney

[permalink] [raw]
Subject: [PATCH tip/core/rcu 3/7] batman,rcu: convert call_rcu(gw_node_free_rcu) to kfree_rcu

The RCU callback gw_node_free_rcu() just calls kfree(), so we can use
kfree_rcu() instead of call_rcu().

Signed-off-by: Paul E. McKenney <[email protected]>
Cc: Marek Lindner <[email protected]>
Cc: Simon Wunderlich <[email protected]>
Cc: Sven Eckelmann <[email protected]>
---
net/batman-adv/gateway_client.c | 10 +---------
1 files changed, 1 insertions(+), 9 deletions(-)

diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index 3cc4355..150b6ce 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -28,18 +28,10 @@
#include <linux/udp.h>
#include <linux/if_vlan.h>

-static void gw_node_free_rcu(struct rcu_head *rcu)
-{
- struct gw_node *gw_node;
-
- gw_node = container_of(rcu, struct gw_node, rcu);
- kfree(gw_node);
-}
-
static void gw_node_free_ref(struct gw_node *gw_node)
{
if (atomic_dec_and_test(&gw_node->refcount))
- call_rcu(&gw_node->rcu, gw_node_free_rcu);
+ kfree_rcu(gw_node, rcu);
}

void *gw_get_selected(struct bat_priv *bat_priv)
--
1.7.3.2

2011-05-02 21:41:59

by Paul E. McKenney

[permalink] [raw]
Subject: [PATCH tip/core/rcu 4/7] batman,rcu: convert call_rcu(neigh_node_free_rcu) to kfree()

The RCU callback neigh_node_free_rcu() just calls kfree(), so we can use
kfree_rcu() instead of call_rcu().

Signed-off-by: Paul E. McKenney <[email protected]>
Cc: Marek Lindner <[email protected]>
Cc: Simon Wunderlich <[email protected]>
Cc: Sven Eckelmann <[email protected]>
---
net/batman-adv/originator.c | 10 +---------
1 files changed, 1 insertions(+), 9 deletions(-)

diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 0b91330..ed23a589 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -56,18 +56,10 @@ err:
return 0;
}

-static void neigh_node_free_rcu(struct rcu_head *rcu)
-{
- struct neigh_node *neigh_node;
-
- neigh_node = container_of(rcu, struct neigh_node, rcu);
- kfree(neigh_node);
-}
-
void neigh_node_free_ref(struct neigh_node *neigh_node)
{
if (atomic_dec_and_test(&neigh_node->refcount))
- call_rcu(&neigh_node->rcu, neigh_node_free_rcu);
+ kfree_rcu(neigh_node, rcu);
}

struct neigh_node *create_neighbor(struct orig_node *orig_node,
--
1.7.3.2

2011-05-02 21:36:52

by Paul E. McKenney

[permalink] [raw]
Subject: [PATCH tip/core/rcu 5/7] batman,rcu: convert call_rcu(softif_neigh_free_rcu) to kfree_rcu

The RCU callback softif_neigh_free_rcu() just calls kfree(), so we can
use kfree_rcu() instead of call_rcu().

Signed-off-by: Paul E. McKenney <[email protected]>
Cc: Marek Lindner <[email protected]>
Cc: Simon Wunderlich <[email protected]>
Cc: Sven Eckelmann <[email protected]>
---
net/batman-adv/soft-interface.c | 10 +---------
1 files changed, 1 insertions(+), 9 deletions(-)

diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 824e1f6..04efe02 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -76,18 +76,10 @@ int my_skb_head_push(struct sk_buff *skb, unsigned int len)
return 0;
}

-static void softif_neigh_free_rcu(struct rcu_head *rcu)
-{
- struct softif_neigh *softif_neigh;
-
- softif_neigh = container_of(rcu, struct softif_neigh, rcu);
- kfree(softif_neigh);
-}
-
static void softif_neigh_free_ref(struct softif_neigh *softif_neigh)
{
if (atomic_dec_and_test(&softif_neigh->refcount))
- call_rcu(&softif_neigh->rcu, softif_neigh_free_rcu);
+ kfree_rcu(softif_neigh, rcu);
}

void softif_neigh_purge(struct bat_priv *bat_priv)
--
1.7.3.2

2011-05-02 21:41:25

by Paul E. McKenney

[permalink] [raw]
Subject: [PATCH tip/core/rcu 6/7] net,rcu: convert call_rcu(prl_entry_destroy_rcu) to kfree

The RCU callback prl_entry_destroy_rcu() just calls kfree(), so we can
use kfree_rcu() instead of call_rcu().

Signed-off-by: Paul E. McKenney <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Alexey Kuznetsov <[email protected]>
Cc: "Pekka Savola (ipv6)" <[email protected]>
Cc: James Morris <[email protected]>
Cc: Hideaki YOSHIFUJI <[email protected]>
Cc: Patrick McHardy <[email protected]>
---
net/ipv6/sit.c | 7 +------
1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 43b3337..5f35d59 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -401,11 +401,6 @@ out:
return err;
}

-static void prl_entry_destroy_rcu(struct rcu_head *head)
-{
- kfree(container_of(head, struct ip_tunnel_prl_entry, rcu_head));
-}
-
static void prl_list_destroy_rcu(struct rcu_head *head)
{
struct ip_tunnel_prl_entry *p, *n;
@@ -433,7 +428,7 @@ ipip6_tunnel_del_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a)
p = &x->next) {
if (x->addr == a->addr) {
*p = x->next;
- call_rcu(&x->rcu_head, prl_entry_destroy_rcu);
+ kfree_rcu(x, rcu_head);
t->prl_count--;
goto out;
}
--
1.7.3.2

2011-05-02 21:36:50

by Paul E. McKenney

[permalink] [raw]
Subject: [PATCH tip/core/rcu 7/7] net,rcu: convert call_rcu(xt_rateest_free_rcu) to kfree_rcu()

The RCU callback xt_rateest_free_rcu() just calls kfree(), so we can
use kfree_rcu() instead of call_rcu(). This also allows us to dispense
with an rcu_barrier() call, speeding up unloading of this module.

Signed-off-by: Paul E. McKenney <[email protected]>
Cc: Patrick McHardy <[email protected]>
---
net/netfilter/xt_RATEEST.c | 8 +-------
1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/net/netfilter/xt_RATEEST.c b/net/netfilter/xt_RATEEST.c
index de079ab..f264032 100644
--- a/net/netfilter/xt_RATEEST.c
+++ b/net/netfilter/xt_RATEEST.c
@@ -60,11 +60,6 @@ struct xt_rateest *xt_rateest_lookup(const char *name)
}
EXPORT_SYMBOL_GPL(xt_rateest_lookup);

-static void xt_rateest_free_rcu(struct rcu_head *head)
-{
- kfree(container_of(head, struct xt_rateest, rcu));
-}
-
void xt_rateest_put(struct xt_rateest *est)
{
mutex_lock(&xt_rateest_mutex);
@@ -75,7 +70,7 @@ void xt_rateest_put(struct xt_rateest *est)
* gen_estimator est_timer() might access est->lock or bstats,
* wait a RCU grace period before freeing 'est'
*/
- call_rcu(&est->rcu, xt_rateest_free_rcu);
+ kfree_rcu(est, rcu);
}
mutex_unlock(&xt_rateest_mutex);
}
@@ -188,7 +183,6 @@ static int __init xt_rateest_tg_init(void)
static void __exit xt_rateest_tg_fini(void)
{
xt_unregister_target(&xt_rateest_tg_reg);
- rcu_barrier(); /* Wait for completion of call_rcu()'s (xt_rateest_free_rcu) */
}


--
1.7.3.2

2011-05-02 21:42:34

by David Miller

[permalink] [raw]
Subject: Re: [PATCH tip/core/rcu 1/7] net,rcu: convert call_rcu(sk_filter_release_rcu) to kfree_rcu

From: "Paul E. McKenney" <[email protected]>
Date: Mon, 2 May 2011 09:13:38 -0700

> The RCU callback sk_filter_release_rcu just calls kfree(), so we use
> kfree_rcu() instead of call_rcu().
>
> Signed-off-by: Paul E. McKenney <[email protected]>

I'm fine with all of these net conversions:

Acked-by: David S. Miller <[email protected]>

2011-05-02 22:06:39

by Paul E. McKenney

[permalink] [raw]
Subject: Re: [PATCH tip/core/rcu 1/7] net,rcu: convert call_rcu(sk_filter_release_rcu) to kfree_rcu

On Mon, May 02, 2011 at 02:41:56PM -0700, David Miller wrote:
> From: "Paul E. McKenney" <[email protected]>
> Date: Mon, 2 May 2011 09:13:38 -0700
>
> > The RCU callback sk_filter_release_rcu just calls kfree(), so we use
> > kfree_rcu() instead of call_rcu().
> >
> > Signed-off-by: Paul E. McKenney <[email protected]>
>
> I'm fine with all of these net conversions:
>
> Acked-by: David S. Miller <[email protected]>

Thank you, Dave!

Thanx, Paul

2011-05-03 00:14:07

by Josh Triplett

[permalink] [raw]
Subject: Re: [PATCH tip/core/rcu 0/7] More uses of kfree_rcu

On Mon, May 02, 2011 at 09:13:21AM -0700, Paul E. McKenney wrote:
> This patchset replaces call_rcu() with kfree_rcu() in a few more places.

For all 7 of these conversions:

Reviewed-by: Josh Triplett <[email protected]>

2011-05-03 06:14:23

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH tip/core/rcu 1/7] net,rcu: convert call_rcu(sk_filter_release_rcu) to kfree_rcu


* Paul E. McKenney <[email protected]> wrote:

> On Mon, May 02, 2011 at 02:41:56PM -0700, David Miller wrote:
> > From: "Paul E. McKenney" <[email protected]>
> > Date: Mon, 2 May 2011 09:13:38 -0700
> >
> > > The RCU callback sk_filter_release_rcu just calls kfree(), so we use
> > > kfree_rcu() instead of call_rcu().
> > >
> > > Signed-off-by: Paul E. McKenney <[email protected]>
> >
> > I'm fine with all of these net conversions:
> >
> > Acked-by: David S. Miller <[email protected]>
>
> Thank you, Dave!

Looking at the networking-only diffstat i suspect the best flow would be if
Dave pulled these from you into the networking tree?

Thanks,

Ingo

2011-05-03 06:17:08

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH tip/core/rcu 1/7] net,rcu: convert call_rcu(sk_filter_release_rcu) to kfree_rcu


* Ingo Molnar <[email protected]> wrote:

>
> * Paul E. McKenney <[email protected]> wrote:
>
> > On Mon, May 02, 2011 at 02:41:56PM -0700, David Miller wrote:
> > > From: "Paul E. McKenney" <[email protected]>
> > > Date: Mon, 2 May 2011 09:13:38 -0700
> > >
> > > > The RCU callback sk_filter_release_rcu just calls kfree(), so we use
> > > > kfree_rcu() instead of call_rcu().
> > > >
> > > > Signed-off-by: Paul E. McKenney <[email protected]>
> > >
> > > I'm fine with all of these net conversions:
> > >
> > > Acked-by: David S. Miller <[email protected]>
> >
> > Thank you, Dave!
>
> Looking at the networking-only diffstat i suspect the best flow would be if
> Dave pulled these from you into the networking tree?

Oh, but kfree_rcu() is not upstream yet, right? So it has to be in the RCU
tree.

Thanks,

Ingo

2011-05-03 07:11:06

by Sven Eckelmann

[permalink] [raw]
Subject: Re: [PATCH tip/core/rcu 5/7] batman,rcu: convert call_rcu(softif_neigh_free_rcu) to kfree_rcu

On Monday 02 May 2011 18:13:42 Paul E. McKenney wrote:
> The RCU callback softif_neigh_free_rcu() just calls kfree(), so we can
> use kfree_rcu() instead of call_rcu().
>
[...]
> The RCU callback neigh_node_free_rcu() just calls kfree(), so we can use
> kfree_rcu() instead of call_rcu().
[...]
> The RCU callback gw_node_free_rcu() just calls kfree(), so we can use
> kfree_rcu() instead of call_rcu().

Thanks, I am fine with Patch 3/7, 4/7, 5/7.

Acked-by: Sven Eckelmann <[email protected]>


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part.

2011-05-03 19:34:07

by Paul E. McKenney

[permalink] [raw]
Subject: Re: [PATCH tip/core/rcu 1/7] net,rcu: convert call_rcu(sk_filter_release_rcu) to kfree_rcu

On Tue, May 03, 2011 at 08:16:04AM +0200, Ingo Molnar wrote:
>
> * Ingo Molnar <[email protected]> wrote:
>
> >
> > * Paul E. McKenney <[email protected]> wrote:
> >
> > > On Mon, May 02, 2011 at 02:41:56PM -0700, David Miller wrote:
> > > > From: "Paul E. McKenney" <[email protected]>
> > > > Date: Mon, 2 May 2011 09:13:38 -0700
> > > >
> > > > > The RCU callback sk_filter_release_rcu just calls kfree(), so we use
> > > > > kfree_rcu() instead of call_rcu().
> > > > >
> > > > > Signed-off-by: Paul E. McKenney <[email protected]>
> > > >
> > > > I'm fine with all of these net conversions:
> > > >
> > > > Acked-by: David S. Miller <[email protected]>
> > >
> > > Thank you, Dave!
> >
> > Looking at the networking-only diffstat i suspect the best flow would be if
> > Dave pulled these from you into the networking tree?
>
> Oh, but kfree_rcu() is not upstream yet, right? So it has to be in the RCU
> tree.

Yep! So I either need to get kfree_rcu() upstream, then push up Dave's
tree, or I need to push them all up -tip. Either way is fine by me.

Thanx, Paul