public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Antonio Quartulli <ordex@autistici.org>
To: "\"Linus Lüssing\"" <linus.luessing@web.de>
Cc: b.a.t.m.a.n@lists.open-mesh.org,
	Marek Lindner <lindner_marek@yahoo.de>,
	Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Subject: Re: [B.A.T.M.A.N.] [PATCHv2 1/2] batman-adv: avoid race conditions on TT global table by counting references
Date: Thu, 18 Apr 2013 15:19:02 +0200	[thread overview]
Message-ID: <20130418131902.GG20819@ritirata.org> (raw)
In-Reply-To: <trinity-654eb65a-c1c3-48f5-9a73-23614f415e71-1366225529049@3capp-webde-bs26>

[-- Attachment #1: Type: text/plain, Size: 1627 bytes --]

On Wed, Apr 17, 2013 at 09:05:29PM +0200, "Linus Lüssing" wrote:
> Hi Antonio,
> 
> Looks good, I like the idea of using refcounting for the tt global hash. That will indeed nicely remove the ordering dependancy I introduced with my patch earlier.
> 
> > @@ -844,7 +897,17 @@ int batadv_tt_global_add(struct batadv_priv *bat_priv,
> >  
> >  		if (unlikely(hash_added != 0)) {
> >  			/* remove the reference for the hash */
> > -			batadv_tt_global_entry_free_ref(tt_global_entry);
> > +			batadv_tt_global_entry_free_ref(bat_priv,
> > +							tt_global_entry);
> > +			goto out_remove;
> > +		}
> > +
> > +		/* increase the refcounter for this new "reference to the global
> > +		 * table represented by the global entry. If the increment
> > +		 * fails remove the entry from the hash
> > +		 */
> > +		if (!atomic_inc_not_zero(&bat_priv->tt.global_refcount)) {
> > +			hlist_del_rcu(&tt_global_entry->common.hash_entry);
> >  			goto out_remove;
> >  		}
> 
> Looks like there's a spin-lock missing, we usually need to do the rcu-list-adds/dels within such a lock.
> 
> Also the ordering looks a little different compared to what we usually do. Usually we increase all the refcounting first and add things to the lists in the end. Changing the order should remove the need for an hlist_del_rcu/spin-lock in the first place.

Hi Linus,

thank you very much for the review.
However, after having properly fixed the "RCU coordination" in the clean up
path, this patch is not needed anymore.

Cheers,

-- 
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

      reply	other threads:[~2013-04-18 13:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-16 10:46 [B.A.T.M.A.N.] [PATCHv2 1/2] batman-adv: avoid race conditions on TT global table by counting references Antonio Quartulli
2013-04-16 10:46 ` [B.A.T.M.A.N.] [PATCHv2 2/2] batman-adv: schedule global entry removal earlier Antonio Quartulli
2013-04-17 19:05 ` [B.A.T.M.A.N.] [PATCHv2 1/2] batman-adv: avoid race conditions on TT global table by counting references "Linus Lüssing"
2013-04-18 13:19   ` Antonio Quartulli [this message]

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=20130418131902.GG20819@ritirata.org \
    --to=ordex@autistici.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=lindner_marek@yahoo.de \
    --cc=linus.luessing@web.de \
    --cc=siwu@hrz.tu-chemnitz.de \
    /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