sfc: replace spinlocks with bit ops for busy poll locking
Subsystems (3)
PATCH 1/1 sfc: replace spinlocks with bit ops for busy poll locking
From: Bert Kenward <[email protected]>
This patch reduces the overhead of locking for busy poll. Previously the state was protected by a lock, whereas now it's manipulated solely with atomic operations.
--- drivers/net/ethernet/sfc/efx.c | 31 +++++--- drivers/net/ethernet/sfc/net_driver.h | 129 +++++++++++++++------------------- 2 files changed, 78 insertions(+), 82 deletions(-)
drivers/net/ethernet/sfc/efx.c +22 -9
@@ -205,7 +205,7 @@ static void efx_remove_channel(struct efx_channel *channel);static void efx_remove_channels (struct efx_nic *efx);static const struct efx_channel_type efx_default_channel_type;static void efx_remove_port (struct efx_nic *efx); -static void efx_init_napi_channel (struct efx_channel *channel); +static int efx_init_napi_channel (struct efx_channel *channel);static void efx_fini_napi (struct efx_nic *efx);static void efx_fini_napi_channel (struct efx_channel *channel);static void efx_fini_struct (struct efx_nic *efx);
@@ -834,7 +834,9 @@ efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries) rc =efx_probe_channel (channel);if (rc) goto rollback; -efx_init_napi_channel (efx->channel[i]); + rc =efx_init_napi_channel (efx->channel[i]); +if (rc) + goto rollback; } out:
@@ -2054,7 +2056,7 @@ static int efx_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)* **************************************************************************/ -static void efx_init_napi_channel (struct efx_channel *channel) +static int efx_init_napi_channel (struct efx_channel *channel) {struct efx_nic *efx = channel->efx;
@@ -2062,15 +2064,23 @@ static void efx_init_napi_channel(struct efx_channel *channel)netif_napi_add (channel->napi_dev, &channel->napi_str, efx_poll, napi_weight);napi_hash_add (&channel->napi_str); -efx_channel_init_lock (channel); +efx_channel_busy_poll_init (channel); + +return 0 ; } -static void efx_init_napi (struct efx_nic *efx) +static int efx_init_napi (struct efx_nic *efx) {struct efx_channel *channel; +int rc; -efx_for_each_channel (channel, efx) -efx_init_napi_channel (channel); +efx_for_each_channel (channel, efx) { + rc =efx_init_napi_channel (channel); +if (rc) +return rc; + } + +return 0 ; }static void efx_fini_napi_channel (struct efx_channel *channel)
@@ -2125,7 +2135,7 @@ static int efx_busy_poll(struct napi_struct *napi)if (!netif_running (efx->net_dev))return LL_FLUSH_FAILED ; -if (!efx_channel_lock_poll (channel)) +if (!efx_channel_try_lock_poll (channel))return LL_FLUSH_BUSY ; old_rx_packets = channel->rx_queue.rx_packets;
@@ -3061,7 +3071,9 @@ static int efx_pci_probe_main(struct efx_nic *efx)if (rc) goto fail1; -efx_init_napi (efx); + rc =efx_init_napi (efx); +if (rc) + goto fail2; rc = efx->type->init (efx);if (rc) {
@@ -3094,6 +3106,7 @@ static int efx_pci_probe_main(struct efx_nic *efx) efx->type->fini (efx); fail3:efx_fini_napi (efx); + fail2:efx_remove_all (efx); fail1:return rc;
drivers/net/ethernet/sfc/net_driver.h +56 -73
182 lines not on this page · raw message
David Miller
maintainerFrom: Shradha Shah <[email protected]>
Date: Fri, 9 Oct 2015 10:18:56 +0100
drivers/net/ethernet/sfc/efx.c static void efx_remove_channel(struct efx_channel *channel); · line 208
Quoted 3 lines
static void
efx_remove_port(struct efx_nic *efx);drivers/net/ethernet/sfc/efx.c +1
-1-static void efx_init_napi_channel (struct efx_channel *channel); +static int efx_init_napi_channel (struct efx_channel *channel);
The changes to modify the call chain to return a status code is completely unnecessary, and distracts from the core of what this patch is actually doing.
Nothing signals an error, all of these code paths return '0', so it's pointless to return a status or check such statuses.