Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1194220rdb; Fri, 9 Feb 2024 13:22:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IFRjuU4gZyZchO7lJOobWwX6EzpX6O3NZpQJn08+ylQo7iLdH7/oLHPZxhi1uSTThRG4T2m X-Received: by 2002:a17:906:7f8c:b0:a3c:b03:5b76 with SMTP id f12-20020a1709067f8c00b00a3c0b035b76mr192006ejr.56.1707513745737; Fri, 09 Feb 2024 13:22:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707513745; cv=pass; d=google.com; s=arc-20160816; b=QvoceH9uSBESgUX0iHIYM/48vxaeTqr3FjjCz6sw90ttX/pTFrl25HCN83qNFAITPH ZfrUHaUgBA9lYB/k0KG+UBc6GK3QRXDNY6a2rKgMPQcK2TjyynOGLO07ZVZ6s0qnSmQZ 7vYPgMVlIC1WU34PIrr+Mpk1p6iX7kdEG+4yfTBj5qZ/KhyClqYf484pHsAqiwBWWckV qu750KNflEZrdlcClM2n9HV8hoDGvAqOWN86DoYUI6d9GKZV3OE1KeezC9Oq4bZbirH6 1a6xa0rr2uKS4YsY9OWe2mqakSjs2e1LVaKUh4W9f/9E5DgKCHWVZof2ie9wINjOECF0 vy4Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=G0NsVP2+DJYJlYo79AHfvXsFPLMqC3dLNa8zH3nE+As=; fh=tcws0VCwIYkx2TGrmtDGFQ0VYc7A5rCujtVOtFP8bOw=; b=q99RBqhJ+NbSG8cAD3InxCqJFj4xRI3bX4KTkIuyMudes1Om5bZpIijWIbZelY6JqL LSwX9/SwH6jyIsGioSsY9UMpa+k4uOKM+aDjYYIRfLAhFkrI4BOJZNk1WBxKHQQL03wY wfYKVR84N6fVb9mi/jy7u5mHGKQ+3ussYckPBnTJEgP/gISOqWFJBW1GwJ2TFCEc7HWf fyH5rfgPOURLy1k0BLAO2IBf681sTju3AMUPKTH4ltS+xCxahPp/JxLc5woe4VcYFMWC RrlH2v3iNRyLTm5hsnuk5g7p6Bhlv4u5eupeGBchPLCeRj5yD2lzoRgiRPaM70AC+xQo pZbg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@fastly.com header.s=google header.b=tG2UUo5K; arc=pass (i=1 spf=pass spfdomain=fastly.com dkim=pass dkdomain=fastly.com dmarc=pass fromdomain=fastly.com); spf=pass (google.com: domain of linux-kernel+bounces-60021-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60021-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fastly.com X-Forwarded-Encrypted: i=2; AJvYcCXtud4y9xOCqw918+sW3OUsQ64jJH5gpOnPXIofr2QX2zYa4Pi/OJl7ZEs1CIs1FikkVVk6cGbjp1bE2uYqyiZyFss49xPv5EUoxrg7Kg== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id dn18-20020a17090794d200b00a3ba6fe0848si1313781ejc.765.2024.02.09.13.22.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 13:22:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60021-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@fastly.com header.s=google header.b=tG2UUo5K; arc=pass (i=1 spf=pass spfdomain=fastly.com dkim=pass dkdomain=fastly.com dmarc=pass fromdomain=fastly.com); spf=pass (google.com: domain of linux-kernel+bounces-60021-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60021-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fastly.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3F1001F2A79B for ; Fri, 9 Feb 2024 21:22:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 592E23AC24; Fri, 9 Feb 2024 21:15:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="tG2UUo5K" Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (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 00D8E3A1B1 for ; Fri, 9 Feb 2024 21:15:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707513352; cv=none; b=pZKWyuI1EvPSAfhRdAOSqLO+YYq6IKlKa514FdcyntUERspKYv9PnXBd49QaAEgOna8bKJk93yC61LSIOQb1LnRYw460DqcV/VOs5ulCmYSQkrot4CRd002QpIDwid50zkC199C2IU9KQ59yTDTvDr6pGbhBbT0dW8OeeCCLy9Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707513352; c=relaxed/simple; bh=CJVUUyQixO3GY5CVmRJIGygCqjREOllOxrIr3Eh94fc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jvpoxNgr1VwZWcYTrFV0ZzZWAHJ/fTqOGtkIq8BLTUeQJgAITuAVrOoRVlK37/9kyf0i27eDxTg1FAG67si/qiu35NnfrfQuys8vvCrSbjvGywn25mzf6RJInNZC345itTv8FOmb3ScLpPK77bNWnqbsg8F5UWQagwQRyjeiGhs= 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=tG2UUo5K; arc=none smtp.client-ip=209.85.215.181 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 Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-5d8ddbac4fbso1194116a12.0 for ; Fri, 09 Feb 2024 13:15:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1707513350; x=1708118150; 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=G0NsVP2+DJYJlYo79AHfvXsFPLMqC3dLNa8zH3nE+As=; b=tG2UUo5Kpulb48owiZcJFB8pxTuNhFU9SFG3y6Pp2+m3iTqxdP0TNvApcT4I8+TCqd g46fYzuQUTpOtXqJJQuOh1qkYpoEarnlL0Fna8bntuGSxxCWfXSbQkAY4Ft4wi+GltSY VWO9pMWohX3ut8JEMS147DOZyzh0Q4/O3Y8UU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707513350; x=1708118150; 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=G0NsVP2+DJYJlYo79AHfvXsFPLMqC3dLNa8zH3nE+As=; b=sqR+lvHq9QTD7Lwf351BF3kO/DPieiBZ9BHtxg+Olf3C2lWx+NgybItnQsIAO6/03m IWrISxyJTaENcrAVTu/AqljxrcY19qtuqNCSXovngQ66Qn4KRrrV70w39VQjNSUMDjv5 yQ3V9QR5JvtZrqmly3jWoyUX4toBfx2jk614dLkxdcEbqI7Fmy/oQQTfXzPhtQt3M3VD 4n8xtRdZprDKfRCe1dlsBc8+RaeZ2lio0C/xOiBEOV/VfvhCFE/gXeyo12M2KO2Bexmb s2CkJowvP1owsb3a9q7YKVlpuA8T/4F5sWw2lgtHe+9ksf+pnupXXEbJBaw+lbjoutG+ 4I5Q== X-Gm-Message-State: AOJu0Yw+e1svK4w26G4aGQAmMYT+hpA1X3eKCmWRigPw0Iq9nj3Tj1hX 1rK4VEoK+Z+Y6rP8enhHg2OOW0Z3bmnEwsX9Y+ywSVM8KUvqUYgwZs/xbJdOkcMYjuK5FfZsjxU sc2K7h+Vv23jcdZWDWajRXDhuU3gwfso9U3Fbthh/UKQFMx0KLibfxherzuElKp1Kglylklf3IM 9BHkWBsxbBjhng7o1HbrMnYgixawel7aYCODFXvgmPOC1+6Q== X-Received: by 2002:a05:6a20:9c99:b0:19e:9a59:20df with SMTP id mj25-20020a056a209c9900b0019e9a5920dfmr417488pzb.9.1707513349972; Fri, 09 Feb 2024 13:15:49 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWNGCpYwEjdWOp9Af1u8tW2O5xfC8VpboIT36q3QoQQ0xH8ctFz596nOAMoJ6F9eyhTK4CEvJ51uFuMx4RHYRgPLExDttotnTGSfTdhT23/b36g8AFG7+uss8UnzMKMa53LRAHzowhtf0al3hzyCvrkY11h/lWzYIPynIHTbIN6G5UcjMAIPlzOVTX095Co2AVRH9cDkWKI8/1rFzGFHNlXbp85kHT81yA+mrIfbgPMAMw+U1nAeAtmV5ebnFKXhLt/PI9r5tcZhGMuVg1ZfywC+HV8IxiRKzPV/lxrB8MPOR8HgvmRPf2u0u/QI5ISX9m31W8z6zinbpMD8h2Hb4jl7zx3p4ZPGSM7XSYfzsXJNLqAmY9wa0hkB+0hnDhEMgvImlirN4gAJGlPng+ARn+AZpzmpIk4WS++qFSfmnCroCn4gOE4F+T2RUvPsGLi+7fMs3YNc5Z747JAwSsALvsjuGQ1fvuK/rQO4ph0xMzubDjDQzWiPoXGGnNdIa7pyamFRUmN5+5V2DdYXB7H1i20ZEHsDOqik5LK4JATJ3l08TuBrqHTaHawQ8+MnQomcrLFsBX9LzSWPMf7UK9UZzaVwSRWUnGTI+hnps+26D5KUGMH5xl8Lr3OSaL/c/Q= Received: from localhost.localdomain ([2620:11a:c018:0:ea8:be91:8d1:f59b]) by smtp.gmail.com with ESMTPSA id x23-20020aa79197000000b006e05c801748sm969629pfa.199.2024.02.09.13.15.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 13:15:49 -0800 (PST) From: Joe Damato To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: chuck.lever@oracle.com, jlayton@kernel.org, linux-api@vger.kernel.org, brauner@kernel.org, edumazet@google.com, davem@davemloft.net, alexander.duyck@gmail.com, sridhar.samudrala@intel.com, kuba@kernel.org, willemdebruijn.kernel@gmail.com, weiwan@google.com, David.Laight@ACULAB.COM, arnd@arndb.de, sdf@google.com, amritha.nambiar@intel.com, Joe Damato , Alexander Viro , Jan Kara , linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure)) Subject: [PATCH net-next v7 3/4] eventpoll: Add per-epoll prefer busy poll option Date: Fri, 9 Feb 2024 21:15:23 +0000 Message-Id: <20240209211528.51234-4-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240209211528.51234-1-jdamato@fastly.com> References: <20240209211528.51234-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: 8bit When using epoll-based busy poll, the prefer_busy_poll option is hardcoded to false. Users may want to enable prefer_busy_poll to be used in conjunction with gro_flush_timeout and defer_hard_irqs_count to keep device IRQs masked. Other busy poll methods allow enabling or disabling prefer busy poll via SO_PREFER_BUSY_POLL, but epoll-based busy polling uses a hardcoded value. Fix this edge case by adding support for a per-epoll context prefer_busy_poll option. The default is false, as it was hardcoded before this change. Signed-off-by: Joe Damato Acked-by: Stanislav Fomichev Reviewed-by: Jakub Kicinski Reviewed-by: Eric Dumazet --- fs/eventpoll.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index ed83ae33dd45..1b8d01af0c2c 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -231,6 +231,7 @@ struct eventpoll { u32 busy_poll_usecs; /* busy poll packet budget */ u16 busy_poll_budget; + bool prefer_busy_poll; #endif #ifdef CONFIG_DEBUG_LOCK_ALLOC @@ -438,13 +439,14 @@ static bool ep_busy_loop(struct eventpoll *ep, int nonblock) { unsigned int napi_id = READ_ONCE(ep->napi_id); u16 budget = READ_ONCE(ep->busy_poll_budget); + bool prefer_busy_poll = READ_ONCE(ep->prefer_busy_poll); if (!budget) budget = BUSY_POLL_BUDGET; if (napi_id >= MIN_NAPI_ID && ep_busy_loop_on(ep)) { - napi_busy_loop(napi_id, nonblock ? NULL : ep_busy_loop_end, ep, false, - budget); + napi_busy_loop(napi_id, nonblock ? NULL : ep_busy_loop_end, + ep, prefer_busy_poll, budget); if (ep_events_available(ep)) return true; /* @@ -2098,6 +2100,7 @@ static int do_epoll_create(int flags) #ifdef CONFIG_NET_RX_BUSY_POLL ep->busy_poll_usecs = 0; ep->busy_poll_budget = 0; + ep->prefer_busy_poll = false; #endif ep->file = file; fd_install(fd, file); -- 2.25.1