netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* preempting while holding rtnl_lock
@ 2011-07-14 21:15 Flavio Leitner
  2011-07-14 23:06 ` Ben Hutchings
  0 siblings, 1 reply; 2+ messages in thread
From: Flavio Leitner @ 2011-07-14 21:15 UTC (permalink / raw)
  To: netdev


Hi,

I was reviewing driver sources and found that
ethtool ops holds rtnl_lock() and there are few
drivers (for example: tg3, bnx2) that use napi_disable()
in this context.

/**     
 *      napi_disable - prevent NAPI from scheduling
 *      @n: napi context
 *              
 * Stop NAPI from being scheduled on this context.
 * Waits till any outstanding processing completes.
 */
static inline void napi_disable(struct napi_struct *n)
{
        set_bit(NAPI_STATE_DISABLE, &n->state);
        while (test_and_set_bit(NAPI_STATE_SCHED, &n->state))
                msleep(1);
        clear_bit(NAPI_STATE_DISABLE, &n->state);
}

The msleep() above will preempt.  I believe this is wrong.
See the functions below as examples:
bnx2_set_ringparam()
+ bnx2_change_ring_size()
  + bnx2_netif_stop()
    + bnx2_napi_disable()
      + napi_disable()


+ tg3_change_mtu() = ndo_change_mtu
  + tg3_netif_stop()
    + tg3_napi_disable()
      + napi_disable()

What am I missing?
thanks,
fbl

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: preempting while holding rtnl_lock
  2011-07-14 21:15 preempting while holding rtnl_lock Flavio Leitner
@ 2011-07-14 23:06 ` Ben Hutchings
  0 siblings, 0 replies; 2+ messages in thread
From: Ben Hutchings @ 2011-07-14 23:06 UTC (permalink / raw)
  To: Flavio Leitner; +Cc: netdev

On Thu, 2011-07-14 at 18:15 -0300, Flavio Leitner wrote:
> Hi,
> 
> I was reviewing driver sources and found that
> ethtool ops holds rtnl_lock() and there are few
> drivers (for example: tg3, bnx2) that use napi_disable()
> in this context.
[...]
> The msleep() above will preempt.  I believe this is wrong.
[...]
> What am I missing?

The RTNL lock is a mutex so it's OK to sleep (but preferably not very
long) while holding it.

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-07-14 23:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-14 21:15 preempting while holding rtnl_lock Flavio Leitner
2011-07-14 23:06 ` Ben Hutchings

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).