1. 17 11月, 2016 1 次提交
    • E
      netpoll: more efficient locking · 89c4b442
      Eric Dumazet 提交于
      Callers of netpoll_poll_lock() own NAPI_STATE_SCHED
      
      Callers of netpoll_poll_unlock() have BH blocked between
      the NAPI_STATE_SCHED being cleared and poll_lock is released.
      
      We can avoid the spinlock which has no contention, and use cmpxchg()
      on poll_owner which we need to set anyway.
      
      This removes a possible lockdep violation after the cited commit,
      since sk_busy_loop() re-enables BH before calling busy_poll_stop()
      
      Fixes: 217f6974 ("net: busy-poll: allow preemption in sk_busy_loop()")
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      89c4b442
  2. 10 7月, 2016 1 次提交
  3. 06 4月, 2016 1 次提交
  4. 25 3月, 2016 1 次提交
    • B
      netpoll: Fix extra refcount release in netpoll_cleanup() · 543e3a8d
      Bjorn Helgaas 提交于
      netpoll_setup() does a dev_hold() on np->dev, the netpoll device.  If it
      fails, it correctly does a dev_put() but leaves np->dev set.  If we call
      netpoll_cleanup() after the failure, np->dev is still set so we do another
      dev_put(), which decrements the refcount an extra time.
      
      It's questionable to call netpoll_cleanup() after netpoll_setup() fails,
      but it can be difficult to find the problem, and we can easily avoid it in
      this case.  The extra decrements can lead to hangs like this:
      
        unregister_netdevice: waiting for bond0 to become free. Usage count = -3
      
      Set and clear np->dev at the points where we dev_hold() and dev_put() the
      device.
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      543e3a8d
  5. 30 9月, 2015 1 次提交
    • A
      netpoll: Drop budget parameter from NAPI polling call hierarchy · 822d54b9
      Alexander Duyck 提交于
      For some reason we were carrying the budget value around between the
      various calls to napi->poll.  If for example one of the drivers called had
      a bug in which it returned a non-zero value for work this could result in
      the budget value becoming negative.
      
      Rather than carry around a value of budget that is 0 or less we can instead
      just loop through and pass 0 to each napi->poll call.  If any driver
      returns a value for work done that is non-zero then we can report that
      driver and continue rather than allowing a bad actor to make the budget
      value negative and pass that negative value to napi->poll.
      
      Note, the only actual change here is that instead of letting budget become
      negative we are keeping it at 0 regardless of the value returned for work
      since it should not be possible for the polling routine to do any actual
      work with a budget of 0.  So if the polling routine returns a non-0 value
      we are just reporting it and continuing with a budget of 0 rather than
      letting that work value be subtracted from the budget of 0.
      Signed-off-by: NAlexander Duyck <aduyck@mirantis.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      822d54b9
  6. 24 9月, 2015 1 次提交
    • N
      netpoll: Close race condition between poll_one_napi and napi_disable · 2d8bff12
      Neil Horman 提交于
      Drivers might call napi_disable while not holding the napi instance poll_lock.
      In those instances, its possible for a race condition to exist between
      poll_one_napi and napi_disable.  That is to say, poll_one_napi only tests the
      NAPI_STATE_SCHED bit to see if there is work to do during a poll, and as such
      the following may happen:
      
      CPU0				CPU1
      ndo_tx_timeout			napi_poll_dev
       napi_disable			 poll_one_napi
        test_and_set_bit (ret 0)
      				  test_bit (ret 1)
         reset adapter		   napi_poll_routine
      
      If the adapter gets a tx timeout without a napi instance scheduled, its possible
      for the adapter to think it has exclusive access to the hardware  (as the napi
      instance is now scheduled via the napi_disable call), while the netpoll code
      thinks there is simply work to do.  The result is parallel hardware access
      leading to corrupt data structures in the driver, and a crash.
      
      Additionaly, there is another, more critical race between netpoll and
      napi_disable.  The disabled napi state is actually identical to the scheduled
      state for a given napi instance.  The implication being that, if a napi instance
      is disabled, a netconsole instance would see the napi state of the device as
      having been scheduled, and poll it, likely while the driver was dong something
      requiring exclusive access.  In the case above, its fairly clear that not having
      the rings in a state ready to be polled will cause any number of crashes.
      
      The fix should be pretty easy.  netpoll uses its own bit to indicate that that
      the napi instance is in a state of being serviced by netpoll (NAPI_STATE_NPSVC).
      We can just gate disabling on that bit as well as the sched bit.  That should
      prevent netpoll from conducting a napi poll if we convert its set bit to a
      test_and_set_bit operation to provide mutual exclusion
      
      Change notes:
      V2)
      	Remove a trailing whtiespace
      	Resubmit with proper subject prefix
      
      V3)
      	Clean up spacing nits
      Signed-off-by: NNeil Horman <nhorman@tuxdriver.com>
      CC: "David S. Miller" <davem@davemloft.net>
      CC: jmaxwell@redhat.com
      Tested-by: jmaxwell@redhat.com
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      2d8bff12
  7. 29 8月, 2015 1 次提交
  8. 14 1月, 2015 1 次提交
  9. 22 11月, 2014 2 次提交
  10. 02 9月, 2014 2 次提交
  11. 30 8月, 2014 1 次提交
  12. 25 8月, 2014 1 次提交
  13. 09 7月, 2014 1 次提交
  14. 02 4月, 2014 1 次提交
  15. 30 3月, 2014 5 次提交
  16. 27 3月, 2014 1 次提交
  17. 25 3月, 2014 1 次提交
  18. 18 3月, 2014 10 次提交
  19. 07 2月, 2014 1 次提交
  20. 22 1月, 2014 1 次提交
  21. 11 1月, 2014 1 次提交
    • J
      net: core: explicitly select a txq before doing l2 forwarding · f663dd9a
      Jason Wang 提交于
      Currently, the tx queue were selected implicitly in ndo_dfwd_start_xmit(). The
      will cause several issues:
      
      - NETIF_F_LLTX were removed for macvlan, so txq lock were done for macvlan
        instead of lower device which misses the necessary txq synchronization for
        lower device such as txq stopping or frozen required by dev watchdog or
        control path.
      - dev_hard_start_xmit() was called with NULL txq which bypasses the net device
        watchdog.
      - dev_hard_start_xmit() does not check txq everywhere which will lead a crash
        when tso is disabled for lower device.
      
      Fix this by explicitly introducing a new param for .ndo_select_queue() for just
      selecting queues in the case of l2 forwarding offload. netdev_pick_tx() was also
      extended to accept this parameter and dev_queue_xmit_accel() was used to do l2
      forwarding transmission.
      
      With this fixes, NETIF_F_LLTX could be preserved for macvlan and there's no need
      to check txq against NULL in dev_hard_start_xmit(). Also there's no need to keep
      a dedicated ndo_dfwd_start_xmit() and we can just reuse the code of
      dev_queue_xmit() to do the transmission.
      
      In the future, it was also required for macvtap l2 forwarding support since it
      provides a necessary synchronization method.
      
      Cc: John Fastabend <john.r.fastabend@intel.com>
      Cc: Neil Horman <nhorman@tuxdriver.com>
      Cc: e1000-devel@lists.sourceforge.net
      Signed-off-by: NJason Wang <jasowang@redhat.com>
      Acked-by: NNeil Horman <nhorman@tuxdriver.com>
      Acked-by: NJohn Fastabend <john.r.fastabend@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f663dd9a
  22. 03 1月, 2014 1 次提交
  23. 26 10月, 2013 1 次提交
  24. 20 9月, 2013 1 次提交
    • N
      netpoll: fix NULL pointer dereference in netpoll_cleanup · d0fe8c88
      Nikolay Aleksandrov 提交于
      I've been hitting a NULL ptr deref while using netconsole because the
      np->dev check and the pointer manipulation in netpoll_cleanup are done
      without rtnl and the following sequence happens when having a netconsole
      over a vlan and we remove the vlan while disabling the netconsole:
      	CPU 1					CPU2
      					removes vlan and calls the notifier
      enters store_enabled(), calls
      netdev_cleanup which checks np->dev
      and then waits for rtnl
      					executes the netconsole netdev
      					release notifier making np->dev
      					== NULL and releases rtnl
      continues to dereference a member of
      np->dev which at this point is == NULL
      Signed-off-by: NNikolay Aleksandrov <nikolay@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d0fe8c88
  25. 13 9月, 2013 1 次提交