All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Antonio Quartulli <a@unstable.cc>
Cc: b.a.t.m.a.n@lists.open-mesh.org
Subject: Re: [B.A.T.M.A.N.] [PATCH 4/4] batman-adv: debugfs: Add netns support
Date: Thu, 28 Jan 2016 02:40:07 +0100	[thread overview]
Message-ID: <20160128014007.GA28633@lunn.ch> (raw)
In-Reply-To: <20160128012807.GA22112@prodigo.lan>

On Thu, Jan 28, 2016 at 09:28:07AM +0800, Antonio Quartulli wrote:
> On Wed, Jan 20, 2016 at 06:48:30PM +0100, Andrew Lunn wrote:
> 
> [...]
> 
> > +static DEFINE_MUTEX(batadv_debugfs_ns_mutex);
> 
> [...]
> 
> > +static void batadv_debugfs_ns_put(struct net *net)
> > +{
> > +	struct batadv_debugfs_ns_entry *ns_entry;
> > +
> > +	mutex_lock(&batadv_debugfs_ns_mutex);
> > +	list_for_each_entry(ns_entry, &batadv_debugfs_ns, link) {
> > +		if (ns_entry->net == net) {
> > +			kref_put(&ns_entry->refcount, batadv_ns_entry_release);
> > +			break;
> > +		}
> > +	}
> > +	mutex_unlock(&batadv_debugfs_ns_mutex);
> > +}
> >  
> 
> Andrew, is there any particular reason why in this case we use a mutex instead
> of a spinlock + RCU ? I imagine it is something related to debugfs..or just to
> make the code simpler as we don't really require a full-blown RCU strategy ?
 
I just wanted it to be KISS. We are on a very slow path, only called
when interfaces are added and removed. Keeping it KISS makes it easier
to review, make sure i have an unlock for every lock, etc. It is also
what is the kref documentation suggests.
 
> >  int batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface)
> >  {
> > +	char *name = hard_iface->net_dev->name;
> > +	struct net *net = dev_net(hard_iface->net_dev);
> 
> here we should respect David's inverted Christmas tree rule :)

Yes, i will change this.

> >  	struct batadv_debuginfo **bat_debug;
> > +	struct dentry *debugfs_ns_dir;
> >  	struct dentry *file;
> >  
> >  	if (!batadv_debugfs)
> >  		goto out;
> >  
> > -	hard_iface->debug_dir = debugfs_create_dir(hard_iface->net_dev->name,
> > -						   batadv_debugfs);
> 
> how about:
> 
> 	debugfs_ns_dir = batadv_debugfs;
> 
> > +	if (net != &init_net) {
> > +		debugfs_ns_dir = batadv_debugfs_ns_get(net);
> > +		if (!debugfs_ns_dir)
> > +			goto out;
> 	}
> 
> 	hard_iface->debug_dir = debugfs_create_dir(name, debugfs_ns_dir);
> 
> isn't it nicer? :)

O.K, i will rearrange.

     Andrew

  reply	other threads:[~2016-01-28  1:40 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-20 17:48 [B.A.T.M.A.N.] [PATCH 0/4] batman-adv: Add network name space support Andrew Lunn
2016-01-20 17:48 ` [B.A.T.M.A.N.] [PATCH 1/4] batman-adv: NETIF_F_NETNS_LOCAL feature to prevent netns moves Andrew Lunn
2016-01-23  2:06   ` Antonio Quartulli
2016-01-23 17:20     ` Andrew Lunn
2016-01-24  6:19       ` Antonio Quartulli
2016-01-24 10:42         ` Antonio Quartulli
2016-01-24 16:46           ` Andrew Lunn
2016-01-24 11:01   ` Antonio Quartulli
2016-01-20 17:48 ` [B.A.T.M.A.N.] [PATCH 2/4] batman-adv: Create batman soft interfaces within correct netns Andrew Lunn
2016-01-25  3:28   ` Antonio Quartulli
2016-01-25 13:12     ` Andrew Lunn
2016-01-26  5:43       ` Antonio Quartulli
2016-01-26  5:55   ` Antonio Quartulli
2016-01-31 13:26   ` Sven Eckelmann
2016-01-20 17:48 ` [B.A.T.M.A.N.] [PATCH 3/4] batman-adv: Handle parent interfaces in a different netns Andrew Lunn
2016-01-26 12:53   ` Antonio Quartulli
2016-01-26 13:25     ` Sven Eckelmann
2016-01-27 10:13   ` Sven Eckelmann
2016-01-27 10:44     ` Antonio Quartulli
2016-02-01  2:57     ` Antonio Quartulli
2016-02-02  2:11       ` Andrew Lunn
2016-01-31 13:26   ` Sven Eckelmann
2016-01-20 17:48 ` [B.A.T.M.A.N.] [PATCH 4/4] batman-adv: debugfs: Add netns support Andrew Lunn
2016-01-28  1:28   ` Antonio Quartulli
2016-01-28  1:40     ` Andrew Lunn [this message]
2016-01-28  2:29       ` Antonio Quartulli
2016-01-31 13:26   ` Sven Eckelmann
2016-01-28  2:59 ` [B.A.T.M.A.N.] [PATCH 0/4] batman-adv: Add network name space support Antonio Quartulli
2016-01-28  3:50   ` Andrew Lunn
2016-01-31 13:26 ` Sven Eckelmann
2016-02-12 15:57   ` Sven Eckelmann

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=20160128014007.GA28633@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=a@unstable.cc \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.