From nobody Mon Feb 9 23:16:04 2026 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 315EF192B6E for ; Fri, 23 Aug 2024 17:31:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724434318; cv=none; b=P9zCGp7lbX9mCBKZOHdK2jPBoYyzGM+x9/otTiaVXMGj8g5++0v279tFOASWFiRYG8MfXttetTcT5w1YS6DW+ckIBIQJIDFUL7nlLH7mmY5SEc6tMeg1Ac5AYezABC6Pix3ZSoM8r8UOIrTg/hNIeM+BmbsR1EtsAgH5LXNgEW0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724434318; c=relaxed/simple; bh=x08ZrLW3d91mrWZQmC/v9H7iJRa473+4x/SsWYtS3JE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SsssUIItGMIzn6wWDiJG6WP7qBe6kr8ey4pwV51Wc9JzDuSlH6kVH7Tu6azDByL8rQN2ewS9zZ4UvjNM5MbkzYpyIr8aduvKYYi6mV3wufpQUswuFg9uyzHjcwr2d5zlA557aix4JxisYXUeM3n6DLAKHmA7vzZVd0j0GXwe/W4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=UDZ0sT8u; arc=none smtp.client-ip=209.85.210.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="UDZ0sT8u" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-71433cba1b7so1811115b3a.0 for ; Fri, 23 Aug 2024 10:31:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1724434316; x=1725039116; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IoqQBySxLV4Sefg/kJRVr1Dr3C923zx/iiQfn4tblTE=; b=UDZ0sT8u5MrIFsQ3wnGp9F9y8pQUiZjszYOkWFxo0DmRD7PgI+tWFNlusmmu2kUoI4 7Y51sqGcrLLr9mdv95q3Xg5gPbYTJJwQh280N/zECe56Ppl2iIuY2WwaGeMFHAFrTixS fL8fumpgh/G5j6qj65gnWQugCyPUtzs5Zxseo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724434316; x=1725039116; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IoqQBySxLV4Sefg/kJRVr1Dr3C923zx/iiQfn4tblTE=; b=I0aUSAXd1zMGToGxTAN0qFQeOJCT9H59E3WwQ4ct9mtFfE5PLF80kg0xHoa8FoZgLw kL1nrFW2QCGlTlnqfgZ2RrOREWYl3iRgV4DtAuSIQ/EzRlXabBx3ofcQq6bWYfrtBWgu 79F44+4XNyDAOhbnRq1QceB5BuMdaRpnwgI8HHDlX/MxW6PVxYmUdr3vn+3S8aTqGOpG zFHxiDxnss6MUG1lAYKtMBI+bSBSmW44EPFBJ1o3xjkNJ+N38lqBajd6AbVHk+0vkegD XbHBCmd1XkRKZ4bAANzjEWh4KqATHFYU9G622yIroQ6th32gbr+cVRbC6SUw6nxtPwLf fHOQ== X-Forwarded-Encrypted: i=1; AJvYcCXhGX2g6XqVBxMQUGy8zVWn7qlTy8w97cu3L+yuNhyOEIa0Uprz7Fh4vaHyIiN54I9E7r2oq6j58dHHWI8=@vger.kernel.org X-Gm-Message-State: AOJu0Yx2BEkkIRzihAxpf77rfHeHVBVoOnx/1OeE/Z/iIHocGQgR1zgB Hw+8w+gnuHCzqAFv9V31eMoqEnpH71ZK7s/LN+UGkiNyHtLiBxk4y6cHvpLOt50= X-Google-Smtp-Source: AGHT+IHXsgl2NQYO+yMV9X1gIfvGuclsqseoRzkfOcO3p7twoiEGni5X0dIXcScV5If78qjNaxucOA== X-Received: by 2002:a05:6a00:3e2a:b0:710:5605:a986 with SMTP id d2e1a72fcca58-714454098b9mr3730824b3a.0.1724434316322; Fri, 23 Aug 2024 10:31:56 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7143430964fsm3279624b3a.150.2024.08.23.10.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 10:31:56 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: amritha.nambiar@intel.com, sridhar.samudrala@intel.com, sdf@fomichev.me, peter@typeblog.net, m2shafiei@uwaterloo.ca, bjorn@rivosinc.com, hch@infradead.org, willy@infradead.org, willemdebruijn.kernel@gmail.com, skhawaja@google.com, kuba@kernel.org, Martin Karsten , Joe Damato , Alexander Viro , Christian Brauner , Jan Kara , linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next 5/6] eventpoll: Control irq suspension for prefer_busy_poll Date: Fri, 23 Aug 2024 17:30:56 +0000 Message-Id: <20240823173103.94978-6-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823173103.94978-1-jdamato@fastly.com> References: <20240823173103.94978-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Martin Karsten 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 Co-developed-by: Joe Damato Signed-off-by: Joe Damato Tested-by: Joe Damato Tested-by: Martin Karsten --- rfc -> v1: - move irq resume code from ep_free to a helper which either resumes IRQs or does nothing if !defined(CONFIG_NET_RX_BUSY_POLL). fs/eventpoll.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index cc47f72005ed..5dbe717c06b4 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -457,6 +457,8 @@ static bool ep_busy_loop(struct eventpoll *ep, int nonb= lock) * it back in when we have moved a socket with a valid NAPI * ID onto the ready list. */ + if (prefer_busy_poll) + napi_resume_irqs(napi_id); ep->napi_id =3D 0; return false; } @@ -540,6 +542,22 @@ static long ep_eventpoll_bp_ioctl(struct file *file, u= nsigned int cmd, } } =20 +static void ep_suspend_napi_irqs(struct eventpoll *ep) +{ + unsigned int napi_id =3D READ_ONCE(ep->napi_id); + + if (napi_id >=3D MIN_NAPI_ID && READ_ONCE(ep->prefer_busy_poll)) + napi_suspend_irqs(napi_id); +} + +static void ep_resume_napi_irqs(struct eventpoll *ep) +{ + unsigned int napi_id =3D READ_ONCE(ep->napi_id); + + if (napi_id >=3D MIN_NAPI_ID && READ_ONCE(ep->prefer_busy_poll)) + napi_resume_irqs(napi_id); +} + #else =20 static inline bool ep_busy_loop(struct eventpoll *ep, int nonblock) @@ -557,6 +575,13 @@ static long ep_eventpoll_bp_ioctl(struct file *file, u= nsigned int cmd, return -EOPNOTSUPP; } =20 +static void ep_suspend_napi_irqs(struct eventpoll *ep) +{ +} + +static void ep_resume_napi_irqs(struct eventpoll *ep) +{ +} #endif /* CONFIG_NET_RX_BUSY_POLL */ =20 /* @@ -788,6 +813,7 @@ static bool ep_refcount_dec_and_test(struct eventpoll *= ep) =20 static void ep_free(struct eventpoll *ep) { + ep_resume_napi_irqs(ep); mutex_destroy(&ep->mtx); free_uid(ep->user); wakeup_source_unregister(ep->ws); @@ -2005,8 +2031,10 @@ static int ep_poll(struct eventpoll *ep, struct epol= l_event __user *events, * trying again in search of more luck. */ res =3D ep_send_events(ep, events, maxevents); - if (res) + if (res) { + ep_suspend_napi_irqs(ep); return res; + } } =20 if (timed_out) --=20 2.25.1