From: Antonio Quartulli <ordex@autistici.org>
To: The list for a Better Approach To Mobile Ad-hoc Networking
<b.a.t.m.a.n@lists.open-mesh.org>
Subject: Re: [B.A.T.M.A.N.] [PATCHv2 1/4] batman-adv: add reference counting for type batadv_tt_orig_list_entry
Date: Sat, 30 Jun 2012 14:08:42 +0200 [thread overview]
Message-ID: <20120630120842.GA2161@ritirata.org> (raw)
In-Reply-To: <201206301155.25761.lindner_marek@yahoo.de>
[-- Attachment #1: Type: text/plain, Size: 1889 bytes --]
On Sat, Jun 30, 2012 at 11:55:25AM +0200, Marek Lindner wrote:
> On Wednesday, June 27, 2012 10:23:04 Antonio Quartulli wrote:
> > @@ -639,12 +641,17 @@ batadv_tt_global_entry_has_orig(const struct
> > batadv_tt_global_entry *entry, rcu_read_lock();
> > head = &entry->orig_list;
> > hlist_for_each_entry_rcu(tmp_orig_entry, node, head, list) {
> > - if (tmp_orig_entry->orig_node == orig_node) {
> > - found = true;
> > - break;
> > - }
> > + if (tmp_orig_entry->orig_node != orig_node)
> > + continue;
> > + if (!atomic_inc_not_zero(&tmp_orig_entry->refcount))
> > + continue;
> > +
> > + found = true;
> > + batadv_tt_orig_list_entry_free_ref(tmp_orig_entry);
>
> Instead of having this weird increment and immediate decrement this patch
> should add a general "orig_entry_get" / "orig_entry_find" function like we do
> everywhere else. Check the following functions to get an idea:
> * batadv_primary_if_get_selected()
> * batadv_orig_node_get_router()
> * batadv_tt_hash_find()
>
Well, actually that is what I implemented in patch 2/4 (ok, I'll fix the
function names to reflect what we already have). In this patch I simply tried to
implement refcounting without changing too much code.
By the way, I will introduce a get function with this patch directly.
>
> > @@ -663,6 +670,7 @@ batadv_tt_global_add_orig_entry(struct
> > batadv_tt_global_entry *tt_global_entry, atomic_inc(&orig_node->tt_size);
> > orig_entry->orig_node = orig_node;
> > orig_entry->ttvn = ttvn;
> > + atomic_set(&orig_entry->refcount, 0);
>
> This looks extremely broken. We init with 0, never increase the counter and
> when we should free, we decrease first before checking if it is 0 ?
>
definitely broken. Will fix it!
Thank you,
--
Antonio Quartulli
..each of us alone is worth nothing..
Ernesto "Che" Guevara
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2012-06-30 12:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-27 8:23 [B.A.T.M.A.N.] [PATCHv2 0/5] new feature: Speedy Join 2012-06-27 Antonio Quartulli
2012-06-27 8:23 ` [B.A.T.M.A.N.] [PATCHv2 1/4] batman-adv: add reference counting for type batadv_tt_orig_list_entry Antonio Quartulli
2012-06-30 9:55 ` Marek Lindner
2012-06-30 12:08 ` Antonio Quartulli [this message]
2012-06-27 8:23 ` [B.A.T.M.A.N.] [PATCHv2 2/4] batman-adv: implement batadv_tt_global_entry_get_orig() Antonio Quartulli
2012-06-30 9:56 ` Marek Lindner
2012-06-27 8:23 ` [B.A.T.M.A.N.] [PATCHv2 3/4] batman-adv: detect not yet announced clients Antonio Quartulli
2012-06-30 10:01 ` Marek Lindner
2012-06-30 12:12 ` Antonio Quartulli
2012-06-27 8:23 ` [B.A.T.M.A.N.] [PATCHv2 4/4] batman-adv: change interface_rx to get orig node Antonio Quartulli
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=20120630120842.GA2161@ritirata.org \
--to=ordex@autistici.org \
--cc=b.a.t.m.a.n@lists.open-mesh.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