* [B.A.T.M.A.N.] [PATCH] batman-adv: don't use call_rcu if not needed
@ 2013-05-06 19:39 Antonio Quartulli
2013-05-06 19:42 ` Antonio Quartulli
2013-05-06 20:29 ` Marek Lindner
0 siblings, 2 replies; 3+ messages in thread
From: Antonio Quartulli @ 2013-05-06 19:39 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Antonio Quartulli
batadv_tt_global_entry_free_ref uses call_rcu to schedule a
function which will only free the global entry itself.
For this reason call_rcu is useless and kfree_rcu can be
used to simplify the code.
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
compat.c | 11 +++++++++++
translation-table.c | 20 ++++++--------------
2 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/compat.c b/compat.c
index 1f3a39d..6226f81 100644
--- a/compat.c
+++ b/compat.c
@@ -27,6 +27,17 @@
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0)
+void batadv_free_rcu_tt_global_entry(struct rcu_head *rcu)
+{
+ struct batadv_tt_common_entry *common;
+ struct batadv_tt_global_entry *global;
+
+ common = container_of(rcu, struct batadv_tt_common_entry, rcu);
+ global = container_of(common, struct batadv_tt_common_entry, common);
+
+ kfree(global);
+}
+
void batadv_free_rcu_gw_node(struct rcu_head *rcu)
{
struct batadv_gw_node *gw_node;
diff --git a/translation-table.c b/translation-table.c
index df6b5cd..44e7789 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -117,25 +117,17 @@ batadv_tt_local_entry_free_ref(struct batadv_tt_local_entry *tt_local_entry)
kfree_rcu(tt_local_entry, common.rcu);
}
-static void batadv_tt_global_entry_free_rcu(struct rcu_head *rcu)
-{
- struct batadv_tt_common_entry *tt_common_entry;
- struct batadv_tt_global_entry *tt_global_entry;
-
- tt_common_entry = container_of(rcu, struct batadv_tt_common_entry, rcu);
- tt_global_entry = container_of(tt_common_entry,
- struct batadv_tt_global_entry, common);
-
- kfree(tt_global_entry);
-}
-
+/**
+ * batadv_tt_global_entry_free_ref - decrement the refcounter for a
+ * tt_global_entry and possibly free it
+ * @tt_global_entry: the object to free
+ */
static void
batadv_tt_global_entry_free_ref(struct batadv_tt_global_entry *tt_global_entry)
{
if (atomic_dec_and_test(&tt_global_entry->common.refcount)) {
batadv_tt_global_del_orig_list(tt_global_entry);
- call_rcu(&tt_global_entry->common.rcu,
- batadv_tt_global_entry_free_rcu);
+ kfree_rcu(tt_global_entry, common.rcu);
}
}
--
1.8.1.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: don't use call_rcu if not needed
2013-05-06 19:39 [B.A.T.M.A.N.] [PATCH] batman-adv: don't use call_rcu if not needed Antonio Quartulli
@ 2013-05-06 19:42 ` Antonio Quartulli
2013-05-06 20:29 ` Marek Lindner
1 sibling, 0 replies; 3+ messages in thread
From: Antonio Quartulli @ 2013-05-06 19:42 UTC (permalink / raw)
To: b.a.t.m.a.n
[-- Attachment #1: Type: text/plain, Size: 858 bytes --]
On Mon, May 06, 2013 at 09:39:52PM +0200, Antonio Quartulli wrote:
> batadv_tt_global_entry_free_ref uses call_rcu to schedule a
> function which will only free the global entry itself.
>
> For this reason call_rcu is useless and kfree_rcu can be
> used to simplify the code.
>
> Signed-off-by: Antonio Quartulli <ordex@autistici.org>
> ---
> compat.c | 11 +++++++++++
> translation-table.c | 20 ++++++--------------
> 2 files changed, 17 insertions(+), 14 deletions(-)
>
> diff --git a/compat.c b/compat.c
> index 1f3a39d..6226f81 100644
> --- a/compat.c
> +++ b/compat.c
> @@ -27,6 +27,17 @@
>
> #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0)
This compat code has not been tested because of lack of kernels...
Cheers,
--
Antonio Quartulli
..each of us alone is worth nothing..
Ernesto "Che" Guevara
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: don't use call_rcu if not needed
2013-05-06 19:39 [B.A.T.M.A.N.] [PATCH] batman-adv: don't use call_rcu if not needed Antonio Quartulli
2013-05-06 19:42 ` Antonio Quartulli
@ 2013-05-06 20:29 ` Marek Lindner
1 sibling, 0 replies; 3+ messages in thread
From: Marek Lindner @ 2013-05-06 20:29 UTC (permalink / raw)
To: The list for a Better Approach To Mobile Ad-hoc Networking
On Tuesday, May 07, 2013 03:39:52 Antonio Quartulli wrote:
> +/**
> + * batadv_tt_global_entry_free_ref - decrement the refcounter for a
> + * tt_global_entry and possibly free it
> + * @tt_global_entry: the object to free
> + */
> static void
> batadv_tt_global_entry_free_ref(struct batadv_tt_global_entry
> *tt_global_entry) {
> if (atomic_dec_and_test(&tt_global_entry->common.refcount)) {
> batadv_tt_global_del_orig_list(tt_global_entry);
> - call_rcu(&tt_global_entry->common.rcu,
> - batadv_tt_global_entry_free_rcu);
> + kfree_rcu(tt_global_entry, common.rcu);
> }
> }
You are replacing 2 container_of() calls with a single one. If you are sure
that works why doesn't the compat code do that same ?
Cheers,
Marek
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-05-06 20:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-06 19:39 [B.A.T.M.A.N.] [PATCH] batman-adv: don't use call_rcu if not needed Antonio Quartulli
2013-05-06 19:42 ` Antonio Quartulli
2013-05-06 20:29 ` Marek Lindner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox