From patchwork Mon Oct 21 01:52:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13843489 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.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 145F617BB6 for ; Mon, 21 Oct 2024 01:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729475634; cv=none; b=rRMPUDO0I3oGd506o9/8wEyvijXKII6Z7tM8Xkc/2iLYqoh8nCAiP8m5r3h35rIrb3wGtIg0uwzaD4apd5w9nT3SqlS5llq4A+yNdgas7cj1fEaMolvYwAbpRgTa+WYhXsEXMju4QbZvXCARTKIwpZGzgu60cP/WkiC9CXB8NX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729475634; c=relaxed/simple; bh=VE4qm8jApOLVerU00KCWXCwt/67d+CL4QjGzcJExsOA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rHi05A9UAZyY+PJqo76Kq/Rg3Pez2CaDLHd6mhtEa00qLuWN4Q27FuTe9EJ3KoCIDbKK9/jcLZVu68mnGYh0bVOQQ8YXWoepFFlPf57+pEcaiPypEnPclVt0Mhaijt9gRDo1uk5zPLyDqGrEvDNmgHoJZs1OzyijrQhaCf8N5oY= 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=BbCVy6X3; arc=none smtp.client-ip=209.85.214.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="BbCVy6X3" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-20caea61132so31332975ad.2 for ; Sun, 20 Oct 2024 18:53:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1729475631; x=1730080431; 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=AfpWC01kTavxQZPrDblAx1MDT+scLEsoUAk88HI2mLY=; b=BbCVy6X3EKt5jkfPv5QHE8O0pIVG9Uq7APlMayjzsAbeaLZnZ6+8U/3Nzmgy6NHyW8 /LUNkv4036NJYFQEyG8y734hZMhWbU8Vr1yndJFzFad7TShSBuJMQxh/qd3TRtAWLwaf xDrgF0eJefo8cgZZ0/Kfv5/Hb/OLUN8SCagDo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729475631; x=1730080431; 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=AfpWC01kTavxQZPrDblAx1MDT+scLEsoUAk88HI2mLY=; b=p9F11fQ5UaTjZzZgPqTt/K9K7N1fcV5LBlm7etVHHJdUS7X1Pa9r9x0xRJ3ypDu3Ws WA5TaA06tigoKVeCHJMNQORc8AZL/cXy5yuvVtagJaQ8xpWTKyDKJqjI4iXZeGy9N1BY H3acO2i5sSiB7bScf2CeehudJyztnhCBhc9eEeiSNNo3xSus/Cd7RHdt+Tbcm2IxTfpl vataZnrkKrpKitxComGdRcZQaX+DLmecE4HPGQQkBVSKwesEx3TKypIpKT4SOl8GqcAQ HgQ+XUJGyx5OV6Fu3b1DIHbFFfSl2n7dWw1OtMccSBn4BTEjGds+AsvMg7TGM+BwMWrr d8hQ== X-Gm-Message-State: AOJu0YxPwVpWLxmmkkjPOGiK3P30oP0VLhQl0RfNt5gDQvcyI0fqiGck n22vER0KaCwCbzRwHzVhVFRm3tVAERIQ/NhnXSJlssAUbMLb/M2usdnppu5xom9CBrHWnjqh3o2 0MCFSo58O6hgmyefd6C9tz7h1mEXoqTyl7k34MHrCXH6bfznfYgD4EZ3i34YT0Ygs3aBWvLC/Ax Yw6LSREzHgnzQ0fpOLoZQQ/P10iFWeUduA+b4= X-Google-Smtp-Source: AGHT+IGjTJnjyjVlBYRXVayLwuiOfn+qQDvfmpxxzMcQOZPyIDPOAhsGL2RHj1rLhlA3CwruLaZYlQ== X-Received: by 2002:a17:902:cec1:b0:1fb:57e7:5bb4 with SMTP id d9443c01a7336-20e5a9061d1mr121980015ad.37.1729475630765; Sun, 20 Oct 2024 18:53:50 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20e7eee650bsm15859985ad.34.2024.10.20.18.53.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 18:53:50 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: namangulati@google.com, edumazet@google.com, 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 , "David S. Miller" , Paolo Abeni , Donald Hunter , Jesper Dangaard Brouer , Mina Almasry , Xuan Zhuo , Jiri Pirko , Sebastian Andrzej Siewior , Lorenzo Bianconi , Alexander Lobakin , Johannes Berg , Daniel Jurgens , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next v2 1/6] net: Add napi_struct parameter irq_suspend_timeout Date: Mon, 21 Oct 2024 01:52:56 +0000 Message-Id: <20241021015311.95468-2-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241021015311.95468-1-jdamato@fastly.com> References: <20241021015311.95468-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Martin Karsten Add a per-NAPI IRQ suspension parameter, which can be get/set with netdev-genl. This patch doesn't change any behavior but prepares the code for other changes in the following commits which use irq_suspend_timeout as a timeout for IRQ suspension. Signed-off-by: Martin Karsten Co-developed-by: Joe Damato Signed-off-by: Joe Damato Tested-by: Joe Damato Tested-by: Martin Karsten --- v1 -> v2: - Rewrote this patch to make irq_suspend_timeout per-NAPI via netdev-genl. rfc -> v1: - Removed napi.rst documentation from this patch; added to patch 6. Documentation/netlink/specs/netdev.yaml | 7 +++++++ include/linux/netdevice.h | 2 ++ include/uapi/linux/netdev.h | 1 + net/core/dev.c | 2 ++ net/core/dev.h | 25 +++++++++++++++++++++++++ net/core/netdev-genl-gen.c | 5 +++-- net/core/netdev-genl.c | 12 ++++++++++++ tools/include/uapi/linux/netdev.h | 1 + 8 files changed, 53 insertions(+), 2 deletions(-) diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlink/specs/netdev.yaml index f9cb97d6106c..cbb544bd6c84 100644 --- a/Documentation/netlink/specs/netdev.yaml +++ b/Documentation/netlink/specs/netdev.yaml @@ -263,6 +263,11 @@ attribute-sets: the end of a NAPI cycle. This may add receive latency in exchange for reducing the number of frames processed by the network stack. type: uint + - + name: irq-suspend-timeout + doc: The timeout, in nanoseconds, of how long to suspend irq + processing, if event polling finds events + type: uint - name: queue attributes: @@ -653,6 +658,7 @@ operations: - pid - defer-hard-irqs - gro-flush-timeout + - irq-suspend-timeout dump: request: attributes: @@ -704,6 +710,7 @@ operations: - id - defer-hard-irqs - gro-flush-timeout + - irq-suspend-timeout kernel-family: headers: [ "linux/list.h"] diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 8feaca12655e..9c3be8455707 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -347,6 +347,7 @@ struct gro_list { */ struct napi_config { u64 gro_flush_timeout; + u64 irq_suspend_timeout; u32 defer_hard_irqs; unsigned int napi_id; }; @@ -383,6 +384,7 @@ struct napi_struct { struct hrtimer timer; struct task_struct *thread; unsigned long gro_flush_timeout; + unsigned long irq_suspend_timeout; u32 defer_hard_irqs; /* control-path-only fields follow */ struct list_head dev_list; diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h index e3ebb49f60d2..e4be227d3ad6 100644 --- a/include/uapi/linux/netdev.h +++ b/include/uapi/linux/netdev.h @@ -124,6 +124,7 @@ enum { NETDEV_A_NAPI_PID, NETDEV_A_NAPI_DEFER_HARD_IRQS, NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT, + NETDEV_A_NAPI_IRQ_SUSPEND_TIMEOUT, __NETDEV_A_NAPI_MAX, NETDEV_A_NAPI_MAX = (__NETDEV_A_NAPI_MAX - 1) diff --git a/net/core/dev.c b/net/core/dev.c index c682173a7642..68d0b16c2f2c 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6662,6 +6662,7 @@ static void napi_restore_config(struct napi_struct *n) { n->defer_hard_irqs = n->config->defer_hard_irqs; n->gro_flush_timeout = n->config->gro_flush_timeout; + n->irq_suspend_timeout = n->config->irq_suspend_timeout; /* a NAPI ID might be stored in the config, if so use it. if not, use * napi_hash_add to generate one for us. It will be saved to the config * in napi_disable. @@ -6676,6 +6677,7 @@ static void napi_save_config(struct napi_struct *n) { n->config->defer_hard_irqs = n->defer_hard_irqs; n->config->gro_flush_timeout = n->gro_flush_timeout; + n->config->irq_suspend_timeout = n->irq_suspend_timeout; n->config->napi_id = n->napi_id; napi_hash_del(n); } diff --git a/net/core/dev.h b/net/core/dev.h index 7881bced70a9..d043dee25a68 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -236,6 +236,31 @@ static inline void netdev_set_gro_flush_timeout(struct net_device *netdev, netdev->napi_config[i].gro_flush_timeout = timeout; } +/** + * napi_get_irq_suspend_timeout - get the irq_suspend_timeout + * @n: napi struct to get the irq_suspend_timeout from + * + * Return: the per-NAPI value of the irq_suspend_timeout field. + */ +static inline unsigned long +napi_get_irq_suspend_timeout(const struct napi_struct *n) +{ + return READ_ONCE(n->irq_suspend_timeout); +} + +/** + * napi_set_irq_suspend_timeout - set the irq_suspend_timeout for a napi + * @n: napi struct to set the irq_suspend_timeout + * @timeout: timeout value to set + * + * napi_set_irq_suspend_timeout sets the per-NAPI irq_suspend_timeout + */ +static inline void napi_set_irq_suspend_timeout(struct napi_struct *n, + unsigned long timeout) +{ + WRITE_ONCE(n->irq_suspend_timeout, timeout); +} + int rps_cpumask_housekeeping(struct cpumask *mask); #if defined(CONFIG_DEBUG_NET) && defined(CONFIG_BPF_SYSCALL) diff --git a/net/core/netdev-genl-gen.c b/net/core/netdev-genl-gen.c index 21de7e10be16..a89cbd8d87c3 100644 --- a/net/core/netdev-genl-gen.c +++ b/net/core/netdev-genl-gen.c @@ -92,10 +92,11 @@ static const struct nla_policy netdev_bind_rx_nl_policy[NETDEV_A_DMABUF_FD + 1] }; /* NETDEV_CMD_NAPI_SET - do */ -static const struct nla_policy netdev_napi_set_nl_policy[NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT + 1] = { +static const struct nla_policy netdev_napi_set_nl_policy[NETDEV_A_NAPI_IRQ_SUSPEND_TIMEOUT + 1] = { [NETDEV_A_NAPI_ID] = { .type = NLA_U32, }, [NETDEV_A_NAPI_DEFER_HARD_IRQS] = NLA_POLICY_FULL_RANGE(NLA_U32, &netdev_a_napi_defer_hard_irqs_range), [NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT] = { .type = NLA_UINT, }, + [NETDEV_A_NAPI_IRQ_SUSPEND_TIMEOUT] = { .type = NLA_UINT, }, }; /* Ops table for netdev */ @@ -186,7 +187,7 @@ static const struct genl_split_ops netdev_nl_ops[] = { .cmd = NETDEV_CMD_NAPI_SET, .doit = netdev_nl_napi_set_doit, .policy = netdev_napi_set_nl_policy, - .maxattr = NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT, + .maxattr = NETDEV_A_NAPI_IRQ_SUSPEND_TIMEOUT, .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, }, }; diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c index b49c3b4e5fbe..765ce7c9d73b 100644 --- a/net/core/netdev-genl.c +++ b/net/core/netdev-genl.c @@ -161,6 +161,7 @@ static int netdev_nl_napi_fill_one(struct sk_buff *rsp, struct napi_struct *napi, const struct genl_info *info) { + unsigned long irq_suspend_timeout; unsigned long gro_flush_timeout; u32 napi_defer_hard_irqs; void *hdr; @@ -196,6 +197,11 @@ netdev_nl_napi_fill_one(struct sk_buff *rsp, struct napi_struct *napi, napi_defer_hard_irqs)) goto nla_put_failure; + irq_suspend_timeout = napi_get_irq_suspend_timeout(napi); + if (nla_put_uint(rsp, NETDEV_A_NAPI_IRQ_SUSPEND_TIMEOUT, + irq_suspend_timeout)) + goto nla_put_failure; + gro_flush_timeout = napi_get_gro_flush_timeout(napi); if (nla_put_uint(rsp, NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT, gro_flush_timeout)) @@ -306,6 +312,7 @@ int netdev_nl_napi_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb) static int netdev_nl_napi_set_config(struct napi_struct *napi, struct genl_info *info) { + u64 irq_suspend_timeout = 0; u64 gro_flush_timeout = 0; u32 defer = 0; @@ -314,6 +321,11 @@ netdev_nl_napi_set_config(struct napi_struct *napi, struct genl_info *info) napi_set_defer_hard_irqs(napi, defer); } + if (info->attrs[NETDEV_A_NAPI_IRQ_SUSPEND_TIMEOUT]) { + irq_suspend_timeout = nla_get_uint(info->attrs[NETDEV_A_NAPI_IRQ_SUSPEND_TIMEOUT]); + napi_set_irq_suspend_timeout(napi, irq_suspend_timeout); + } + if (info->attrs[NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT]) { gro_flush_timeout = nla_get_uint(info->attrs[NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT]); napi_set_gro_flush_timeout(napi, gro_flush_timeout); diff --git a/tools/include/uapi/linux/netdev.h b/tools/include/uapi/linux/netdev.h index e3ebb49f60d2..e4be227d3ad6 100644 --- a/tools/include/uapi/linux/netdev.h +++ b/tools/include/uapi/linux/netdev.h @@ -124,6 +124,7 @@ enum { NETDEV_A_NAPI_PID, NETDEV_A_NAPI_DEFER_HARD_IRQS, NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT, + NETDEV_A_NAPI_IRQ_SUSPEND_TIMEOUT, __NETDEV_A_NAPI_MAX, NETDEV_A_NAPI_MAX = (__NETDEV_A_NAPI_MAX - 1) From patchwork Mon Oct 21 01:52:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13843490 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.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 4A7FA1BC3C for ; Mon, 21 Oct 2024 01:53:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729475637; cv=none; b=eSLVu+Hzg6SKrVgpXRrh9sdZvVqEYaucMd6t3IJcq9GEUFA3dEd9921O8hwjR08Bq3KQULdOed1lpwnTyqP/OwRlyH7lEsafslRNWZ8o0IaT4BShttA75NoVTh1W68CU79UCoahz/ZdT5J3qwNIS2DhSZrjIhoKY+Kin3jwDfec= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729475637; c=relaxed/simple; bh=j/xq+NkIfYdhz94qa/CP8OLzI/XZjv3RfYV1I/panlE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cpbcw1KzJ+jOFniHOD/wbvScF1l8aCci1dBgM6OttkNSak35EJ82+saMOEEYF9iROPVm4CvGkRhUV/xLAuP/G9QoKYC9Otwwzry4uNWyywneOv1/VlnMJg9YhtfVMwrFGNeWX40+VlGshsGO6s/GxL5vqkmMK26UEWKr+rrV4dU= 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=lZ7Rwt1I; arc=none smtp.client-ip=209.85.214.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="lZ7Rwt1I" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-20c77459558so33158315ad.0 for ; Sun, 20 Oct 2024 18:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1729475634; x=1730080434; 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=UTXGBPwWb2UjgB4YRsP1U7o6ISppA/AhjO8WcV0ADKY=; b=lZ7Rwt1Ijr1N+kRYA6bsUYdYehqVJbTHzS1U9g6IC33+L5oDDi03q4w3XR/AUg4Mmz M6xTrSLhCRhkykHAavaZYBHYM3b/eUehrtup1kMswrPAf8LbP+ySDuYu/MxDXPltwqEb fLrEFUaEy8IjLdMcdemTtnxVxouL70tvGLgo4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729475634; x=1730080434; 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=UTXGBPwWb2UjgB4YRsP1U7o6ISppA/AhjO8WcV0ADKY=; b=f1Ua7YFm3EEqiHA+11NSj8QZ4CiiD3kIFVfbHBi04p79N/0Qwcxd/y7uTx0RVgPtKr ZaSRKga5JDLvFbeTr1wzdhDv5MRB7//fWxxf4gPAyR7aaYi7OWtQ4CQ4ir3EKnOY2MpH rNME6v9PgakOP98yWZ4x1zXBEvMCikL/Cw3wxdAjWjrHxAQ9Z/P+mNeDq0gG4odytKWV io/UHiZw2ev1YfGcwvFbn0bJ5Rxxruc05R90RSvBCq5kwpbb4Zlg1Gph99hKjC/zTNpt GmUMt9pio2gpw8eeEoa+ZKFDtXHHFE8DVFsVwFaMmXu1X8i6OCZeqKQbO7aYmlqSq/1z LZ3Q== X-Gm-Message-State: AOJu0YzAPhVKfBv+YRwnr9GlWw+eYSB3ypmtFx2Ediejeik7uqf82P4i eUWwsD1MRZ7SJcBcJc0NtI+9a2intnEB93lIxRDTBAkfYEeg4eR60z80no3pSPLjPRJctzBBObi OifflFONIFFp64DllGCqOqGwVHlpGe+a+gVKSJVnK0M76jDicHw14aDr/BcpqSksAFVMTk0KDNq HNXsFH2wS0xeJiG6g3GtE+ggkA2KoVSK10x1E= X-Google-Smtp-Source: AGHT+IHwIA2NfupKP85DHpqMkbeTwP0qaJp0Gh7HUU0pAgnV6BG8mMO/V6AL9FsCCHPaR3ALMNsp4g== X-Received: by 2002:a17:902:da8f:b0:20c:c18f:c3a0 with SMTP id d9443c01a7336-20e5a728241mr140048925ad.7.1729475634077; Sun, 20 Oct 2024 18:53:54 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20e7eee650bsm15859985ad.34.2024.10.20.18.53.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 18:53:53 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: namangulati@google.com, edumazet@google.com, 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 , "David S. Miller" , Paolo Abeni , Jiri Pirko , Sebastian Andrzej Siewior , Lorenzo Bianconi , Alexander Lobakin , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next v2 2/6] net: Suspend softirq when prefer_busy_poll is set Date: Mon, 21 Oct 2024 01:52:57 +0000 Message-Id: <20241021015311.95468-3-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241021015311.95468-1-jdamato@fastly.com> References: <20241021015311.95468-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Martin Karsten When NAPI_F_PREFER_BUSY_POLL is set during busy_poll_stop and the irq_suspend_timeout sysfs is nonzero, this timeout is used to defer softirq scheduling, potentially longer than gro_flush_timeout. This can be used to effectively suspend softirq processing during the time it takes for an application to process data and return to the next busy-poll. The call to napi->poll in busy_poll_stop might lead to an invocation of napi_complete_done, but the prefer-busy flag is still set at that time, so the same logic is used to defer softirq scheduling for irq_suspend_timeout. Signed-off-by: Martin Karsten Co-developed-by: Joe Damato Signed-off-by: Joe Damato Tested-by: Joe Damato Tested-by: Martin Karsten --- net/core/dev.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 68d0b16c2f2c..a388303b26b9 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6235,7 +6235,12 @@ bool napi_complete_done(struct napi_struct *n, int work_done) timeout = napi_get_gro_flush_timeout(n); n->defer_hard_irqs_count = napi_get_defer_hard_irqs(n); } - if (n->defer_hard_irqs_count > 0) { + if (napi_prefer_busy_poll(n)) { + timeout = napi_get_irq_suspend_timeout(n); + if (timeout) + ret = false; + } + if (ret && n->defer_hard_irqs_count > 0) { n->defer_hard_irqs_count--; timeout = napi_get_gro_flush_timeout(n); if (timeout) @@ -6371,9 +6376,13 @@ static void busy_poll_stop(struct napi_struct *napi, void *have_poll_lock, bpf_net_ctx = bpf_net_ctx_set(&__bpf_net_ctx); if (flags & NAPI_F_PREFER_BUSY_POLL) { - napi->defer_hard_irqs_count = napi_get_defer_hard_irqs(napi); - timeout = napi_get_gro_flush_timeout(napi); - if (napi->defer_hard_irqs_count && timeout) { + timeout = napi_get_irq_suspend_timeout(napi); + if (!timeout) { + napi->defer_hard_irqs_count = napi_get_defer_hard_irqs(napi); + if (napi->defer_hard_irqs_count) + timeout = napi_get_gro_flush_timeout(napi); + } + if (timeout) { hrtimer_start(&napi->timer, ns_to_ktime(timeout), HRTIMER_MODE_REL_PINNED); skip_schedule = true; } From patchwork Mon Oct 21 01:52:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13843491 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 E49D62E401 for ; Mon, 21 Oct 2024 01:53:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729475640; cv=none; b=HwUFGDfBUY51+jaHHN6YtLjqcJKVzc4B5OfU/Y+JVhOSlW3cHFn7NLyiN59U2SO9Ug9N947QHxio31q8ZZEa2HQ3qjl3NWfNfygZiRuw+Hxw7TSueF77+O+WoTZshRz8jyYZU/vPeKC2Af00+1WWhsH7T39fQ+Oy01G8ZNVnBVg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729475640; c=relaxed/simple; bh=fNcofMdMGqSdkpD7cvRXzDTPFTdNqqwK2UlNXiWtTNU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VDjksuNngLUi4BfjRLuj0mjlDnvEVWWQdmtJm4K/8xfP5cn14KEDiRmAeMkwHtmPDUuzQ3SM00/4d4nLCBse7eGvcvgDyxkpRDxSahwpvo1hzkY8y3i70TXxm3VRAATqXYXeIJHQlYDwAJV+MthcjL/MlQZ/C86B8rB7c1exPwQ= 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=ITGHjhkM; arc=none smtp.client-ip=209.85.214.170 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="ITGHjhkM" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-20cb47387ceso33241525ad.1 for ; Sun, 20 Oct 2024 18:53:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1729475638; x=1730080438; 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=FePUDPVukA9o3l+UniZnQUedPYlrvLH3uHGO+zGSqIk=; b=ITGHjhkMLqsqvNFCZiiDk8r9f+i1QqbgSaJcr176cTTacfZyNy88Q2Q6Fu05QLT8BD PLd33QDYIC2Sxv6I+rtWKkc1xJLeO+DLac3E0l7xorJe6wN4bS2GVKdfCzSLmlAP2i1r 7yvfNuihfABsxI88FJpfAKJ5fmromSu39Ye98= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729475638; x=1730080438; 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=FePUDPVukA9o3l+UniZnQUedPYlrvLH3uHGO+zGSqIk=; b=lUCpb11RDjnkY31WbXyL+sLQoQf7FOpgrgOR0anp3quHlPFX87jmNQv8t9e1diU1Tl qDUAUIWk+UlV4IbQBrXGipKoq4k1g/3KDG6m/oxcT99+hecIBW/GhGmgbDDa5LtLujf1 k/CB12nizwg3nYSkcdhfOew8Jii4Ms4NUje49qWTQtonO++Erk+E2evXBST8t6reqACf izvQ0/kK/lcqQLn8Yme95tofEiAsoaeVdGU3OcZroHCq1cJ5E6H6tG5rnVmlcoRrUdwN xozfmfA2u5d0Hvihxs+am84DfClLNl0GC/3iBxaKjqH8DlC7NevWaGk6OIS+wM77oOej aT2g== X-Gm-Message-State: AOJu0YyMa6SYNHuGVnbPja0WRFWxCGxPDZgVECdZK2Y+xKYXrD8EAc2Y 0Vs/oTiXokJeMXx1fLew3vJ4YO79UTxK6ET/yLDNYUlMyuu36+/6vM0Kli+2DEvaisL8aQ+NfSa nax0XFLXOCj/w947jnT1J+GKzpU/BcHXxaC6bJ4N/583UjhXq9HOdWUeJxxIcldlYIKm0A/f6Nq TEi2YPLDYHF+2iCtbSeU+NYiAJFxpO0brKbcQ= X-Google-Smtp-Source: AGHT+IEhfBRZa4e9pXBSkhlDjOdj0kT4hP3ReRxh8NImFNH/yZPYPV6MnIfG85+rxL+mQSbyDRjkwg== X-Received: by 2002:a17:902:e74d:b0:20c:bb1c:d216 with SMTP id d9443c01a7336-20e5a773ebbmr154528285ad.21.1729475637501; Sun, 20 Oct 2024 18:53:57 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20e7eee650bsm15859985ad.34.2024.10.20.18.53.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 18:53:57 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: namangulati@google.com, edumazet@google.com, 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 , "David S. Miller" , Paolo Abeni , Jiri Pirko , Sebastian Andrzej Siewior , Lorenzo Bianconi , Alexander Lobakin , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next v2 3/6] net: Add control functions for irq suspension Date: Mon, 21 Oct 2024 01:52:58 +0000 Message-Id: <20241021015311.95468-4-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241021015311.95468-1-jdamato@fastly.com> References: <20241021015311.95468-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Martin Karsten The napi_suspend_irqs routine bootstraps irq suspension by elongating the defer timeout to irq_suspend_timeout. The napi_resume_irqs routine effectively cancels irq suspension by forcing the napi to be scheduled immediately. Signed-off-by: Martin Karsten Co-developed-by: Joe Damato Signed-off-by: Joe Damato Tested-by: Joe Damato Tested-by: Martin Karsten --- v1 -> v2: - Added a comment to napi_resume_irqs. include/net/busy_poll.h | 3 +++ net/core/dev.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h index f03040baaefd..c858270141bc 100644 --- a/include/net/busy_poll.h +++ b/include/net/busy_poll.h @@ -52,6 +52,9 @@ void napi_busy_loop_rcu(unsigned int napi_id, bool (*loop_end)(void *, unsigned long), void *loop_end_arg, bool prefer_busy_poll, u16 budget); +void napi_suspend_irqs(unsigned int napi_id); +void napi_resume_irqs(unsigned int napi_id); + #else /* CONFIG_NET_RX_BUSY_POLL */ static inline unsigned long net_busy_loop_on(void) { diff --git a/net/core/dev.c b/net/core/dev.c index a388303b26b9..143b3e690169 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6512,6 +6512,45 @@ void napi_busy_loop(unsigned int napi_id, } EXPORT_SYMBOL(napi_busy_loop); +void napi_suspend_irqs(unsigned int napi_id) +{ + struct napi_struct *napi; + + rcu_read_lock(); + napi = napi_by_id(napi_id); + if (napi) { + unsigned long timeout = napi_get_irq_suspend_timeout(napi); + + if (timeout) + hrtimer_start(&napi->timer, ns_to_ktime(timeout), + HRTIMER_MODE_REL_PINNED); + } + rcu_read_unlock(); +} +EXPORT_SYMBOL(napi_suspend_irqs); + +void napi_resume_irqs(unsigned int napi_id) +{ + struct napi_struct *napi; + + rcu_read_lock(); + napi = napi_by_id(napi_id); + if (napi) { + /* If irq_suspend_timeout is set to 0 between the call to + * napi_suspend_irqs and now, the original value still + * determines the safety timeout as intended and napi_watchdog + * will resume irq processing. + */ + if (napi_get_irq_suspend_timeout(napi)) { + local_bh_disable(); + napi_schedule(napi); + local_bh_enable(); + } + } + rcu_read_unlock(); +} +EXPORT_SYMBOL(napi_resume_irqs); + #endif /* CONFIG_NET_RX_BUSY_POLL */ static void __napi_hash_add_with_id(struct napi_struct *napi, From patchwork Mon Oct 21 01:52:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13843492 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 09CA5811F1 for ; Mon, 21 Oct 2024 01:54:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729475643; cv=none; b=MFNrfbjtF9fVLlj3FaEpcU0RMbTJhXx5O3csdbTY1asb/o6HDfjk2GPySm63D1bBF3yN20aqLEWmtm7oSStuxBNnJaA5H2fecdYUQvldGlBogcvrCegqa1MMb+fY0OBsltkF5O+zH9jGOQ7UpT9s6BjmQ4W0vYUcJ6WkS8DOGWI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729475643; c=relaxed/simple; bh=0e84nxtTo0ZoFDbU9IHdh0nF4DdHDes+nR9YAcbdfkw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jJ599ElvILqo2arGqYoJhPuvvSWl+KigzSYlRjrx+FvxFETuwYCV0Q2hi4Nc7Ow3nnRAPJWUgFGh2/z+6AGzQRuC/M+OrCfDnyEebORt5QJg1phSC4fQFnAaUOfXFsqLe6V7BYRktLovVVEZ7o+YDDZNqp0yIBrRzi2arFU9zMo= 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=lhiwI1As; arc=none smtp.client-ip=209.85.214.170 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="lhiwI1As" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-20c693b68f5so41301665ad.1 for ; Sun, 20 Oct 2024 18:54:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1729475640; x=1730080440; 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=iFrcV5k7ZDwjmKi04AgmgViZJXfV02gap8kxsUW7sc8=; b=lhiwI1Asx/53ccFpny/+Vd1zgltvJ9LGoMvnvxf9v83LiC7Ag6E+lygWgeGZYz3Fgu muEz7Dee79iUJH2WnT8fXQ2T+J3aOUCIT/L7gPeVgLg3YrswXh41gRxYlqPxOGF8n/oW 8goIPQl9fwlGnI7ne3jEsflH0kLuvUpyYoOR8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729475640; x=1730080440; 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=iFrcV5k7ZDwjmKi04AgmgViZJXfV02gap8kxsUW7sc8=; b=XKldwJB9RM9KzECP216895wH8w3kyZYU/yEtROC9Boc8vmSPiWMUBD6GUGI8fMqmvb NUJBKo6oIHV/UBCGwgTBK7u7iapIByCQ8gP61FBYl1kKCDv2p9jO6KR0kzE6ykiOsK5i k5ufnC/jQjSIZFER2rGH77nC3n/nBnMfJC0QHPVzin/3rnvUAvD/u2oycB5IRlWIsiOd TC1M+KE9tm8/EdCpA/y7syQXXyQmI4YgtNhtVufwPXiuGICokwttzOVhMQebtMBDg1TH JWp2cu/Wq+lA+iGaAFFrG7K2p4x4bDmw4LnNElwK0BSN35ksGEmEUBtFlZatB2J9MCLY 6Kyw== X-Gm-Message-State: AOJu0YymQSD0H6phn6HuMj8fgEu/lKvoGNlCAuAygZpNZ29J/zHHvsVh gvEDOvc8EkCFUNnwj66OIR8HK0mWg2v21dS9KH9Kh8m427hE5CKYFpWyhP8yAlJoPYTfLE7Bekb kPWsD36lb9Z59cB6Da2VGCnOnj00buBty2PcA3IOCag6ykjA6F8K9DossgWthKtaIy9i5x8ZsEG PUWuI3A/52AeHK0FIKCsIw6VzuUjMP70HILmg= X-Google-Smtp-Source: AGHT+IHHA/oGS3p+tLHWaHAvFQTIjHcw3aME6fzgwVhWuS7b1NgLYLejs28l5AZoGl8AQkfb80AvWQ== X-Received: by 2002:a17:903:2308:b0:20b:6d71:4140 with SMTP id d9443c01a7336-20e5a8f5fabmr135068245ad.44.1729475640402; Sun, 20 Oct 2024 18:54:00 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20e7eee650bsm15859985ad.34.2024.10.20.18.53.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 18:54:00 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: namangulati@google.com, edumazet@google.com, 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 v2 4/6] eventpoll: Trigger napi_busy_loop, if prefer_busy_poll is set Date: Mon, 21 Oct 2024 01:52:59 +0000 Message-Id: <20241021015311.95468-5-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241021015311.95468-1-jdamato@fastly.com> References: <20241021015311.95468-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org 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 --- v1 -> v2: - Rebased to apply now that commit b9ca079dd6b0 ("eventpoll: Annotate data-race of busy_poll_usecs") has been picked up from VFS. fs/eventpoll.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 1ae4542f0bd8..f9e0d9307dad 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 !!READ_ONCE(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 Oct 21 01:53:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13843493 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 91E5383CA0 for ; Mon, 21 Oct 2024 01:54:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729475645; cv=none; b=PBECYa4PDYOdubqXZJJ6m7omGWxKEymez/1alLIhHZjs+gJy9kDfhpgphQY0HQ4pQu4Tv4y23KQWGuen83kd81ffohL62D+LyJMlVqleo8uqrgOWYxUAaRoxMEwHYkAZrVHGs63PUlCDsnOJ+EoOJosc2/L5a6n7wx5gv6K52vw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729475645; c=relaxed/simple; bh=+v/H79GmiAG3naN0zeRg2nElJUiBqVhmyL2Hh1hlU1E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=K1rm+RvQuVTV5hODBJgHz94t1iB/m+7h88h47JGWV0/zbB4rO5ahlt0jjHo21jX66j3TOrQD0GD7OgTZuW/y3jiP54KH5mjywA9h2eRQnCZYOX9WfsdCvR4NkLT5RJJwAXVyEHrFmaoG467bGvcv0Z8nDnKJe70MK2bI2gavrIo= 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=jPaPMNaz; arc=none smtp.client-ip=209.85.214.178 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="jPaPMNaz" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-20c9978a221so45388535ad.1 for ; Sun, 20 Oct 2024 18:54:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1729475642; x=1730080442; 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=JmUjBpdJ0f8V/MHrwl+AGewKk5aAt+i1MtpvNR8b1Y8=; b=jPaPMNazIG9wKFrhCiVuME+1DCpbm3buJdEvqMBu/yXUuXMFWHrj7IiEkhnaMV9KZJ m/m5dncBvKrF9U0CB2ZPEaBkp0Xf5w3ftOpoeYIiyM0UI2HBOIQtaAGg+2iSzFbdH23f Sug6HtzSIp23FZ2OWhTySPXE8KVAlx60d5GTo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729475642; x=1730080442; 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=JmUjBpdJ0f8V/MHrwl+AGewKk5aAt+i1MtpvNR8b1Y8=; b=jrHkfY6f8BF3t/I0IQ+kod0EYnLmjjWXVFehkpVK9+OGJUCvrMihDhp2rrLM3lWYHj 1o8+QEC9bm6fG2MGIZzAKB35QqL+dirZ7gYYk15qWirtyI9fZ9vvDt0Im1bugIm0cO8r GU7ZgLEpC5xLREOVXpWyxnkfoY/JjL38nP+xnKWUBToMjyPYHX/yMDA4Ez5jKRYHH2hh 0U3mUg2R13Sabi9V6rxuiafRoCKHQ+6hxKsIjPch1XsOOTFH07xL/JYpcKucFMQ6CnNZ wTOdPWNA1hgaplOWR/ymv5BJtydFcP/1WF6nspwt05LyjLOqCVGgpfC5EE/r5d0fugwW BNjw== X-Gm-Message-State: AOJu0Yw/AjAJoTEJxiB/yivgXvaFKnTnSwE/3pfvdoKsHOuJ+4HeOX/f VxWhcD6T4v8+rOY3SUVlR1jw04DmxVhUqqZdZOz6B7qVb8EsS0tpOhnnKosZUbQVRm5SOj0bi10 EY+/vopGMmvYJY6LF9DJmyK8kjgDbF3szlm8FRjm2pDrgeiXevLUyibw8bDN7Hln4vb6Rj8CCId KZI6E3bHcPQ5pol6jHvnJOnDby6+rW1/y025I= X-Google-Smtp-Source: AGHT+IGVda21+4TkdnbM/4Q+uHbJcBEZbiTKQt97djp2s9YV3IPbRBsjbBBv8Rl+668P90LjyRMasw== X-Received: by 2002:a17:902:f906:b0:20b:8776:4906 with SMTP id d9443c01a7336-20e5a8ee770mr105564285ad.37.1729475642435; Sun, 20 Oct 2024 18:54:02 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20e7eee650bsm15859985ad.34.2024.10.20.18.54.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 18:54:01 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: namangulati@google.com, edumazet@google.com, 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 v2 5/6] eventpoll: Control irq suspension for prefer_busy_poll Date: Mon, 21 Oct 2024 01:53:00 +0000 Message-Id: <20241021015311.95468-6-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241021015311.95468-1-jdamato@fastly.com> References: <20241021015311.95468-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org 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 | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index f9e0d9307dad..36a657594352 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,22 @@ 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); +} + +static void ep_resume_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_resume_irqs(napi_id); +} + #else 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, return -EOPNOTSUPP; } +static void ep_suspend_napi_irqs(struct eventpoll *ep) +{ +} + +static void ep_resume_napi_irqs(struct eventpoll *ep) +{ +} + #endif /* CONFIG_NET_RX_BUSY_POLL */ /* @@ -788,6 +814,7 @@ static bool ep_refcount_dec_and_test(struct eventpoll *ep) 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 +2032,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) From patchwork Mon Oct 21 01:53:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13843485 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 4911F126BE0 for ; Mon, 21 Oct 2024 01:54:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729475647; cv=none; b=WbAAV9IjRESlalwnPu6D0buV9pqL81ukfcUnCv52+M6Ft8yYFTsa9ybxnzC2KVnVWl2DrmtozJz4mM3cLkZx9wGyDiWfSym2mLDOmO7KKRry14z5nZdVrT130CSgYfjBjIyEhNPqtlnwlH737KIxs5HNSHg+8iYdmjbRPjc5ZJw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729475647; c=relaxed/simple; bh=UKcbLgaIhruPiHQVux7frT2vyssaPMGMH3qyAhwocGw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jVCsy/+vNddY1R3LyIEW4by+N1a0ZHKJ5ZG5P7qdCImkR5qSfXH9+BijLyv1xbQULygHstf5Llr1FU01Ae5of0qSkMxbrhOZcozvsiMy1I+oqWruB5BEniJ0x2TCfbG7BxmgvNXO4gnD7TwDieERrJNxeCq1wvNR9Kt+v1tCPiE= 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=dQV3fgXV; arc=none smtp.client-ip=209.85.214.173 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="dQV3fgXV" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-20ce5e3b116so29605435ad.1 for ; Sun, 20 Oct 2024 18:54:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1729475644; x=1730080444; 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=ov+a74yyWVssGZ0VVpLag6M6zuR8CKA5GgGeFDgsMcI=; b=dQV3fgXVYxTZflvEtCMJCkH9wPk6AyRT1vExTi+WroPVPIehXv/5vhvLdRIfoRe4iM MxPrXj/K3sHSPtluNRlbHGTP3uDS+1mmLw95ncELP8qAqog2nP+4snjohk3ucVQw+7ff 2ydJrPXGimyuYMfPOyPrZzjScL7DvU0vn9X3A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729475644; x=1730080444; 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=ov+a74yyWVssGZ0VVpLag6M6zuR8CKA5GgGeFDgsMcI=; b=NfnyE6Zay8W9em0tq5Fg5huoo3h9zbLtL68yQL5sNgWoXqn0dHxtf5LYwVA7TKw7gR 6Dytk9UyjessG55AYNUAJ4/Xnhvzs66nqgMEg/1B+C8ajLSFvuJ3KYtbmwbVVRgqznV8 LKOq3xoBwE4YuAo8e0etWv8ktJw6K9tG7x8E2thZT8TJ1/LYkfYdA8bRkr1QKn05rvzE OsrVl5z7yPafufGOZjFsWZtXRu4ehDbFBugfzt5qGDm9CDBZ/AFPdv9S3e+FPwgCBt77 N///eoNzLLLxXZcDU95g0cA5UhtA7zEEc97S0Axs/qzBpGTSDaqfg3AFIVHmxTpGhvep Io7g== X-Forwarded-Encrypted: i=1; AJvYcCXG8MzIScirZ4u9fshkUcyt2Opg5MXzLl9AnZrJctYWSz60NhwkddDk1qJ5wmUKdTGGaFk=@vger.kernel.org X-Gm-Message-State: AOJu0YzMOwif+gdJ/Ct3dPVeDVZGC1IoMDraykxOwGjQfoDSYMYWAXJ3 DU6ksPHlTp77tJL65K0BlK2hi1PaK+P8hzArM4YVFntYR3KApXOV+cWcc0FYL5w= X-Google-Smtp-Source: AGHT+IFRh1M+as63n98NkQTDVZCHlHy/fZhBOPIE+Ea8KXRBufysFtL+AR7pOkA5nc0vjrv7IGmlBg== X-Received: by 2002:a17:903:22c2:b0:20c:f9ec:cd8a with SMTP id d9443c01a7336-20e5a79f596mr152490435ad.7.1729475644492; Sun, 20 Oct 2024 18:54:04 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20e7eee650bsm15859985ad.34.2024.10.20.18.54.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 18:54:03 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: namangulati@google.com, edumazet@google.com, 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, Joe Damato , Martin Karsten , "David S. Miller" , Paolo Abeni , Jonathan Corbet , linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-kernel@vger.kernel.org (open list), bpf@vger.kernel.org (open list:BPF [MISC]:Keyword:(?:\b|_)bpf(?:\b|_)) Subject: [PATCH net-next v2 6/6] docs: networking: Describe irq suspension Date: Mon, 21 Oct 2024 01:53:01 +0000 Message-Id: <20241021015311.95468-7-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241021015311.95468-1-jdamato@fastly.com> References: <20241021015311.95468-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Describe irq suspension, the epoll ioctls, and the tradeoffs of using different gro_flush_timeout values. Signed-off-by: Joe Damato Co-developed-by: Martin Karsten Signed-off-by: Martin Karsten Reviewed-by: Bagas Sanjaya --- v1 -> v2: - Updated documentation to describe the per-NAPI configuration parameters. Documentation/networking/napi.rst | 132 +++++++++++++++++++++++++++++- 1 file changed, 130 insertions(+), 2 deletions(-) diff --git a/Documentation/networking/napi.rst b/Documentation/networking/napi.rst index dfa5d549be9c..3b43477a52ce 100644 --- a/Documentation/networking/napi.rst +++ b/Documentation/networking/napi.rst @@ -192,6 +192,28 @@ is reused to control the delay of the timer, while ``napi_defer_hard_irqs`` controls the number of consecutive empty polls before NAPI gives up and goes back to using hardware IRQs. +The above parameters can also be set on a per-NAPI basis using netlink via +netdev-genl. This can be done programmatically in a user application or by +using a script included in the kernel source tree: ``tools/net/ynl/cli.py``. + +For example, using the script: + +.. code-block:: bash + + $ kernel-source/tools/net/ynl/cli.py \ + --spec Documentation/netlink/specs/netdev.yaml \ + --do napi-set \ + --json='{"id": 345, + "defer-hard-irqs": 111, + "gro-flush-timeout": 11111}' + +Similarly, the parameter ``irq-suspend-timeout`` can be set using netlink +via netdev-genl. There is no global sysfs parameter for this value. + +``irq_suspend_timeout`` is used to determine how long an application can +completely suspend IRQs. It is used in combination with SO_PREFER_BUSY_POLL, +which can be set on a per-epoll context basis with ``EPIOCSPARAMS`` ioctl. + .. _poll: Busy polling @@ -207,6 +229,46 @@ selected sockets or using the global ``net.core.busy_poll`` and ``net.core.busy_read`` sysctls. An io_uring API for NAPI busy polling also exists. +epoll-based busy polling +------------------------ + +It is possible to trigger packet processing directly from calls to +``epoll_wait``. In order to use this feature, a user application must ensure +all file descriptors which are added to an epoll context have the same NAPI ID. + +If the application uses a dedicated acceptor thread, the application can obtain +the NAPI ID of the incoming connection using SO_INCOMING_NAPI_ID and then +distribute that file descriptor to a worker thread. The worker thread would add +the file descriptor to its epoll context. This would ensure each worker thread +has an epoll context with FDs that have the same NAPI ID. + +Alternatively, if the application uses SO_REUSEPORT, a bpf or ebpf program be +inserted to distribute incoming connections to threads such that each thread is +only given incoming connections with the same NAPI ID. Care must be taken to +carefully handle cases where a system may have multiple NICs. + +In order to enable busy polling, there are two choices: + +1. ``/proc/sys/net/core/busy_poll`` can be set with a time in useconds to busy + loop waiting for events. This is a system-wide setting and will cause all + epoll-based applications to busy poll when they call epoll_wait. This may + not be desirable as many applications may not have the need to busy poll. + +2. Applications using recent kernels can issue an ioctl on the epoll context + file descriptor to set (``EPIOCSPARAMS``) or get (``EPIOCGPARAMS``) ``struct + epoll_params``:, which user programs can define as follows: + +.. code-block:: c + + struct epoll_params { + uint32_t busy_poll_usecs; + uint16_t busy_poll_budget; + uint8_t prefer_busy_poll; + + /* pad the struct to a multiple of 64bits */ + uint8_t __pad; + }; + IRQ mitigation --------------- @@ -222,12 +284,78 @@ Such applications can pledge to the kernel that they will perform a busy polling operation periodically, and the driver should keep the device IRQs permanently masked. This mode is enabled by using the ``SO_PREFER_BUSY_POLL`` socket option. To avoid system misbehavior the pledge is revoked -if ``gro_flush_timeout`` passes without any busy poll call. +if ``gro_flush_timeout`` passes without any busy poll call. For epoll-based +busy polling applications, the ``prefer_busy_poll`` field of ``struct +epoll_params`` can be set to 1 and the ``EPIOCSPARAMS`` ioctl can be issued to +enable this mode. See the above section for more details. The NAPI budget for busy polling is lower than the default (which makes sense given the low latency intention of normal busy polling). This is not the case with IRQ mitigation, however, so the budget can be adjusted -with the ``SO_BUSY_POLL_BUDGET`` socket option. +with the ``SO_BUSY_POLL_BUDGET`` socket option. For epoll-based busy polling +applications, the ``busy_poll_budget`` field can be adjusted to the desired value +in ``struct epoll_params`` and set on a specific epoll context using the ``EPIOCSPARAMS`` +ioctl. See the above section for more details. + +It is important to note that choosing a large value for ``gro_flush_timeout`` +will defer IRQs to allow for better batch processing, but will induce latency +when the system is not fully loaded. Choosing a small value for +``gro_flush_timeout`` can cause interference of the user application which is +attempting to busy poll by device IRQs and softirq processing. This value +should be chosen carefully with these tradeoffs in mind. epoll-based busy +polling applications may be able to mitigate how much user processing happens +by choosing an appropriate value for ``maxevents``. + +Users may want to consider an alternate approach, IRQ suspension, to help deal +with these tradeoffs. + +IRQ suspension +-------------- + +IRQ suspension is a mechanism wherein device IRQs are masked while epoll +triggers NAPI packet processing. + +While application calls to epoll_wait successfully retrieve events, the kernel will +defer the IRQ suspension timer. If the kernel does not retrieve any events +while busy polling (for example, because network traffic levels subsided), IRQ +suspension is disabled and the IRQ mitigation strategies described above are +engaged. + +This allows users to balance CPU consumption with network processing +efficiency. + +To use this mechanism: + + 1. The per-NAPI config parameter ``irq_suspend_timeout`` should be set to the + maximum time (in nanoseconds) the application can have its IRQs + suspended. This is done using netlink, as described above. This timeout + serves as a safety mechanism to restart IRQ driver interrupt processing if + the application has stalled. This value should be chosen so that it covers + the amount of time the user application needs to process data from its + call to epoll_wait, noting that applications can control how much data + they retrieve by setting ``max_events`` when calling epoll_wait. + + 2. The sysfs parameter or per-NAPI config parameters ``gro_flush_timeout`` + and ``napi_defer_hard_irqs`` can be set to low values. They will be used + to defer IRQs after busy poll has found no data. + + 3. The ``prefer_busy_poll`` flag must be set to true. This can be done using + the ``EPIOCSPARAMS`` ioctl as described above. + + 4. The application uses epoll as described above to trigger NAPI packet + processing. + +As mentioned above, as long as subsequent calls to epoll_wait return events to +userland, the ``irq_suspend_timeout`` is deferred and IRQs are disabled. This +allows the application to process data without interference. + +Once a call to epoll_wait results in no events being found, IRQ suspension is +automatically disabled and the ``gro_flush_timeout`` and +``napi_defer_hard_irqs`` mitigation mechanisms take over. + +It is expected that ``irq_suspend_timeout`` will be set to a value much larger +than ``gro_flush_timeout`` as ``irq_suspend_timeout`` should suspend IRQs for +the duration of one userland processing cycle. .. _threaded: