Skip to content

Commit 147cb25

Browse files
committed
eventpoll: Control irq suspension for prefer_busy_poll
JIRA: https://issues.redhat.com/browse/RHEL-77189 Upstream Status: linux.git commit 8a6de26 Author: Martin Karsten <mkarsten@uwaterloo.ca> Date: Sat Nov 9 05:02:34 2024 +0000 eventpoll: Control irq suspension for prefer_busy_poll When events are reported to userland and prefer_busy_poll is set, irqs are temporarily suspended using napi_suspend_irqs. If no events are found and ep_poll would go to sleep, irq suspension is cancelled using napi_resume_irqs. Signed-off-by: Martin Karsten <mkarsten@uwaterloo.ca> Co-developed-by: Joe Damato <jdamato@fastly.com> Signed-off-by: Joe Damato <jdamato@fastly.com> Tested-by: Joe Damato <jdamato@fastly.com> Tested-by: Martin Karsten <mkarsten@uwaterloo.ca> Acked-by: Stanislav Fomichev <sdf@fomichev.me> Reviewed-by: Sridhar Samudrala <sridhar.samudrala@intel.com> Link: https://patch.msgid.link/20241109050245.191288-5-jdamato@fastly.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Antoine Tenart <atenart@redhat.com>
1 parent aa15fa3 commit 147cb25

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

fs/eventpoll.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,8 @@ static bool ep_busy_loop(struct eventpoll *ep, int nonblock)
457457
* it back in when we have moved a socket with a valid NAPI
458458
* ID onto the ready list.
459459
*/
460+
if (prefer_busy_poll)
461+
napi_resume_irqs(napi_id);
460462
ep->napi_id = 0;
461463
return false;
462464
}
@@ -540,6 +542,22 @@ static long ep_eventpoll_bp_ioctl(struct file *file, unsigned int cmd,
540542
}
541543
}
542544

545+
static void ep_suspend_napi_irqs(struct eventpoll *ep)
546+
{
547+
unsigned int napi_id = READ_ONCE(ep->napi_id);
548+
549+
if (napi_id >= MIN_NAPI_ID && READ_ONCE(ep->prefer_busy_poll))
550+
napi_suspend_irqs(napi_id);
551+
}
552+
553+
static void ep_resume_napi_irqs(struct eventpoll *ep)
554+
{
555+
unsigned int napi_id = READ_ONCE(ep->napi_id);
556+
557+
if (napi_id >= MIN_NAPI_ID && READ_ONCE(ep->prefer_busy_poll))
558+
napi_resume_irqs(napi_id);
559+
}
560+
543561
#else
544562

545563
static inline bool ep_busy_loop(struct eventpoll *ep, int nonblock)
@@ -557,6 +575,14 @@ static long ep_eventpoll_bp_ioctl(struct file *file, unsigned int cmd,
557575
return -EOPNOTSUPP;
558576
}
559577

578+
static void ep_suspend_napi_irqs(struct eventpoll *ep)
579+
{
580+
}
581+
582+
static void ep_resume_napi_irqs(struct eventpoll *ep)
583+
{
584+
}
585+
560586
#endif /* CONFIG_NET_RX_BUSY_POLL */
561587

562588
/*
@@ -788,6 +814,7 @@ static bool ep_refcount_dec_and_test(struct eventpoll *ep)
788814

789815
static void ep_free(struct eventpoll *ep)
790816
{
817+
ep_resume_napi_irqs(ep);
791818
mutex_destroy(&ep->mtx);
792819
free_uid(ep->user);
793820
wakeup_source_unregister(ep->ws);
@@ -2005,8 +2032,11 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
20052032
* trying again in search of more luck.
20062033
*/
20072034
res = ep_send_events(ep, events, maxevents);
2008-
if (res)
2035+
if (res) {
2036+
if (res > 0)
2037+
ep_suspend_napi_irqs(ep);
20092038
return res;
2039+
}
20102040
}
20112041

20122042
if (timed_out)

0 commit comments

Comments
 (0)