Re: [ovs-dev] [PATCH 2/2] dpif-netdev: Introduce port_try_ref() to prevent a race.

2014-09-03 Thread Pravin Shelar
On Wed, Sep 3, 2014 at 1:24 PM, Alex Wang wrote: > After discussing with Pravin offline, it is good to use first get the > reference > and then access the 'port->netdev' for pmd check. > > So, use a nested if statement: > > @@ -1864,20 +1874,27 @@ pmd_load_queues(struct pmd_thread *f, > index

Re: [ovs-dev] [PATCH 2/2] dpif-netdev: Introduce port_try_ref() to prevent a race.

2014-09-03 Thread Alex Wang
After discussing with Pravin offline, it is good to use first get the reference and then access the 'port->netdev' for pmd check. So, use a nested if statement: @@ -1864,20 +1874,27 @@ pmd_load_queues(struct pmd_thread *f, index = 0; CMAP_FOR_EACH (port, node, &f->dp->ports) { -

Re: [ovs-dev] [PATCH 2/2] dpif-netdev: Introduce port_try_ref() to prevent a race.

2014-09-02 Thread Alex Wang
> > > @@ -1864,7 +1874,10 @@ pmd_load_queues(struct pmd_thread *f, > > index = 0; > > > > CMAP_FOR_EACH (port, node, &f->dp->ports) { > > -if (netdev_is_pmd(port->netdev)) { > > +/* Calls port_try_ref() to prevent the main thread > > + * from deleting the port. */

Re: [ovs-dev] [PATCH 2/2] dpif-netdev: Introduce port_try_ref() to prevent a race.

2014-09-02 Thread Pravin Shelar
On Tue, Sep 2, 2014 at 6:44 PM, Alex Wang wrote: > When pmd thread interates through all ports for queue loading, > the main thread may unreference and 'rcu-free' a port before > pmd thread take new reference of it. This could cause pmd > thread fail the reference and access freed memory later. >

[ovs-dev] [PATCH 2/2] dpif-netdev: Introduce port_try_ref() to prevent a race.

2014-09-02 Thread Alex Wang
When pmd thread interates through all ports for queue loading, the main thread may unreference and 'rcu-free' a port before pmd thread take new reference of it. This could cause pmd thread fail the reference and access freed memory later. This commit fixes this race by introducing port_try_ref()