Skip to content

Commit 6fbc05e

Browse files
ecree-solarflareJakub Kicinski
authored andcommitted
sfc: do ARFS expiry work occasionally even without NAPI poll
If there's no traffic on a channel, its ARFS expiry work will never get scheduled by efx_poll() as that isn't being run. So make efx_filter_rfs_expire() reschedule itself to run after 30 seconds. Signed-off-by: Edward Cree <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ca70bd4 commit 6fbc05e

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

drivers/net/ethernet/sfc/efx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ static int efx_poll(struct napi_struct *napi, int budget)
355355

356356
#ifdef CONFIG_RFS_ACCEL
357357
/* Perhaps expire some ARFS filters */
358-
schedule_work(&channel->filter_work);
358+
mod_delayed_work(system_wq, &channel->filter_work, 0);
359359
#endif
360360

361361
/* There is no race here; although napi_disable() will
@@ -487,7 +487,7 @@ efx_alloc_channel(struct efx_nic *efx, int i, struct efx_channel *old_channel)
487487
}
488488

489489
#ifdef CONFIG_RFS_ACCEL
490-
INIT_WORK(&channel->filter_work, efx_filter_rfs_expire);
490+
INIT_DELAYED_WORK(&channel->filter_work, efx_filter_rfs_expire);
491491
#endif
492492

493493
rx_queue = &channel->rx_queue;
@@ -533,7 +533,7 @@ efx_copy_channel(const struct efx_channel *old_channel)
533533
memset(&rx_queue->rxd, 0, sizeof(rx_queue->rxd));
534534
timer_setup(&rx_queue->slow_fill, efx_rx_slow_fill, 0);
535535
#ifdef CONFIG_RFS_ACCEL
536-
INIT_WORK(&channel->filter_work, efx_filter_rfs_expire);
536+
INIT_DELAYED_WORK(&channel->filter_work, efx_filter_rfs_expire);
537537
#endif
538538

539539
return channel;
@@ -1994,7 +1994,7 @@ static void efx_remove_filters(struct efx_nic *efx)
19941994
struct efx_channel *channel;
19951995

19961996
efx_for_each_channel(channel, efx) {
1997-
flush_work(&channel->filter_work);
1997+
cancel_delayed_work_sync(&channel->filter_work);
19981998
kfree(channel->rps_flow_id);
19991999
}
20002000
#endif

drivers/net/ethernet/sfc/efx.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,17 @@ int efx_filter_rfs(struct net_device *net_dev, const struct sk_buff *skb,
169169
bool __efx_filter_rfs_expire(struct efx_channel *channel, unsigned int quota);
170170
static inline void efx_filter_rfs_expire(struct work_struct *data)
171171
{
172-
struct efx_channel *channel = container_of(data, struct efx_channel,
173-
filter_work);
174-
unsigned int time = jiffies - channel->rfs_last_expiry, quota;
172+
struct delayed_work *dwork = to_delayed_work(data);
173+
struct efx_channel *channel;
174+
unsigned int time, quota;
175175

176+
channel = container_of(dwork, struct efx_channel, filter_work);
177+
time = jiffies - channel->rfs_last_expiry;
176178
quota = channel->rfs_filter_count * time / (30 * HZ);
177179
if (quota > 20 && __efx_filter_rfs_expire(channel, min(channel->rfs_filter_count, quota)))
178180
channel->rfs_last_expiry += time;
181+
/* Ensure we do more work eventually even if NAPI poll is not happening */
182+
schedule_delayed_work(dwork, 30 * HZ);
179183
}
180184
#define efx_filter_rfs_enabled() 1
181185
#else

drivers/net/ethernet/sfc/net_driver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ struct efx_channel {
501501
unsigned int rfs_expire_index;
502502
unsigned int n_rfs_succeeded;
503503
unsigned int n_rfs_failed;
504-
struct work_struct filter_work;
504+
struct delayed_work filter_work;
505505
#define RPS_FLOW_ID_INVALID 0xFFFFFFFF
506506
u32 *rps_flow_id;
507507
#endif

0 commit comments

Comments
 (0)