[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090515195321.GH7745@hmsreliant.think-freely.org>
Date: Fri, 15 May 2009 15:53:21 -0400
From: Neil Horman <nhorman@...driver.com>
To: Stephen Hemminger <shemminger@...tta.com>
Cc: Eric Dumazet <dada1@...mosbay.com>, Jiri Pirko <jpirko@...hat.com>,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
netdev@...r.kernel.org, davem@...emloft.net
Subject: Re: [PATCH] dropmon: add ability to detect when hardware
dropsrxpackets
On Fri, May 15, 2009 at 11:23:45AM -0700, Stephen Hemminger wrote:
> On Fri, 15 May 2009 20:11:57 +0200
> Eric Dumazet <dada1@...mosbay.com> wrote:
>
> > Neil Horman a écrit :
> > > +static int dropmon_net_event(struct notifier_block *ev_block,
> > > + unsigned long event, void *ptr)
> > > +{
> > > + struct net_device *dev = ptr;
> > > + struct dm_hw_stat_delta *new_stat = NULL;
> > > + int found = 0;
> > > +
> > > + switch (event) {
> > > + case NETDEV_REGISTER:
> > > + new_stat = kzalloc(sizeof(struct dm_hw_stat_delta), GFP_KERNEL);
> > > +
> > > + if (!new_stat)
> > > + goto out;
> > > +
> > > + new_stat->dev = dev;
> > > + INIT_RCU_HEAD(&new_stat->rcu);
> > > + spin_lock(&trace_state_lock);
> > > + list_add_rcu(&new_stat->list, &hw_stats_list);
> > > + spin_unlock(&trace_state_lock);
> > > + break;
> > > + case NETDEV_UNREGISTER:
> > > + rcu_read_lock();
> > > + list_for_each_entry_rcu(new_stat, &hw_stats_list, list) {
> > > + if (new_stat->dev == dev)
> > > + new_stat->dev = NULL;
> > > + found = 1;
> > > + break;
> > > + }
> > > + rcu_read_unlock();
> >
> > This is racy, unless caller already owns a lock.
> >
> > If caller aleady owns a lock, you dont need :
> >
> > rcu_read_lock()
> > list_for_each_entry_rcu()
> > rcu_read_unlock();
>
> RTNL mutex is always held on notification call backs.
> Actually why is trace_state_lock needed at all? Why not
> just use the RTNL mutex?
>
Theres also a need for this mutex to protect simeoustaneous state changes to the
tracer from userspace. I suppose I could use the rtnl lock for that, but I
think this is more readable.
Neil
>
>
> --
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists