From patchwork Mon Aug 12 12:57:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13760523 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (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 2AD5E17CA1A for ; Mon, 12 Aug 2024 12:57:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723467471; cv=none; b=S6ntCeig8iezWotufUEFlFEjtdo5GBvAFlRHRlkSO0eb0DkV2z1JW0Mt1A65IM5pARVTBKyRvDwK6wrUq4uH1hM/dnkotP8yzEok6yYgFdkUVNbdw6pJCOpGvReSNhlMkWsw1Fo7CAEU22/86r8BsGv1SygcNIK/hWh2OJtdEOs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723467471; c=relaxed/simple; bh=uGO5dEJrzAGpkDGXLrC8ztAywM3dRMCy6F4elADygWk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MrGEx2+QZjhNrhXtiOm8SUXa8sKA5Zux7MuuM0/ZslTKNZIuEOzJeXpsver4+DqLryrQDKhOaRJOwh9Rne46bPXEFdOa7Y06n41o8jSQI0wVMLXN0O1fKO6Sxav0oVvQHaXSoZ+JtPliJJvTDOplDED88r5GmjEUcrnCM6uKzsk= 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=Ec759tHm; arc=none smtp.client-ip=209.85.216.51 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="Ec759tHm" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-2cb4b7fef4aso3380538a91.0 for ; Mon, 12 Aug 2024 05:57:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1723467469; x=1724072269; 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=58S4qbuyYKoKQjyHpzs28ekwRvFYt2yreo1eLG7u1fM=; b=Ec759tHmiiGhgXoUEENfBjcubXA0apvXqhwmY2HjIeK4pU4mXeTqHHRpIzpRCmZydv ZEUTnBcD/A6jnVUa2hdCfp0Wsxdetqt8g/7KVs4/H9bV1MeKqWEQFvbwtPI2P/HKRYLH B2I3+X/BFppZjTgk5y7WYuZWqm8ilH+/sg7w4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723467469; x=1724072269; 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=58S4qbuyYKoKQjyHpzs28ekwRvFYt2yreo1eLG7u1fM=; b=dA12LDXbbgtTqbxylayCT4rXZ0AxExj1LfrEphj4k4e9yuCpP/ieGlhz9e86FBkRNj lkt3b6ibmOMgIh57oIkw35RZWZ7cCCnIgTHzJ0qxLwXdZpbE9ODM5nuppW+WwyZQKqyW H7mj6oNg4XVEXRj69aXwNAIjLoEzBfufr02xI869pODbijeC/w3H84PgaWWfccqj+wTS M92jAn0zxe2wLzkGZVYKSAq6uob0FVlgpYDTc2C92uLPvbe58A2cn4k3xYldEELrFcH1 9o1UcTFiZh6kZ+5pDs2J//l7sQ+zhjLWKT6FyumxG0xcj4TKNt2MDtoBGn89sgsK/ALK 407w== X-Forwarded-Encrypted: i=1; AJvYcCUPbGc7W/2or0Sg6U1+26hiQCMlelS66VhE09yZz9fam/Uq/1tRNRdDTRNhhIuItHn/EKvY0ye2sESkY+TYmHH3TZyxP3H+huORBpGPOg== X-Gm-Message-State: AOJu0Yw1c6dNhFi4hkwFwWmPk2mfjnxgfgwlkNSDyh887u/QtnhVez4w Vw8hjODJCsYWSJWDdLryDglacg+YcspnJ/dRS3mjQoFmtHr8daVPHqla/9QkGiI= X-Google-Smtp-Source: AGHT+IGFlBi1X8/Y7i5u30ax6RMbfkRifnWc7b7YQe3Aid69JjvZ1u0IpdtiYAyCV6l+7Dbup8PUIQ== X-Received: by 2002:a17:90a:53e1:b0:2cd:40ef:4764 with SMTP id 98e67ed59e1d1-2d392510ccamr117032a91.17.1723467469481; Mon, 12 Aug 2024 05:57:49 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d1c9ca6fafsm8183368a91.34.2024.08.12.05.57.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 05:57:49 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, sdf@fomichev.me, 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: [RFC net-next 4/5] eventpoll: Trigger napi_busy_loop, if prefer_busy_poll is set Date: Mon, 12 Aug 2024 12:57:07 +0000 Message-Id: <20240812125717.413108-5-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240812125717.413108-1-jdamato@fastly.com> References: <20240812125717.413108-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Martin Karsten Setting prefer_busy_poll now leads to an effectively nonblocking iteration though napi_busy_loop, even when busy_poll_usecs is 0. Signed-off-by: Martin Karsten Co-developed-by: Joe Damato Signed-off-by: Joe Damato Tested-by: Joe Damato Tested-by: Martin Karsten --- fs/eventpoll.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index f53ca4f7fced..cc47f72005ed 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -420,7 +420,9 @@ static bool busy_loop_ep_timeout(unsigned long start_time, static bool ep_busy_loop_on(struct eventpoll *ep) { - return !!ep->busy_poll_usecs || net_busy_loop_on(); + return !!READ_ONCE(ep->busy_poll_usecs) || + READ_ONCE(ep->prefer_busy_poll) || + net_busy_loop_on(); } static bool ep_busy_loop_end(void *p, unsigned long start_time) From patchwork Mon Aug 12 12:57:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13760524 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (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 B811717D895 for ; Mon, 12 Aug 2024 12:57:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723467473; cv=none; b=JBEp1EElK7TyuulkpA7ZfK9Rjk7Q8D8HHCDSCObeIs95CLFnZMtkQL3ds3YrfwW0Nlu2v95Xhen8aZfUtmGhETjN8NyElxMfcl8y0big58/UdNjGRiq/ELDjnHLsuJ5A4rlRTH8x4X5eyuFnfbTBaRWtqGCGIEAzvBHOZ+EUgJQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723467473; c=relaxed/simple; bh=ayLYRx3QKfi6gmR7b4DhUiYvDsWYqJuL4KCn2w5LCzE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZCbPYbmNarbDsfy+27pI6+XVJWUV/6X9I62mERrd+E55Szf75kHh5DXHysZI76OLqR7Yupt58PN3kNstXiSWelJx87UzxR0Ty24MejsY2+vjQ8ZBOIVWuB7OpLWygQAepOYqCbxvSfWPUfGA2qcVp8KqEg+0BX1K4OwQ42VTrcE= 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=ubMnQW0u; arc=none smtp.client-ip=209.85.215.176 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="ubMnQW0u" Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-7c3d8f260easo1108991a12.1 for ; Mon, 12 Aug 2024 05:57:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1723467471; x=1724072271; 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=GsO15pwNsB215SzDNzNe7pDnu6o5GjMMYX4qU8sz+wY=; b=ubMnQW0uWxTuFizaWewZgJbZ97O4EkKDpmEsQFN7xS4dEszQFfFkx4eGTDO8LuJm4H 3pnCBEA+HEoUMQ+iClrGRVvOUCY9RialylxtfhtgqDeDWf8R+Vxow786n5CRWIXzw7/j i+ZDNJ/QQHrP0hL78HO7J+1cSvqk14KxFqURY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723467471; x=1724072271; 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=GsO15pwNsB215SzDNzNe7pDnu6o5GjMMYX4qU8sz+wY=; b=dG6fGe7cmS++lZS4RZp8tolZrMpUSaLSsBpvDjY/LB5pk7RpO+qnATC/cO+kC8aovy RfH+PpjIHaU+3JNeI2j7hlPgf9ohgQjoefs0SL1zW4NzAncTvFNgizs6+4SJraFWuAtx 8jboBTsdz3ROUuFoFWGgASyDt4JgvLsLB+/uDj7d1T1WE8VMs8VzlaOMJyTQqeU4bGda TaW1joZDcgGcdc4NJ9ZcWpw0w73Xq4pYgEm3qb3U8K5Jt6sx/YgBQDsQRba4aq2TFejJ KfhOq5yydWBrP9wD2rDHNkYImp/p8b/fJNUXfO7FtkpR/TdY0mqx1gpja7NGmWhzWFXn ni+Q== X-Forwarded-Encrypted: i=1; AJvYcCWmy09FypheUNy6pT2KHzhlFCLPcS3WQ2I7ab2uddqJLqrdm07ZDvJ+gcxZEwcjcM+rsqcIHm3rrVW359TjSWDG0BDeMNu0xu2igbSPdA== X-Gm-Message-State: AOJu0YxOtZnwvPGtmtjSiweCEdbt3QmMY5KulKt6PmiUr8kZ37rU9ZmF nnrnmqwtMsAxeVkHV8aoRDFfkt8fuqTKn7kUF09+ne4BgjQDpeLOp/rQHtPte38= X-Google-Smtp-Source: AGHT+IFORSWX0ysgwFR7RQ99ft+D14MIbt0Ie8vdK9uiCSKuM0XLaRfZUtZDgUJaa+RQRY7CagNyAw== X-Received: by 2002:a17:90a:bf05:b0:2c5:10a6:e989 with SMTP id 98e67ed59e1d1-2d39265846bmr99107a91.35.1723467471060; Mon, 12 Aug 2024 05:57:51 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d1c9ca6fafsm8183368a91.34.2024.08.12.05.57.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 05:57:50 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, sdf@fomichev.me, 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: [RFC net-next 5/5] eventpoll: Control irq suspension for prefer_busy_poll Date: Mon, 12 Aug 2024 12:57:08 +0000 Message-Id: <20240812125717.413108-6-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240812125717.413108-1-jdamato@fastly.com> References: <20240812125717.413108-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- fs/eventpoll.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index cc47f72005ed..d74b5b9c1f51 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -457,6 +457,8 @@ static bool ep_busy_loop(struct eventpoll *ep, int nonblock) * 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 = 0; return false; } @@ -540,6 +542,14 @@ static long ep_eventpoll_bp_ioctl(struct file *file, unsigned int cmd, } } +static void ep_suspend_napi_irqs(struct eventpoll *ep) +{ + unsigned int napi_id = READ_ONCE(ep->napi_id); + + if (napi_id >= MIN_NAPI_ID && READ_ONCE(ep->prefer_busy_poll)) + napi_suspend_irqs(napi_id); +} + #else static inline bool ep_busy_loop(struct eventpoll *ep, int nonblock) @@ -557,6 +567,10 @@ static long ep_eventpoll_bp_ioctl(struct file *file, unsigned int cmd, return -EOPNOTSUPP; } +static void ep_suspend_napi_irqs(struct eventpoll *ep) +{ +} + #endif /* CONFIG_NET_RX_BUSY_POLL */ /* @@ -788,6 +802,10 @@ static bool ep_refcount_dec_and_test(struct eventpoll *ep) static void ep_free(struct eventpoll *ep) { + unsigned int napi_id = READ_ONCE(ep->napi_id); + + if (napi_id >= MIN_NAPI_ID && READ_ONCE(ep->prefer_busy_poll)) + napi_resume_irqs(napi_id); mutex_destroy(&ep->mtx); free_uid(ep->user); wakeup_source_unregister(ep->ws); @@ -2005,8 +2023,10 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, * trying again in search of more luck. */ res = ep_send_events(ep, events, maxevents); - if (res) + if (res) { + ep_suspend_napi_irqs(ep); return res; + } } if (timed_out)