Skip to content

Commit 364b605

Browse files
edumazetdavem330
authored andcommitted
net: busy-poll: return busypolling status to drivers
NAPI drivers use napi_complete_done() or napi_complete() when they drained RX ring and right before re-enabling device interrupts. In busy polling, we can avoid interrupts being delivered since we are polling RX ring in a controlled loop. Drivers can chose to use napi_complete_done() return value to reduce interrupts overhead while busy polling is active. This is optional, legacy drivers should work fine even if not updated. Signed-off-by: Eric Dumazet <[email protected]> Cc: Willem de Bruijn <[email protected]> Cc: Adam Belay <[email protected]> Cc: Tariq Toukan <[email protected]> Cc: Yuval Mintz <[email protected]> Cc: Ariel Elior <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 21cb84c commit 364b605

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

include/linux/netdevice.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,16 +463,17 @@ static inline bool napi_reschedule(struct napi_struct *napi)
463463
return false;
464464
}
465465

466-
void __napi_complete(struct napi_struct *n);
467-
void napi_complete_done(struct napi_struct *n, int work_done);
466+
bool __napi_complete(struct napi_struct *n);
467+
bool napi_complete_done(struct napi_struct *n, int work_done);
468468
/**
469469
* napi_complete - NAPI processing complete
470470
* @n: NAPI context
471471
*
472472
* Mark NAPI processing as complete.
473473
* Consider using napi_complete_done() instead.
474+
* Return false if device should avoid rearming interrupts.
474475
*/
475-
static inline void napi_complete(struct napi_struct *n)
476+
static inline bool napi_complete(struct napi_struct *n)
476477
{
477478
return napi_complete_done(n, 0);
478479
}

net/core/dev.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4898,23 +4898,24 @@ void __napi_schedule_irqoff(struct napi_struct *n)
48984898
}
48994899
EXPORT_SYMBOL(__napi_schedule_irqoff);
49004900

4901-
void __napi_complete(struct napi_struct *n)
4901+
bool __napi_complete(struct napi_struct *n)
49024902
{
49034903
BUG_ON(!test_bit(NAPI_STATE_SCHED, &n->state));
49044904

49054905
/* Some drivers call us directly, instead of calling
49064906
* napi_complete_done().
49074907
*/
49084908
if (unlikely(test_bit(NAPI_STATE_IN_BUSY_POLL, &n->state)))
4909-
return;
4909+
return false;
49104910

49114911
list_del_init(&n->poll_list);
49124912
smp_mb__before_atomic();
49134913
clear_bit(NAPI_STATE_SCHED, &n->state);
4914+
return true;
49144915
}
49154916
EXPORT_SYMBOL(__napi_complete);
49164917

4917-
void napi_complete_done(struct napi_struct *n, int work_done)
4918+
bool napi_complete_done(struct napi_struct *n, int work_done)
49184919
{
49194920
unsigned long flags;
49204921

@@ -4926,7 +4927,7 @@ void napi_complete_done(struct napi_struct *n, int work_done)
49264927
*/
49274928
if (unlikely(n->state & (NAPIF_STATE_NPSVC |
49284929
NAPIF_STATE_IN_BUSY_POLL)))
4929-
return;
4930+
return false;
49304931

49314932
if (n->gro_list) {
49324933
unsigned long timeout = 0;
@@ -4948,6 +4949,7 @@ void napi_complete_done(struct napi_struct *n, int work_done)
49484949
__napi_complete(n);
49494950
local_irq_restore(flags);
49504951
}
4952+
return true;
49514953
}
49524954
EXPORT_SYMBOL(napi_complete_done);
49534955

0 commit comments

Comments
 (0)