From nobody Wed Nov 27 16:33:25 2024 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 36CEE2770B for ; Wed, 9 Oct 2024 00:55:44 +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=1728435346; cv=none; b=sqvVMeu1fV8nEi1bg0Tfj3O/blC5LwKAfPRL2wpHMNMEd0/MRhVzzACoeCRB7zhql5RSwSIy8Ql9AkIGCDXNJPeH7T54goOcvXaIYdqOYETR07bukdDtMDWaegVe6UkT9Ji/79Br/ER1XHgH+TQPtcXB3cX9l5uJVRgeMhZg6rg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728435346; c=relaxed/simple; bh=OSjhYgCraL1pjtRCrrLJx+dP50hJvvrgzBqU+eXq8xE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=erP5h7m4eW2Cc6BnzfSiYSiwlE8RtlLgEX6DHG3KYU+NbUWl6VVq2VA7299DpQGrJ11NNXBPJT+OO4sQNCgUYLGeFgPoygUdAweGseuR3puy5g1RWM6ZVHfahQCD1RI23gVhb7N3t3VbOMYxt915iN+jTRcOfOXsY39HrSTt85E= 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=l0A7LuWB; 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="l0A7LuWB" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-20b49ee353cso58475135ad.2 for ; Tue, 08 Oct 2024 17:55:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1728435343; x=1729040143; 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=deg8XZq5zNjaBqZWSFjh4SCyJKHLBliWqnssKGJsyB8=; b=l0A7LuWBzgJAzgoYPXk86O0N5RQ0rMFx2V78rdUiOaFbLrPBUUNjxcVrHYX7J011UX CHACp7P210GACD6hrMgr/NDJAU0uDm9+3uxhH0ttz4VHAt5u2VMHkikqjIxF4WIkA5MI VoCH7+HLOBZeeOhdc0btZ7q93rR98u84i45g4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728435343; x=1729040143; 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=deg8XZq5zNjaBqZWSFjh4SCyJKHLBliWqnssKGJsyB8=; b=cyqSYJvi7pNvow1nAXW68Tgue1JuJBYftTL8k4vax5G2IWDl92rDKv/ha7KKAunuMb rKSIDJrNpt9ydU7vDN8c5VL7He7btwChvJR92fdte4H4Jy7Sn881GQ6offBpr1EJk25q 5GI7ERmHCTOBhAWV93zNVveriQecfLp91ykX54uI7HA1YdkUiXM84CRPRbAT/TwSGQLf wgfH68gMpnaU2haqEv5Fz6nEH3jJGWjIGU/2Ow+FluQizBhRXUwQk7oxcE/Eb6ZrbBjA l2UwHEJc8vEBn17H9kKRYqC33MBTrRElbGQWdASNwZkdBqQTjnBjeze05XD0k3FHp5qC Kyxw== X-Forwarded-Encrypted: i=1; AJvYcCXZEg1bKZXXP+dpLQY3a+NEajEQXZRsFwA4X13gZnNsFvqx0sw0xROM/Pa1eto+fSsF5DJiaQbQ/4oZDsQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yy+AhmYWuQ+U5gwoCzsJipkrTzjZJCgQvqhJLa7L63FNSmmLdO5 97er3lDJ64wDhoVrUDlVPqNxZKC0pV08Vo8TxrI5GSIQ6ujCIPgOGZCS+MTdTTA= X-Google-Smtp-Source: AGHT+IG7nsJEQbRVf1GCMMh5naPYCm+uYaFdo+uqFeHXyzS5A7OHYrSNQySa5p3gC3x8esQTp16VRw== X-Received: by 2002:a17:903:2289:b0:20c:5263:247a with SMTP id d9443c01a7336-20c637809c9mr18295855ad.38.1728435343546; Tue, 08 Oct 2024 17:55:43 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cec92sm60996045ad.101.2024.10.08.17.55.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:55:43 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, willemdebruijn.kernel@gmail.com, Joe Damato , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Jiri Pirko , Sebastian Andrzej Siewior , Lorenzo Bianconi , Johannes Berg , Breno Leitao , Alexander Lobakin , linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-kernel@vger.kernel.org (open list) Subject: [net-next v5 1/9] net: napi: Make napi_defer_hard_irqs per-NAPI Date: Wed, 9 Oct 2024 00:54:55 +0000 Message-Id: <20241009005525.13651-2-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241009005525.13651-1-jdamato@fastly.com> References: <20241009005525.13651-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" Add defer_hard_irqs to napi_struct in preparation for per-NAPI settings. The existing sysfs parameter is respected; writes to sysfs will write to all NAPI structs for the device and the net_device defer_hard_irq field. Reads from sysfs show the net_device field. The ability to set defer_hard_irqs on specific NAPI instances will be added in a later commit, via netdev-genl. Signed-off-by: Joe Damato Reviewed-by: Eric Dumazet Reviewed-by: Jakub Kicinski --- .../networking/net_cachelines/net_device.rst | 2 +- include/linux/netdevice.h | 3 +- net/core/dev.c | 10 +++--- net/core/dev.h | 36 +++++++++++++++++++ net/core/net-sysfs.c | 2 +- 5 files changed, 45 insertions(+), 8 deletions(-) diff --git a/Documentation/networking/net_cachelines/net_device.rst b/Docum= entation/networking/net_cachelines/net_device.rst index 556711c4d3cf..d78b1362f12a 100644 --- a/Documentation/networking/net_cachelines/net_device.rst +++ b/Documentation/networking/net_cachelines/net_device.rst @@ -100,7 +100,6 @@ unsigned_int num_rx_queues unsigned_int real_num_rx_queues - = read_mostly get_rps_cpu struct_bpf_prog* xdp_prog - = read_mostly netif_elide_gro() unsigned_long gro_flush_timeout - = read_mostly napi_complete_done -u32 napi_defer_hard_irqs - = read_mostly napi_complete_done unsigned_int gro_max_size - = read_mostly skb_gro_receive unsigned_int gro_ipv4_max_size - = read_mostly skb_gro_receive rx_handler_func_t* rx_handler read_mostly = - __netif_receive_skb_core @@ -185,3 +184,4 @@ struct_dpll_pin* dpll_pin struct hlist_head page_pools struct dim_irq_moder* irq_moder u64 max_pacing_offload_horizon +u32 napi_defer_hard_irqs diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 3baf8e539b6f..9042920cdd1a 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -373,6 +373,7 @@ struct napi_struct { unsigned int napi_id; struct hrtimer timer; struct task_struct *thread; + u32 defer_hard_irqs; /* control-path-only fields follow */ struct list_head dev_list; struct hlist_node napi_hash_node; @@ -2077,7 +2078,6 @@ struct net_device { unsigned int real_num_rx_queues; struct netdev_rx_queue *_rx; unsigned long gro_flush_timeout; - u32 napi_defer_hard_irqs; unsigned int gro_max_size; unsigned int gro_ipv4_max_size; rx_handler_func_t __rcu *rx_handler; @@ -2405,6 +2405,7 @@ struct net_device { struct dim_irq_moder *irq_moder; =20 u64 max_pacing_offload_horizon; + u32 napi_defer_hard_irqs; =20 u8 priv[] ____cacheline_aligned __counted_by(priv_len); diff --git a/net/core/dev.c b/net/core/dev.c index ea5fbcd133ae..3487eec284a6 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6231,7 +6231,7 @@ bool napi_complete_done(struct napi_struct *n, int wo= rk_done) if (work_done) { if (n->gro_bitmask) timeout =3D READ_ONCE(n->dev->gro_flush_timeout); - n->defer_hard_irqs_count =3D READ_ONCE(n->dev->napi_defer_hard_irqs); + n->defer_hard_irqs_count =3D napi_get_defer_hard_irqs(n); } if (n->defer_hard_irqs_count > 0) { n->defer_hard_irqs_count--; @@ -6369,7 +6369,7 @@ static void busy_poll_stop(struct napi_struct *napi, = void *have_poll_lock, bpf_net_ctx =3D bpf_net_ctx_set(&__bpf_net_ctx); =20 if (flags & NAPI_F_PREFER_BUSY_POLL) { - napi->defer_hard_irqs_count =3D READ_ONCE(napi->dev->napi_defer_hard_irq= s); + napi->defer_hard_irqs_count =3D napi_get_defer_hard_irqs(napi); timeout =3D READ_ONCE(napi->dev->gro_flush_timeout); if (napi->defer_hard_irqs_count && timeout) { hrtimer_start(&napi->timer, ns_to_ktime(timeout), HRTIMER_MODE_REL_PINN= ED); @@ -6651,6 +6651,7 @@ void netif_napi_add_weight(struct net_device *dev, st= ruct napi_struct *napi, INIT_HLIST_NODE(&napi->napi_hash_node); hrtimer_init(&napi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED); napi->timer.function =3D napi_watchdog; + napi_set_defer_hard_irqs(napi, READ_ONCE(dev->napi_defer_hard_irqs)); init_gro_hash(napi); napi->skb =3D NULL; INIT_LIST_HEAD(&napi->rx_list); @@ -11057,7 +11058,7 @@ void netdev_sw_irq_coalesce_default_on(struct net_d= evice *dev) =20 if (!IS_ENABLED(CONFIG_PREEMPT_RT)) { dev->gro_flush_timeout =3D 20000; - dev->napi_defer_hard_irqs =3D 1; + netdev_set_defer_hard_irqs(dev, 1); } } EXPORT_SYMBOL_GPL(netdev_sw_irq_coalesce_default_on); @@ -11995,7 +11996,6 @@ static void __init net_dev_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, real= _num_rx_queues); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, _rx); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, gro_= flush_timeout); - CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, napi= _defer_hard_irqs); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, gro_= max_size); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, gro_= ipv4_max_size); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, rx_h= andler); @@ -12007,7 +12007,7 @@ static void __init net_dev_struct_check(void) #ifdef CONFIG_NET_XGRESS CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, tcx_= ingress); #endif - CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_rx, 104); + CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_rx, 100); } =20 /* diff --git a/net/core/dev.h b/net/core/dev.h index 5654325c5b71..b3792219879b 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -138,6 +138,42 @@ static inline void netif_set_gro_ipv4_max_size(struct = net_device *dev, WRITE_ONCE(dev->gro_ipv4_max_size, size); } =20 +/** + * napi_get_defer_hard_irqs - get the NAPI's defer_hard_irqs + * @n: napi struct to get the defer_hard_irqs field from + * + * Return: the per-NAPI value of the defar_hard_irqs field. + */ +static inline u32 napi_get_defer_hard_irqs(const struct napi_struct *n) +{ + return READ_ONCE(n->defer_hard_irqs); +} + +/** + * napi_set_defer_hard_irqs - set the defer_hard_irqs for a napi + * @n: napi_struct to set the defer_hard_irqs field + * @defer: the value the field should be set to + */ +static inline void napi_set_defer_hard_irqs(struct napi_struct *n, u32 def= er) +{ + WRITE_ONCE(n->defer_hard_irqs, defer); +} + +/** + * netdev_set_defer_hard_irqs - set defer_hard_irqs for all NAPIs of a net= dev + * @netdev: the net_device for which all NAPIs will have defer_hard_irqs s= et + * @defer: the defer_hard_irqs value to set + */ +static inline void netdev_set_defer_hard_irqs(struct net_device *netdev, + u32 defer) +{ + struct napi_struct *napi; + + WRITE_ONCE(netdev->napi_defer_hard_irqs, defer); + list_for_each_entry(napi, &netdev->napi_list, dev_list) + napi_set_defer_hard_irqs(napi, defer); +} + int rps_cpumask_housekeeping(struct cpumask *mask); =20 #if defined(CONFIG_DEBUG_NET) && defined(CONFIG_BPF_SYSCALL) diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 05cf5347f25e..25125f356a15 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -429,7 +429,7 @@ static int change_napi_defer_hard_irqs(struct net_devic= e *dev, unsigned long val if (val > S32_MAX) return -ERANGE; =20 - WRITE_ONCE(dev->napi_defer_hard_irqs, val); + netdev_set_defer_hard_irqs(dev, (u32)val); return 0; } =20 --=20 2.34.1 From nobody Wed Nov 27 16:33:25 2024 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 E9BE82C859 for ; Wed, 9 Oct 2024 00:55:48 +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=1728435350; cv=none; b=dKL7AqDLsnzaLlpIrgkL443WJNqdK7essmScZlyktB7m20ymJAW6u8KSSmEmh0EH6k8LsOjV5zM7Qj8vrS3W3G4G9qJyCSpOTT7D7HM3lEW3jbsi9U35SmNsmlGhgJrngz/IaZwUoY3GrVh3MfRIlVwJ1ud4aX1YUn6uwIMG8L0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728435350; c=relaxed/simple; bh=xH668O18crr5A1NH6k8Aj+JP8S+91oltJLMlwh58J78=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LTo27k1Ms+cTlKdionWpgT5LMqjiDLk5Ea7BF2hfgmWzKtvakoX37qncC3yvGc2yWEYshxZNL2l8tH3P83LyowODPZ8t57YSLtetoOfM+XBiyH0tzRrzJal8HHM6j4fPYA3d1xtxF8SqYfI+6OdR/pTHAovYlfpdM9fGz07yC6M= 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=Zl9J5qaQ; 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="Zl9J5qaQ" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-20b95359440so53949595ad.0 for ; Tue, 08 Oct 2024 17:55:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1728435348; x=1729040148; 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=mqUcKdW42CrdR2Dee2W+Xtk6g2oMU7HQioOPLi4n5sw=; b=Zl9J5qaQZi+UghVH3h2kfroIOeWVJ/hgQg9C+B+DNgblOSnvfeYtEVj2Fx2hg7Ce/p 3svvzN5bieYuhXTJaGmRFCHToR/KGfDTkDn+fvtu1ICWX/RHcovFkTv/fqxLtEOmNbDn AfymLN1kmIJgnpAQJbJdSBrblDAKT3UjoBy+I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728435348; x=1729040148; 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=mqUcKdW42CrdR2Dee2W+Xtk6g2oMU7HQioOPLi4n5sw=; b=hTsu/Csc3UpF74rNy+Kdvtoy+Xyk9FG/d8aXO5WhpvQukI6yztnG/cV3W3D3wqBhQ4 2rlUt/i3ynhdGZ2asSdGgwy1CBXLTIFnJCyIx0Msm37nGOvnGDnlbQXN/TAjpWsEcCVU cfSduvEKTr5rbYXG5LA3bOmuj738FT6LtrXAIgDcyclI8lhipxEkx7aBjIVkidFHD1r+ A+VzB5Ylp0WMJJcPt88hGPkSdZ8rxVuUXT6pOIp7VP5MAkxkQZ62whNH3s4bmXWDmH4V 3yO/NmpBKoAvuEB1YYgdmK1Mu5Gdrw9j88hkNibBbWWif83ied6GhrKMeP5D8mr7jxZv pKGQ== X-Forwarded-Encrypted: i=1; AJvYcCWvsCgxT30xRq3n0G/pkHtaeZ2CedLZonth99O/4gfisx5z3DcgAYWQamLnVgJn0j867FnBRZm4pU6D+sY=@vger.kernel.org X-Gm-Message-State: AOJu0YxBsOLMSQPM+9hQJSqlCictIRxSu1eP9ge+DWl0+rMTJEodbrWJ ZFjuRA3tRRSCwgdMvL1DK5EkdqIH5DbvGVC9p7nrk3BJckO+NFAxuBXw0lSBNJQ= X-Google-Smtp-Source: AGHT+IGfMGlqV4u9Qk5t0M3OQWhoi/AtJl6chgAjQYihLIPfXcXG6om5Wm1XMryvJEMq2Go13N+ZEg== X-Received: by 2002:a17:903:41c5:b0:20c:637e:b28 with SMTP id d9443c01a7336-20c637e0b3bmr11984985ad.39.1728435348225; Tue, 08 Oct 2024 17:55:48 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cec92sm60996045ad.101.2024.10.08.17.55.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:55:47 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, willemdebruijn.kernel@gmail.com, Joe Damato , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Donald Hunter , Jesper Dangaard Brouer , Mina Almasry , Xuan Zhuo , Daniel Jurgens , linux-kernel@vger.kernel.org (open list) Subject: [net-next v5 2/9] netdev-genl: Dump napi_defer_hard_irqs Date: Wed, 9 Oct 2024 00:54:56 +0000 Message-Id: <20241009005525.13651-3-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241009005525.13651-1-jdamato@fastly.com> References: <20241009005525.13651-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" Support dumping defer_hard_irqs for a NAPI ID. Signed-off-by: Joe Damato Reviewed-by: Eric Dumazet Reviewed-by: Jakub Kicinski --- Documentation/netlink/specs/netdev.yaml | 8 ++++++++ include/uapi/linux/netdev.h | 1 + net/core/netdev-genl.c | 6 ++++++ tools/include/uapi/linux/netdev.h | 1 + 4 files changed, 16 insertions(+) diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlin= k/specs/netdev.yaml index 08412c279297..585e87ec3c16 100644 --- a/Documentation/netlink/specs/netdev.yaml +++ b/Documentation/netlink/specs/netdev.yaml @@ -248,6 +248,13 @@ attribute-sets: threaded mode. If NAPI is not in threaded mode (i.e. uses nor= mal softirq context), the attribute will be absent. type: u32 + - + name: defer-hard-irqs + doc: The number of consecutive empty polls before IRQ deferral ends + and hardware IRQs are re-enabled. + type: u32 + checks: + max: s32-max - name: queue attributes: @@ -636,6 +643,7 @@ operations: - ifindex - irq - pid + - defer-hard-irqs dump: request: attributes: diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h index 7c308f04e7a0..13dc0b027e86 100644 --- a/include/uapi/linux/netdev.h +++ b/include/uapi/linux/netdev.h @@ -122,6 +122,7 @@ enum { NETDEV_A_NAPI_ID, NETDEV_A_NAPI_IRQ, NETDEV_A_NAPI_PID, + NETDEV_A_NAPI_DEFER_HARD_IRQS, =20 __NETDEV_A_NAPI_MAX, NETDEV_A_NAPI_MAX =3D (__NETDEV_A_NAPI_MAX - 1) diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c index 1cb954f2d39e..de9bd76f43f8 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) { + u32 napi_defer_hard_irqs; void *hdr; pid_t pid; =20 @@ -189,6 +190,11 @@ netdev_nl_napi_fill_one(struct sk_buff *rsp, struct na= pi_struct *napi, goto nla_put_failure; } =20 + napi_defer_hard_irqs =3D napi_get_defer_hard_irqs(napi); + if (nla_put_s32(rsp, NETDEV_A_NAPI_DEFER_HARD_IRQS, + napi_defer_hard_irqs)) + goto nla_put_failure; + genlmsg_end(rsp, hdr); =20 return 0; diff --git a/tools/include/uapi/linux/netdev.h b/tools/include/uapi/linux/n= etdev.h index 7c308f04e7a0..13dc0b027e86 100644 --- a/tools/include/uapi/linux/netdev.h +++ b/tools/include/uapi/linux/netdev.h @@ -122,6 +122,7 @@ enum { NETDEV_A_NAPI_ID, NETDEV_A_NAPI_IRQ, NETDEV_A_NAPI_PID, + NETDEV_A_NAPI_DEFER_HARD_IRQS, =20 __NETDEV_A_NAPI_MAX, NETDEV_A_NAPI_MAX =3D (__NETDEV_A_NAPI_MAX - 1) --=20 2.34.1 From nobody Wed Nov 27 16:33:25 2024 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 8B84918EAD for ; Wed, 9 Oct 2024 00:55:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728435357; cv=none; b=AX7NKFZpgMjLrLyXO9SsB6eAmfGRBwHv6INegdfOrMycP+MftatSxSHKQCPZPYyIB8/adL0/vINH8qPPoYOzMfsHfo0lpG6NTxj0+IYaZsDeEgIWDLfmeRe/KGnHlznaDCXUedq1/FvwcyZxeUnuoC1SmepsXNTl70Q85i5ndiQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728435357; c=relaxed/simple; bh=L7ye8pmrftNu3IkpoKdu8GwvDW1PO1p+AP0iNfFSjhA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kdhH8Yp+msRvDNrl9g2FBHhEsYKrDVeRLYioaJ6blk4jdblZGOz8lXDSqgWjd1vJPNhucnHykz0eXltDuq4lISEfIEHp6Ym2VIdxwNQrbDvXeCD+qXx2kybs+KMASQwFrxKeY7fzj2k9As2yTyJavepS5wHxTKqcauDNU/ZiegE= 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=EMsQJ7a+; arc=none smtp.client-ip=209.85.214.175 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="EMsQJ7a+" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-20b9b35c7c3so65730235ad.3 for ; Tue, 08 Oct 2024 17:55:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1728435355; x=1729040155; 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=ha0YuEKd9nmgN8+z/fTji7Q40w0sfoYW6qAEsAvCTJQ=; b=EMsQJ7a+tZ1K0NbUlZ6K5O7RX/g+0Cc/8EuvOT9X40mG9Bz0vtpl/k/AZfU6rQLq4j z8hYfCIXqUCYmLqJ64nt9iSpph1BiYdwswq/JVVLGCtOSy9i+zpVnClCiUCZ5qGnsyxj PuBu+T3CTQONi1Z7fOZts+pxv3hJVBvne+KVQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728435355; x=1729040155; 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=ha0YuEKd9nmgN8+z/fTji7Q40w0sfoYW6qAEsAvCTJQ=; b=S5GunoxtInnz8MCK2O9q7uuUZbV0Pj01vf94ZPyA2rmSJadwKE30fZx2wRS3YaEVCp ADdtNiynW/+e9WdLGrs8v70ltHUe+NpM8DHZBMSJkzDBxFYkW0reCWUkBLaBdGwsU6Y2 rEMKdfpM+vjwanWdFgNEHYkpM10O9yYLns2hzH5leJzXytTzI+JiQx2udAjf1VW9qsC1 hjrvxvtmTxXW8hT/NTiQiUnknV2bhBaXeOmk2usu6rRGAu1pTAx7tYiilECxcX5bmdfE gHFpHD2O6fzfJjRVB78itDxLyAxnPmxhGRqnoc2E025i/8qP7p9VJEA3ylQit4fOBiEu 1y3w== X-Forwarded-Encrypted: i=1; AJvYcCW9QQqpDR9Nzg5l2DCBwXufWALSbVfr99JJKP49cXziRKlMHpt/s1PMqgL45eD00TR5bPJBm6oqwmK7Cek=@vger.kernel.org X-Gm-Message-State: AOJu0YwSezDM22bx43QhzxsNpk529Yb0AqQYCv7J+BQqhkKwriIFdAVH 4RHdkAtPGIl+t50UdguuNA9pDyEhJaunqQ6X3qPEFT9P9A3tl0x0zDVU/80H8Gs= X-Google-Smtp-Source: AGHT+IEmQPUV6/8+Ao7RL15qOhFm881mHN5EgoEZfCzj2eAg1fFmgFosCzKUGOAUHC9LSzRKIvtmDA== X-Received: by 2002:a17:902:c451:b0:20b:a25e:16c5 with SMTP id d9443c01a7336-20c639157c5mr10973795ad.53.1728435354802; Tue, 08 Oct 2024 17:55:54 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cec92sm60996045ad.101.2024.10.08.17.55.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:55:53 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, willemdebruijn.kernel@gmail.com, Joe Damato , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Jiri Pirko , Sebastian Andrzej Siewior , Lorenzo Bianconi , Kory Maincent , Johannes Berg , Breno Leitao , Alexander Lobakin , linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-kernel@vger.kernel.org (open list) Subject: [net-next v5 3/9] net: napi: Make gro_flush_timeout per-NAPI Date: Wed, 9 Oct 2024 00:54:57 +0000 Message-Id: <20241009005525.13651-4-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241009005525.13651-1-jdamato@fastly.com> References: <20241009005525.13651-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" Allow per-NAPI gro_flush_timeout setting. The existing sysfs parameter is respected; writes to sysfs will write to all NAPI structs for the device and the net_device gro_flush_timeout field. Reads from sysfs will read from the net_device field. The ability to set gro_flush_timeout on specific NAPI instances will be added in a later commit, via netdev-genl. Signed-off-by: Joe Damato Reviewed-by: Eric Dumazet Reviewed-by: Jakub Kicinski --- .../networking/net_cachelines/net_device.rst | 2 +- include/linux/netdevice.h | 3 +- net/core/dev.c | 12 +++--- net/core/dev.h | 40 +++++++++++++++++++ net/core/net-sysfs.c | 2 +- 5 files changed, 50 insertions(+), 9 deletions(-) diff --git a/Documentation/networking/net_cachelines/net_device.rst b/Docum= entation/networking/net_cachelines/net_device.rst index d78b1362f12a..3ab663b6cf16 100644 --- a/Documentation/networking/net_cachelines/net_device.rst +++ b/Documentation/networking/net_cachelines/net_device.rst @@ -99,7 +99,6 @@ struct_netdev_queue* _rx = read_mostly unsigned_int num_rx_queues = =20 unsigned_int real_num_rx_queues - = read_mostly get_rps_cpu struct_bpf_prog* xdp_prog - = read_mostly netif_elide_gro() -unsigned_long gro_flush_timeout - = read_mostly napi_complete_done unsigned_int gro_max_size - = read_mostly skb_gro_receive unsigned_int gro_ipv4_max_size - = read_mostly skb_gro_receive rx_handler_func_t* rx_handler read_mostly = - __netif_receive_skb_core @@ -184,4 +183,5 @@ struct_dpll_pin* dpll_pin struct hlist_head page_pools struct dim_irq_moder* irq_moder u64 max_pacing_offload_horizon +unsigned_long gro_flush_timeout u32 napi_defer_hard_irqs diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 9042920cdd1a..4239a4a9d295 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -373,6 +373,7 @@ struct napi_struct { unsigned int napi_id; struct hrtimer timer; struct task_struct *thread; + unsigned long gro_flush_timeout; u32 defer_hard_irqs; /* control-path-only fields follow */ struct list_head dev_list; @@ -2077,7 +2078,6 @@ struct net_device { int ifindex; unsigned int real_num_rx_queues; struct netdev_rx_queue *_rx; - unsigned long gro_flush_timeout; unsigned int gro_max_size; unsigned int gro_ipv4_max_size; rx_handler_func_t __rcu *rx_handler; @@ -2405,6 +2405,7 @@ struct net_device { struct dim_irq_moder *irq_moder; =20 u64 max_pacing_offload_horizon; + unsigned long gro_flush_timeout; u32 napi_defer_hard_irqs; =20 u8 priv[] ____cacheline_aligned diff --git a/net/core/dev.c b/net/core/dev.c index 3487eec284a6..fca2295f4d95 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6230,12 +6230,12 @@ bool napi_complete_done(struct napi_struct *n, int = work_done) =20 if (work_done) { if (n->gro_bitmask) - timeout =3D READ_ONCE(n->dev->gro_flush_timeout); + timeout =3D napi_get_gro_flush_timeout(n); n->defer_hard_irqs_count =3D napi_get_defer_hard_irqs(n); } if (n->defer_hard_irqs_count > 0) { n->defer_hard_irqs_count--; - timeout =3D READ_ONCE(n->dev->gro_flush_timeout); + timeout =3D napi_get_gro_flush_timeout(n); if (timeout) ret =3D false; } @@ -6370,7 +6370,7 @@ static void busy_poll_stop(struct napi_struct *napi, = void *have_poll_lock, =20 if (flags & NAPI_F_PREFER_BUSY_POLL) { napi->defer_hard_irqs_count =3D napi_get_defer_hard_irqs(napi); - timeout =3D READ_ONCE(napi->dev->gro_flush_timeout); + timeout =3D napi_get_gro_flush_timeout(napi); if (napi->defer_hard_irqs_count && timeout) { hrtimer_start(&napi->timer, ns_to_ktime(timeout), HRTIMER_MODE_REL_PINN= ED); skip_schedule =3D true; @@ -6652,6 +6652,7 @@ void netif_napi_add_weight(struct net_device *dev, st= ruct napi_struct *napi, hrtimer_init(&napi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED); napi->timer.function =3D napi_watchdog; napi_set_defer_hard_irqs(napi, READ_ONCE(dev->napi_defer_hard_irqs)); + napi_set_gro_flush_timeout(napi, READ_ONCE(dev->gro_flush_timeout)); init_gro_hash(napi); napi->skb =3D NULL; INIT_LIST_HEAD(&napi->rx_list); @@ -11057,7 +11058,7 @@ void netdev_sw_irq_coalesce_default_on(struct net_d= evice *dev) WARN_ON(dev->reg_state =3D=3D NETREG_REGISTERED); =20 if (!IS_ENABLED(CONFIG_PREEMPT_RT)) { - dev->gro_flush_timeout =3D 20000; + netdev_set_gro_flush_timeout(dev, 20000); netdev_set_defer_hard_irqs(dev, 1); } } @@ -11995,7 +11996,6 @@ static void __init net_dev_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, ifin= dex); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, real= _num_rx_queues); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, _rx); - CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, gro_= flush_timeout); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, gro_= max_size); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, gro_= ipv4_max_size); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, rx_h= andler); @@ -12007,7 +12007,7 @@ static void __init net_dev_struct_check(void) #ifdef CONFIG_NET_XGRESS CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, tcx_= ingress); #endif - CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_rx, 100); + CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_rx, 92); } =20 /* diff --git a/net/core/dev.h b/net/core/dev.h index b3792219879b..26e598aa56c3 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -174,6 +174,46 @@ static inline void netdev_set_defer_hard_irqs(struct n= et_device *netdev, napi_set_defer_hard_irqs(napi, defer); } =20 +/** + * napi_get_gro_flush_timeout - get the gro_flush_timeout + * @n: napi struct to get the gro_flush_timeout from + * + * Return: the per-NAPI value of the gro_flush_timeout field. + */ +static inline unsigned long +napi_get_gro_flush_timeout(const struct napi_struct *n) +{ + return READ_ONCE(n->gro_flush_timeout); +} + +/** + * napi_set_gro_flush_timeout - set the gro_flush_timeout for a napi + * @n: napi struct to set the gro_flush_timeout + * @timeout: timeout value to set + * + * napi_set_gro_flush_timeout sets the per-NAPI gro_flush_timeout + */ +static inline void napi_set_gro_flush_timeout(struct napi_struct *n, + unsigned long timeout) +{ + WRITE_ONCE(n->gro_flush_timeout, timeout); +} + +/** + * netdev_set_gro_flush_timeout - set gro_flush_timeout of a netdev's NAPIs + * @netdev: the net_device for which all NAPIs will have gro_flush_timeout= set + * @timeout: the timeout value to set + */ +static inline void netdev_set_gro_flush_timeout(struct net_device *netdev, + unsigned long timeout) +{ + struct napi_struct *napi; + + WRITE_ONCE(netdev->gro_flush_timeout, timeout); + list_for_each_entry(napi, &netdev->napi_list, dev_list) + napi_set_gro_flush_timeout(napi, timeout); +} + int rps_cpumask_housekeeping(struct cpumask *mask); =20 #if defined(CONFIG_DEBUG_NET) && defined(CONFIG_BPF_SYSCALL) diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 25125f356a15..2d9afc6e2161 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -409,7 +409,7 @@ NETDEVICE_SHOW_RW(tx_queue_len, fmt_dec); =20 static int change_gro_flush_timeout(struct net_device *dev, unsigned long = val) { - WRITE_ONCE(dev->gro_flush_timeout, val); + netdev_set_gro_flush_timeout(dev, val); return 0; } =20 --=20 2.34.1 From nobody Wed Nov 27 16:33:25 2024 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 0E55643AD2 for ; Wed, 9 Oct 2024 00:55:59 +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=1728435361; cv=none; b=D8yYRhQVdaP2Cbxqa0CFZDmzR8u/rwsR1l6oEeMdVendUEi1w0CrBkDeg3u2FBpwaEshGeNJ1LmjSia7mPPs/OL1G+1KqELWCPCVLbca/hWP+Q7frTGicwj/QQFOxkFMOZkCBI8Q8l+0K9AAdZ8QBE1AtIWuPX337FK1ztomG/8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728435361; c=relaxed/simple; bh=fmuhBTf3bfBIF3wPJkt513NrrZF6VgNGcvDr2NU+JRo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AQ8zHR6b61Ec03vVVhWHi2/HPjBAAniek8D/nKoGmqZHF2XbBLwTrBsU12/EII1RzCoCHcxxSCqeXJjW6BP+3ZcU9p+iCaOXGkcoS+1uin7mP2/CU4dMTKf7Qr9reSJjMvf4PNNeINuHc8Z+KoAo6XpIbpUWpq8vsaqkDO8QPUM= 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=UK5ZlGjo; 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="UK5ZlGjo" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-20b5affde14so45486885ad.3 for ; Tue, 08 Oct 2024 17:55:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1728435359; x=1729040159; 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=wozl6FR6jO7LtfNZu3T9/AIWhCZAnrXDluBkWDgGbTE=; b=UK5ZlGjok2PnRZ5DCGgpaad4wjQMwclmXoxPRRCbvCUFDrZpCzLYAywVBO7XGGI8cS JfWPyzubJ4MgIlQQQ9jr5WT+oS2i4EZCxjggLAFBNqQgkCzl5lT2hh9JrL+xK5Y/TAjZ qKgPOV34tKbLsxLO+hE/kmyaH1um2JeB50xGM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728435359; x=1729040159; 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=wozl6FR6jO7LtfNZu3T9/AIWhCZAnrXDluBkWDgGbTE=; b=CMbv3QSVC3dw1LaZjP0C5R9KRAtKeqzw5bAnGK/8CYd2YzwBWdlz2gnbAnVNCSt0zi YxEl4HaB8/GHhymQ0DIwFEhv3GERMogUX2jL0T9P3bOzDZGwoxo6r8oRPpPRf6lxXyR1 ywTwYhKjK8P09SyrBbj2fIM9M/17Fla4nV0gjhzHe2bT0kXW5qQSxvvelx5NiodJv7Jc LF+DSSS+2peU9c8WO9i+Z1Uf5MVCDwcaBK0bj34oV2OfCZP5ZHpV3OUx2pMlLaHTQOOE tCWEOD38bKOZVRD1ALVf7fqI7zskijxcLNhv17V/Rx4WtJnHERWF0vqkEtaxTXkcRdIz swfg== X-Forwarded-Encrypted: i=1; AJvYcCUuMFSnQf9zU8AXwouhZR6XJY+KiVm9vfnY73Ug6UfK2G3K20IZfp/thPby6sHHWBTumUYRxq32odUtgGs=@vger.kernel.org X-Gm-Message-State: AOJu0Yz2w4UKSiW/ug59w3BVxwWEmtaBzian9etj5lmPzw5oTy5sRW9e OpH3D3T0A7mSNUwepUHD6b4ISAfjtHQ9kUgJHejyXMYq2yvrDC9+GXk+444gyM8= X-Google-Smtp-Source: AGHT+IEqXufwgSngAKNnN6AE5Vf68UGEK4jh8JF0urWXXFYD7O9enYEJi71s3fUkRUjlzqvzi1A9yA== X-Received: by 2002:a17:903:22cb:b0:20b:6458:ec6b with SMTP id d9443c01a7336-20c63738e4cmr14191925ad.25.1728435359509; Tue, 08 Oct 2024 17:55:59 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cec92sm60996045ad.101.2024.10.08.17.55.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:55:58 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, willemdebruijn.kernel@gmail.com, Joe Damato , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Donald Hunter , Jesper Dangaard Brouer , Mina Almasry , Xuan Zhuo , linux-kernel@vger.kernel.org (open list) Subject: [net-next v5 4/9] netdev-genl: Dump gro_flush_timeout Date: Wed, 9 Oct 2024 00:54:58 +0000 Message-Id: <20241009005525.13651-5-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241009005525.13651-1-jdamato@fastly.com> References: <20241009005525.13651-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" Support dumping gro_flush_timeout for a NAPI ID. Signed-off-by: Joe Damato Reviewed-by: Jakub Kicinski --- Documentation/netlink/specs/netdev.yaml | 6 ++++++ include/uapi/linux/netdev.h | 1 + net/core/netdev-genl.c | 6 ++++++ tools/include/uapi/linux/netdev.h | 1 + 4 files changed, 14 insertions(+) diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlin= k/specs/netdev.yaml index 585e87ec3c16..bf13613eaa0d 100644 --- a/Documentation/netlink/specs/netdev.yaml +++ b/Documentation/netlink/specs/netdev.yaml @@ -255,6 +255,11 @@ attribute-sets: type: u32 checks: max: s32-max + - + name: gro-flush-timeout + doc: The timeout, in nanoseconds, of when to trigger the NAPI + watchdog timer and schedule NAPI processing. + type: uint - name: queue attributes: @@ -644,6 +649,7 @@ operations: - irq - pid - defer-hard-irqs + - gro-flush-timeout dump: request: attributes: diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h index 13dc0b027e86..cacd33359c76 100644 --- a/include/uapi/linux/netdev.h +++ b/include/uapi/linux/netdev.h @@ -123,6 +123,7 @@ enum { NETDEV_A_NAPI_IRQ, NETDEV_A_NAPI_PID, NETDEV_A_NAPI_DEFER_HARD_IRQS, + NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT, =20 __NETDEV_A_NAPI_MAX, NETDEV_A_NAPI_MAX =3D (__NETDEV_A_NAPI_MAX - 1) diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c index de9bd76f43f8..64e5e4cee60d 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 gro_flush_timeout; u32 napi_defer_hard_irqs; void *hdr; pid_t pid; @@ -195,6 +196,11 @@ netdev_nl_napi_fill_one(struct sk_buff *rsp, struct na= pi_struct *napi, napi_defer_hard_irqs)) goto nla_put_failure; =20 + gro_flush_timeout =3D napi_get_gro_flush_timeout(napi); + if (nla_put_uint(rsp, NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT, + gro_flush_timeout)) + goto nla_put_failure; + genlmsg_end(rsp, hdr); =20 return 0; diff --git a/tools/include/uapi/linux/netdev.h b/tools/include/uapi/linux/n= etdev.h index 13dc0b027e86..cacd33359c76 100644 --- a/tools/include/uapi/linux/netdev.h +++ b/tools/include/uapi/linux/netdev.h @@ -123,6 +123,7 @@ enum { NETDEV_A_NAPI_IRQ, NETDEV_A_NAPI_PID, NETDEV_A_NAPI_DEFER_HARD_IRQS, + NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT, =20 __NETDEV_A_NAPI_MAX, NETDEV_A_NAPI_MAX =3D (__NETDEV_A_NAPI_MAX - 1) --=20 2.34.1 From nobody Wed Nov 27 16:33:25 2024 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 E556448CDD for ; Wed, 9 Oct 2024 00:56:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728435366; cv=none; b=aiomxTIQLDexEKl7CgwPoVfTRMW0JtMo8fQoqcHPdjK3UGLnf2xDs9ejt28VMB9ElBUK5NyDffwwsfriUcg6U2VCd3JadlnHL/q1aEoWXR+68IJYSDz9m79atEpUf+m/T+xHNX8RM8HzEeTtnSVlTkM3IwLa9NB5EVlJ4cmTteE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728435366; c=relaxed/simple; bh=OgnU7jGlYOZ4RgUbpwTEE1doBCYt+nNNnswKcF5DWLk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YzhZUX1z5OluJ0qmb6YQi8g6cCOO5mSmdINQW5PWZ/Mlqi1TB+ewRc9ffvvgtrZ6wCzwaUwiScVOpI5sqyFIjj8XG7QWrvZ+DfNmKyNeIksHkMpNDqo8PHKylMSOJ0pI3jaOKxjc8IZEW756/0ZyGG8FrIbq4zoQ9lFR2mDV0oE= 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=rHS5XO8d; arc=none smtp.client-ip=209.85.214.174 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="rHS5XO8d" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-20c544d345cso2798635ad.1 for ; Tue, 08 Oct 2024 17:56:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1728435364; x=1729040164; 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=n16XhemzbXx7qwcaB9LPA7EkmnNUbtxincb4Rdb9OsI=; b=rHS5XO8dkUU3o7d/3kMT1rFjpuzKmRr8/+yrpDMpZBSWuKBr/2nGo90dBlT1T8MrWh jtG01oIW3CBI85VRbrDE5XfIyHpRllm+fic9XEknqMGdawqAwExoJJlAwhpzqHSW0Eqe L2FIQoJosTfs/c8rbzA8UpuPufEiRo6BcNvmk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728435364; x=1729040164; 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=n16XhemzbXx7qwcaB9LPA7EkmnNUbtxincb4Rdb9OsI=; b=OHP3uBAtmxw6KVV3yldbjYhkxz2hribn62NbuuAtsnrQSh5YVCKGraWOSmswhEZ7qE PoorDZNc+SuJZeyspI2l7vvrmmwWFelycgvWTWPH5C5coVSCcE9nX90PI/3GxM7VL0oW TmUJ/FQPZk6Cio3V4wMSsz/2wTUFY6pqh6Q6TJ0iZujGe3FrXVJyLkMZ6YiPlAE65sop eHycgfsYWk5eLUBoy7PUPV0Tagl/MhwyS+4woiz13ppczR3PK2w43njfw1fvqoPjBaYh pthKzEMYcZfz33aj1vQKRrE97/vBeI4GnP1OR4PZ/uWy0ns85ZlmHDRr+8Ffjv00iGvC cP+A== X-Forwarded-Encrypted: i=1; AJvYcCV+EVRo/t2JEWOiDdmBNqJBRFmtMcKGk4FKQiwgjjOy9TeJJ71a3SMYeoKU3BrLqbeA8RCM0w+qKi/16vY=@vger.kernel.org X-Gm-Message-State: AOJu0YzsyJqpde88kzAOOjyG+q1YTHjxd/po66NDj6qEZsuZiqBNywyr xS2Qp4lMwewvIFFoD1/Xc4uiFcLPgzBMjdFruo1A3bCDi+goqTnlnubHqExm6Zs= X-Google-Smtp-Source: AGHT+IHR1SIa8oY4V7UBXp5AdvZXp4JzGRwj4HelaMVkmT5XlbsItqb8H1RCUr8fzXvBNtNPuWtGqw== X-Received: by 2002:a17:903:124d:b0:205:5c06:39e6 with SMTP id d9443c01a7336-20c4e19d98emr86680775ad.0.1728435364214; Tue, 08 Oct 2024 17:56:04 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cec92sm60996045ad.101.2024.10.08.17.56.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:56:03 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, willemdebruijn.kernel@gmail.com, Joe Damato , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Jiri Pirko , Sebastian Andrzej Siewior , Lorenzo Bianconi , Kory Maincent , Johannes Berg , linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-kernel@vger.kernel.org (open list) Subject: [net-next v5 5/9] net: napi: Add napi_config Date: Wed, 9 Oct 2024 00:54:59 +0000 Message-Id: <20241009005525.13651-6-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241009005525.13651-1-jdamato@fastly.com> References: <20241009005525.13651-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" Add a persistent NAPI config area for NAPI configuration to the core. Drivers opt-in to setting the persistent config for a NAPI by passing an index when calling netif_napi_add_config. napi_config is allocated in alloc_netdev_mqs, freed in free_netdev (after the NAPIs are deleted). Drivers which call netif_napi_add_config will have persistent per-NAPI settings: NAPI IDs, gro_flush_timeout, and defer_hard_irq settings. Per-NAPI settings are saved in napi_disable and restored in napi_enable. Co-developed-by: Martin Karsten Signed-off-by: Martin Karsten Signed-off-by: Joe Damato Reviewed-by: Jakub Kicinski --- .../networking/net_cachelines/net_device.rst | 1 + include/linux/netdevice.h | 36 ++++++++- net/core/dev.c | 79 +++++++++++++++++-- net/core/dev.h | 12 +++ 4 files changed, 118 insertions(+), 10 deletions(-) diff --git a/Documentation/networking/net_cachelines/net_device.rst b/Docum= entation/networking/net_cachelines/net_device.rst index 3ab663b6cf16..9d86720cb722 100644 --- a/Documentation/networking/net_cachelines/net_device.rst +++ b/Documentation/networking/net_cachelines/net_device.rst @@ -183,5 +183,6 @@ struct_dpll_pin* dpll_pin struct hlist_head page_pools struct dim_irq_moder* irq_moder u64 max_pacing_offload_horizon +struct_napi_config* napi_config unsigned_long gro_flush_timeout u32 napi_defer_hard_irqs diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 4239a4a9d295..b65a901ab4e7 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -342,6 +342,15 @@ struct gro_list { */ #define GRO_HASH_BUCKETS 8 =20 +/* + * Structure for per-NAPI config + */ +struct napi_config { + u64 gro_flush_timeout; + u32 defer_hard_irqs; + unsigned int napi_id; +}; + /* * Structure for NAPI scheduling similar to tasklet but with weighting */ @@ -379,6 +388,8 @@ struct napi_struct { struct list_head dev_list; struct hlist_node napi_hash_node; int irq; + int index; + struct napi_config *config; }; =20 enum { @@ -1860,9 +1871,6 @@ enum netdev_reg_state { * allocated at register_netdev() time * @real_num_rx_queues: Number of RX queues currently active in device * @xdp_prog: XDP sockets filter program pointer - * @gro_flush_timeout: timeout for GRO layer in NAPI - * @napi_defer_hard_irqs: If not zero, provides a counter that would - * allow to avoid NIC hard IRQ, on busy queues. * * @rx_handler: handler for received packets * @rx_handler_data: XXX: need comments on this one @@ -2012,6 +2020,11 @@ enum netdev_reg_state { * where the clock is recovered. * * @max_pacing_offload_horizon: max EDT offload horizon in nsec. + * @napi_config: An array of napi_config structures containing per-NAPI + * settings. + * @gro_flush_timeout: timeout for GRO layer in NAPI + * @napi_defer_hard_irqs: If not zero, provides a counter that would + * allow to avoid NIC hard IRQ, on busy queues. * * FIXME: cleanup struct net_device such that network protocol info * moves out. @@ -2405,6 +2418,7 @@ struct net_device { struct dim_irq_moder *irq_moder; =20 u64 max_pacing_offload_horizon; + struct napi_config *napi_config; unsigned long gro_flush_timeout; u32 napi_defer_hard_irqs; =20 @@ -2657,6 +2671,22 @@ netif_napi_add_tx_weight(struct net_device *dev, netif_napi_add_weight(dev, napi, poll, weight); } =20 +/** + * netif_napi_add_config - initialize a NAPI context with persistent config + * @dev: network device + * @napi: NAPI context + * @poll: polling function + * @index: the NAPI index + */ +static inline void +netif_napi_add_config(struct net_device *dev, struct napi_struct *napi, + int (*poll)(struct napi_struct *, int), int index) +{ + napi->index =3D index; + napi->config =3D &dev->napi_config[index]; + netif_napi_add_weight(dev, napi, poll, NAPI_POLL_WEIGHT); +} + /** * netif_napi_add_tx() - initialize a NAPI context to be used for Tx only * @dev: network device diff --git a/net/core/dev.c b/net/core/dev.c index fca2295f4d95..bd87232f7b37 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6503,6 +6503,22 @@ EXPORT_SYMBOL(napi_busy_loop); =20 #endif /* CONFIG_NET_RX_BUSY_POLL */ =20 +static void __napi_hash_add_with_id(struct napi_struct *napi, + unsigned int napi_id) +{ + napi->napi_id =3D napi_id; + hlist_add_head_rcu(&napi->napi_hash_node, + &napi_hash[napi->napi_id % HASH_SIZE(napi_hash)]); +} + +static void napi_hash_add_with_id(struct napi_struct *napi, + unsigned int napi_id) +{ + spin_lock(&napi_hash_lock); + __napi_hash_add_with_id(napi, napi_id); + spin_unlock(&napi_hash_lock); +} + static void napi_hash_add(struct napi_struct *napi) { if (test_bit(NAPI_STATE_NO_BUSY_POLL, &napi->state)) @@ -6515,10 +6531,8 @@ static void napi_hash_add(struct napi_struct *napi) if (unlikely(++napi_gen_id < MIN_NAPI_ID)) napi_gen_id =3D MIN_NAPI_ID; } while (napi_by_id(napi_gen_id)); - napi->napi_id =3D napi_gen_id; =20 - hlist_add_head_rcu(&napi->napi_hash_node, - &napi_hash[napi->napi_id % HASH_SIZE(napi_hash)]); + __napi_hash_add_with_id(napi, napi_gen_id); =20 spin_unlock(&napi_hash_lock); } @@ -6641,6 +6655,28 @@ void netif_queue_set_napi(struct net_device *dev, un= signed int queue_index, } EXPORT_SYMBOL(netif_queue_set_napi); =20 +static void napi_restore_config(struct napi_struct *n) +{ + n->defer_hard_irqs =3D n->config->defer_hard_irqs; + n->gro_flush_timeout =3D n->config->gro_flush_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. + */ + if (n->config->napi_id) + napi_hash_add_with_id(n, n->config->napi_id); + else + napi_hash_add(n); +} + +static void napi_save_config(struct napi_struct *n) +{ + n->config->defer_hard_irqs =3D n->defer_hard_irqs; + n->config->gro_flush_timeout =3D n->gro_flush_timeout; + n->config->napi_id =3D n->napi_id; + napi_hash_del(n); +} + void netif_napi_add_weight(struct net_device *dev, struct napi_struct *nap= i, int (*poll)(struct napi_struct *, int), int weight) { @@ -6651,8 +6687,6 @@ void netif_napi_add_weight(struct net_device *dev, st= ruct napi_struct *napi, INIT_HLIST_NODE(&napi->napi_hash_node); hrtimer_init(&napi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED); napi->timer.function =3D napi_watchdog; - napi_set_defer_hard_irqs(napi, READ_ONCE(dev->napi_defer_hard_irqs)); - napi_set_gro_flush_timeout(napi, READ_ONCE(dev->gro_flush_timeout)); init_gro_hash(napi); napi->skb =3D NULL; INIT_LIST_HEAD(&napi->rx_list); @@ -6670,7 +6704,13 @@ void netif_napi_add_weight(struct net_device *dev, s= truct napi_struct *napi, set_bit(NAPI_STATE_SCHED, &napi->state); set_bit(NAPI_STATE_NPSVC, &napi->state); list_add_rcu(&napi->dev_list, &dev->napi_list); - napi_hash_add(napi); + + /* default settings from sysfs are applied to all NAPIs. any per-NAPI + * configuration will be loaded in napi_enable + */ + napi_set_defer_hard_irqs(napi, READ_ONCE(dev->napi_defer_hard_irqs)); + napi_set_gro_flush_timeout(napi, READ_ONCE(dev->gro_flush_timeout)); + napi_get_frags_check(napi); /* Create kthread for this napi if dev->threaded is set. * Clear dev->threaded if kthread creation failed so that @@ -6702,6 +6742,11 @@ void napi_disable(struct napi_struct *n) =20 hrtimer_cancel(&n->timer); =20 + if (n->config) + napi_save_config(n); + else + napi_hash_del(n); + clear_bit(NAPI_STATE_DISABLE, &n->state); } EXPORT_SYMBOL(napi_disable); @@ -6717,6 +6762,11 @@ void napi_enable(struct napi_struct *n) { unsigned long new, val =3D READ_ONCE(n->state); =20 + if (n->config) + napi_restore_config(n); + else + napi_hash_add(n); + do { BUG_ON(!test_bit(NAPI_STATE_SCHED, &val)); =20 @@ -6746,7 +6796,11 @@ void __netif_napi_del(struct napi_struct *napi) if (!test_and_clear_bit(NAPI_STATE_LISTED, &napi->state)) return; =20 - napi_hash_del(napi); + if (napi->config) { + napi->index =3D -1; + napi->config =3D NULL; + } + list_del_rcu(&napi->dev_list); napi_free_frags(napi); =20 @@ -11083,6 +11137,8 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv= , const char *name, unsigned int txqs, unsigned int rxqs) { struct net_device *dev; + size_t napi_config_sz; + unsigned int maxqs; =20 BUG_ON(strlen(name) >=3D sizeof(dev->name)); =20 @@ -11096,6 +11152,8 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv= , const char *name, return NULL; } =20 + maxqs =3D max(txqs, rxqs); + dev =3D kvzalloc(struct_size(dev, priv, sizeof_priv), GFP_KERNEL_ACCOUNT | __GFP_RETRY_MAYFAIL); if (!dev) @@ -11170,6 +11228,11 @@ struct net_device *alloc_netdev_mqs(int sizeof_pri= v, const char *name, if (!dev->ethtool) goto free_all; =20 + napi_config_sz =3D array_size(maxqs, sizeof(*dev->napi_config)); + dev->napi_config =3D kvzalloc(napi_config_sz, GFP_KERNEL_ACCOUNT); + if (!dev->napi_config) + goto free_all; + strscpy(dev->name, name); dev->name_assign_type =3D name_assign_type; dev->group =3D INIT_NETDEV_GROUP; @@ -11231,6 +11294,8 @@ void free_netdev(struct net_device *dev) list_for_each_entry_safe(p, n, &dev->napi_list, dev_list) netif_napi_del(p); =20 + kvfree(dev->napi_config); + ref_tracker_dir_exit(&dev->refcnt_tracker); #ifdef CONFIG_PCPU_DEV_REFCNT free_percpu(dev->pcpu_refcnt); diff --git a/net/core/dev.h b/net/core/dev.h index 26e598aa56c3..f22cb532de7a 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -167,11 +167,17 @@ static inline void napi_set_defer_hard_irqs(struct na= pi_struct *n, u32 defer) static inline void netdev_set_defer_hard_irqs(struct net_device *netdev, u32 defer) { + unsigned int count =3D max(netdev->num_rx_queues, + netdev->num_tx_queues); struct napi_struct *napi; + int i; =20 WRITE_ONCE(netdev->napi_defer_hard_irqs, defer); list_for_each_entry(napi, &netdev->napi_list, dev_list) napi_set_defer_hard_irqs(napi, defer); + + for (i =3D 0; i < count; i++) + netdev->napi_config[i].defer_hard_irqs =3D defer; } =20 /** @@ -207,11 +213,17 @@ static inline void napi_set_gro_flush_timeout(struct = napi_struct *n, static inline void netdev_set_gro_flush_timeout(struct net_device *netdev, unsigned long timeout) { + unsigned int count =3D max(netdev->num_rx_queues, + netdev->num_tx_queues); struct napi_struct *napi; + int i; =20 WRITE_ONCE(netdev->gro_flush_timeout, timeout); list_for_each_entry(napi, &netdev->napi_list, dev_list) napi_set_gro_flush_timeout(napi, timeout); + + for (i =3D 0; i < count; i++) + netdev->napi_config[i].gro_flush_timeout =3D timeout; } =20 int rps_cpumask_housekeeping(struct cpumask *mask); --=20 2.34.1 From nobody Wed Nov 27 16:33:25 2024 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 9326B7DA6D for ; Wed, 9 Oct 2024 00:56:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728435373; cv=none; b=Q4zMz1i6Z8LLRD/S1byHwP/MxjKWXNWFTSgpp/MeruhZv/w1x59KBN1LfsWC4t2lMnCkZJXBt8ZlOedkotf68+Qhn+REaiTWIilaAMpLHmWA2/jdhNqZ4A8lDO05zx4aT3XXYVsvXAbCsbxh/j4H3+DKVK1pFBbAJ7arPvwKqNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728435373; c=relaxed/simple; bh=Ekg5Ex2CwrKTH3s26jVh5V639pIR/3T65wmqDH2EYMg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AxFHb9PR40vWBEa7FULOMHsukeYSu5cwzBMRSyq7CWg42iXgYjDXngxPCdyPyyiuSHrRurnLA/sdlhvSzPQ59XdHX2daQcu+n6rXJ5Ycn3yTj/+M/QOpcWGcUwjNMNICFIZrrT18y+TD6PU4PyNgzdbGFQ0AKM66H09qJ1INNH0= 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=KxhOI1Ab; arc=none smtp.client-ip=209.85.214.172 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="KxhOI1Ab" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20b49ee353cso58478195ad.2 for ; Tue, 08 Oct 2024 17:56:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1728435371; x=1729040171; 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=VFExh9JLgCX2o8sJ1oJkFzqxwxUaw6eXwPdUITUkpmw=; b=KxhOI1AbsZufB7Wnx0c/a1oYZ/ybMlY5RVsb1lHnHXLHMpgvRGkqKqSCR3AZFeqvaQ q+I1b33raksMYT+BckgoYKYuFWmDjifa0rmwdwmcN9mNUIzGQOV4sBlQfpiiuAzZRm00 bezf1u0VwuNT50GIQ3B6Cmj7I7fPIqcDtYuEE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728435371; x=1729040171; 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=VFExh9JLgCX2o8sJ1oJkFzqxwxUaw6eXwPdUITUkpmw=; b=WeO20wyJLHXyoqRjgwdOVjyMueJ9lCnrQ/yAVUWsgsFU865fulp/reNUFVjsbzN3q6 UIT+4FdzALcRXklnhs5zi5u4isnsmk73+3ZLC3IZjuIOr+L7gNFckSieiA0d50fvUH12 Kes7pF4lII8odI6DTHKUCVIAMNeflfo/W/sBXQi2UL3EFNfZMA+dYI1+Lnoz5oIfcz43 qAC5owBS8D5CYZllUPYWcOy1KhlJfjgk4YAEc+WWh2eNzthaX/ojNpwtqzbEINpd4qBz 1mUtsv3+yF85tUpBiu0MF5iDoczh4au0tnj26ga67kEfSo+GaYeWkgmk6WoM1jBxG4Mj AF/w== X-Forwarded-Encrypted: i=1; AJvYcCUGXEQnxs7+hw3yUPCsVWGQBSafFGtBNYdKJtZLpHfwkqhYB1BkJsx2440XRt14Dpa6fnty8Gfve5p7j4g=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5sX8A3vzipZ+F9jm8/yeoU0muS3Bj79FjzgLwlyuP7TrDSODs oxkMF2b6vrx4tg9UGcx7pMRo83ghURKtbghYb3wEX/HzVdZG2enfKA/ZFhSoIzQ= X-Google-Smtp-Source: AGHT+IE6iws8gP7BWGiblTSiPcFSgObUoGQNSyjfQ0BioIRailDiNSGi9E1uSTBmefAKiV8fnM3bNA== X-Received: by 2002:a17:902:e743:b0:20c:59ca:d76e with SMTP id d9443c01a7336-20c636f44a2mr13256075ad.8.1728435370891; Tue, 08 Oct 2024 17:56:10 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cec92sm60996045ad.101.2024.10.08.17.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:56:10 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, willemdebruijn.kernel@gmail.com, Joe Damato , Donald Hunter , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jesper Dangaard Brouer , Mina Almasry , Xuan Zhuo , linux-kernel@vger.kernel.org (open list) Subject: [net-next v5 6/9] netdev-genl: Support setting per-NAPI config values Date: Wed, 9 Oct 2024 00:55:00 +0000 Message-Id: <20241009005525.13651-7-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241009005525.13651-1-jdamato@fastly.com> References: <20241009005525.13651-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" Add support to set per-NAPI defer_hard_irqs and gro_flush_timeout. Signed-off-by: Joe Damato Reviewed-by: Jakub Kicinski --- Documentation/netlink/specs/netdev.yaml | 11 ++++++ include/uapi/linux/netdev.h | 1 + net/core/netdev-genl-gen.c | 18 ++++++++++ net/core/netdev-genl-gen.h | 1 + net/core/netdev-genl.c | 45 +++++++++++++++++++++++++ tools/include/uapi/linux/netdev.h | 1 + 6 files changed, 77 insertions(+) diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlin= k/specs/netdev.yaml index bf13613eaa0d..7b4ea5a6e73d 100644 --- a/Documentation/netlink/specs/netdev.yaml +++ b/Documentation/netlink/specs/netdev.yaml @@ -690,6 +690,17 @@ operations: reply: attributes: - id + - + name: napi-set + doc: Set configurable NAPI instance settings. + attribute-set: napi + flags: [ admin-perm ] + do: + request: + attributes: + - id + - defer-hard-irqs + - gro-flush-timeout =20 kernel-family: headers: [ "linux/list.h"] diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h index cacd33359c76..e3ebb49f60d2 100644 --- a/include/uapi/linux/netdev.h +++ b/include/uapi/linux/netdev.h @@ -201,6 +201,7 @@ enum { NETDEV_CMD_NAPI_GET, NETDEV_CMD_QSTATS_GET, NETDEV_CMD_BIND_RX, + NETDEV_CMD_NAPI_SET, =20 __NETDEV_CMD_MAX, NETDEV_CMD_MAX =3D (__NETDEV_CMD_MAX - 1) diff --git a/net/core/netdev-genl-gen.c b/net/core/netdev-genl-gen.c index b28424ae06d5..e197bd84997c 100644 --- a/net/core/netdev-genl-gen.c +++ b/net/core/netdev-genl-gen.c @@ -22,6 +22,10 @@ static const struct netlink_range_validation netdev_a_pa= ge_pool_ifindex_range =3D .max =3D 2147483647ULL, }; =20 +static const struct netlink_range_validation netdev_a_napi_defer_hard_irqs= _range =3D { + .max =3D 2147483647ULL, +}; + /* Common nested types */ const struct nla_policy netdev_page_pool_info_nl_policy[NETDEV_A_PAGE_POOL= _IFINDEX + 1] =3D { [NETDEV_A_PAGE_POOL_ID] =3D NLA_POLICY_FULL_RANGE(NLA_UINT, &netdev_a_pag= e_pool_id_range), @@ -87,6 +91,13 @@ static const struct nla_policy netdev_bind_rx_nl_policy[= NETDEV_A_DMABUF_FD + 1] [NETDEV_A_DMABUF_QUEUES] =3D NLA_POLICY_NESTED(netdev_queue_id_nl_policy), }; =20 +/* NETDEV_CMD_NAPI_SET - do */ +static const struct nla_policy netdev_napi_set_nl_policy[NETDEV_A_NAPI_GRO= _FLUSH_TIMEOUT + 1] =3D { + [NETDEV_A_NAPI_ID] =3D { .type =3D NLA_U32, }, + [NETDEV_A_NAPI_DEFER_HARD_IRQS] =3D NLA_POLICY_FULL_RANGE(NLA_U32, &netde= v_a_napi_defer_hard_irqs_range), + [NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT] =3D { .type =3D NLA_UINT, }, +}; + /* Ops table for netdev */ static const struct genl_split_ops netdev_nl_ops[] =3D { { @@ -171,6 +182,13 @@ static const struct genl_split_ops netdev_nl_ops[] =3D= { .maxattr =3D NETDEV_A_DMABUF_FD, .flags =3D GENL_ADMIN_PERM | GENL_CMD_CAP_DO, }, + { + .cmd =3D NETDEV_CMD_NAPI_SET, + .doit =3D netdev_nl_napi_set_doit, + .policy =3D netdev_napi_set_nl_policy, + .maxattr =3D NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT, + .flags =3D GENL_ADMIN_PERM | GENL_CMD_CAP_DO, + }, }; =20 static const struct genl_multicast_group netdev_nl_mcgrps[] =3D { diff --git a/net/core/netdev-genl-gen.h b/net/core/netdev-genl-gen.h index 8cda334fd042..e09dd7539ff2 100644 --- a/net/core/netdev-genl-gen.h +++ b/net/core/netdev-genl-gen.h @@ -33,6 +33,7 @@ int netdev_nl_napi_get_dumpit(struct sk_buff *skb, struct= netlink_callback *cb); int netdev_nl_qstats_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb); int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info); +int netdev_nl_napi_set_doit(struct sk_buff *skb, struct genl_info *info); =20 enum { NETDEV_NLGRP_MGMT, diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c index 64e5e4cee60d..59523318d620 100644 --- a/net/core/netdev-genl.c +++ b/net/core/netdev-genl.c @@ -303,6 +303,51 @@ int netdev_nl_napi_get_dumpit(struct sk_buff *skb, str= uct netlink_callback *cb) return err; } =20 +static int +netdev_nl_napi_set_config(struct napi_struct *napi, struct genl_info *info) +{ + u64 gro_flush_timeout =3D 0; + u32 defer =3D 0; + + if (info->attrs[NETDEV_A_NAPI_DEFER_HARD_IRQS]) { + defer =3D nla_get_u32(info->attrs[NETDEV_A_NAPI_DEFER_HARD_IRQS]); + napi_set_defer_hard_irqs(napi, defer); + } + + if (info->attrs[NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT]) { + gro_flush_timeout =3D nla_get_uint(info->attrs[NETDEV_A_NAPI_GRO_FLUSH_T= IMEOUT]); + napi_set_gro_flush_timeout(napi, gro_flush_timeout); + } + + return 0; +} + +int netdev_nl_napi_set_doit(struct sk_buff *skb, struct genl_info *info) +{ + struct napi_struct *napi; + unsigned int napi_id; + int err; + + if (GENL_REQ_ATTR_CHECK(info, NETDEV_A_NAPI_ID)) + return -EINVAL; + + napi_id =3D nla_get_u32(info->attrs[NETDEV_A_NAPI_ID]); + + rtnl_lock(); + + napi =3D napi_by_id(napi_id); + if (napi) { + err =3D netdev_nl_napi_set_config(napi, info); + } else { + NL_SET_BAD_ATTR(info->extack, info->attrs[NETDEV_A_NAPI_ID]); + err =3D -ENOENT; + } + + rtnl_unlock(); + + return err; +} + static int netdev_nl_queue_fill_one(struct sk_buff *rsp, struct net_device *netdev, u32 q_idx, u32 q_type, const struct genl_info *info) diff --git a/tools/include/uapi/linux/netdev.h b/tools/include/uapi/linux/n= etdev.h index cacd33359c76..e3ebb49f60d2 100644 --- a/tools/include/uapi/linux/netdev.h +++ b/tools/include/uapi/linux/netdev.h @@ -201,6 +201,7 @@ enum { NETDEV_CMD_NAPI_GET, NETDEV_CMD_QSTATS_GET, NETDEV_CMD_BIND_RX, + NETDEV_CMD_NAPI_SET, =20 __NETDEV_CMD_MAX, NETDEV_CMD_MAX =3D (__NETDEV_CMD_MAX - 1) --=20 2.34.1 From nobody Wed Nov 27 16:33:25 2024 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 3D9ED29429 for ; Wed, 9 Oct 2024 00:56:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728435374; cv=none; b=TVpc2J07YdVkHM/044K3iZvCnHEOiVnO5SNLTIfCq3dhGhS1/wSF+cnWOeNGwu4O7A9PjeCNYZgAVhn3jK0ohr7JB7PeJRgbXbwj4bVs4QwZwRBIx/keZPHoOwaXTwhyhkiwsJXYH4PqP2cEogwQGYNPUYJ2g32Rtk0QppX9JbI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728435374; c=relaxed/simple; bh=DHbZfeA6zp3c1SN+4z3kVAiT7+/abWBwPzDqDLUbUl4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jZ9d93FE9jO+f8VFTmVb8WJPtkBOFpPXd2zUgoBs/K0vEkIx7l7OINLFsZKeJV10OsniRNJA6YVvp+sLk3kPHS5TWxT4fEKjnpP7jJs/WlqPvmA6rcrtPFzEXdqAvjGUzrwyABn5+u9LbcbjS1zwAzXQ893RSazjCB9zkxvibLk= 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=B/iFlElN; arc=none smtp.client-ip=209.85.214.177 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="B/iFlElN" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-20b1335e4e4so61774935ad.0 for ; Tue, 08 Oct 2024 17:56:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1728435373; x=1729040173; 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=mJVHwUgMs+rfxIOK3S7MBwjWGHZYDl++VcT9JOMBFYY=; b=B/iFlElNjQqlitvIAzQdGEII/NxNoQTxFDK8+tRzr/cL5p6C7zXg1vCB4XU/95RUXw G5BBaeNAP5wa8SlZgXYCgmRRvXlSbqiR7+qydpO58PSifQaCrl257q2VyRSoUxQS68/b hNtvOI+KIxeTjvC+yAKP4+pmmsP9hAc1c78cY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728435373; x=1729040173; 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=mJVHwUgMs+rfxIOK3S7MBwjWGHZYDl++VcT9JOMBFYY=; b=JZBMzcDiGDjmwJSpTSQtuBS5JFj6bbxg8VRa/xPA92ieZfgNsohVJNL8+mg/8YwTfF G/phPr/q2r/meMXXDQfJznl0oug34woYhNrhYKYzy6iAG5t1D9FcypjYVpRIpFE90PCz GYJ/yjbBmeresTKoPmaNSnBEg58JtCVrU+ief/gA9oPTfjsFeoN8WwtCO8s+MX9CzYNL aa/d7cxTV4VUClVrglHCd/I1PFsLwldxceCPnaGIv8hhJ0nIPh2ZhYwDf9FYqLA30NYY k0yp8H0Lx4XA2lS63McGIHBLM2Q9eR5z3/mzb3NUjF2z/ziwPPwT9SIceqb5OwlD7THh ZBGA== X-Forwarded-Encrypted: i=1; AJvYcCVkg8h9BDK5MF7geLlfS7jf7+FDHXtg9sIIGpt/hizOiRCQsawXRH+/jyLDj3gDUTZFFfwWVlyQbyLuhss=@vger.kernel.org X-Gm-Message-State: AOJu0YwgLTIGk94dq2s218K0D5ASGAcANmCP+EoWBTXqfw9m0J68fbAQ zorprfoDWw+wn4cav4Dbr2rk/E3e+F7J4nzEIJiSFILbWUrlP6jKgR43YYeS6bA= X-Google-Smtp-Source: AGHT+IE+Jy6YzaCczW12PcHPToB8Qp5/Tm1AJJplbGlk9QLna4eYrt4cJ6UOiJ/ettHxwkoxAnC7Gw== X-Received: by 2002:a17:902:e802:b0:20b:8924:3a89 with SMTP id d9443c01a7336-20c6375b2b8mr14141655ad.12.1728435372708; Tue, 08 Oct 2024 17:56:12 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cec92sm60996045ad.101.2024.10.08.17.56.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:56:12 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, willemdebruijn.kernel@gmail.com, Joe Damato , Michael Chan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org (open list) Subject: [net-next v5 7/9] bnxt: Add support for persistent NAPI config Date: Wed, 9 Oct 2024 00:55:01 +0000 Message-Id: <20241009005525.13651-8-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241009005525.13651-1-jdamato@fastly.com> References: <20241009005525.13651-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" Use netif_napi_add_config to assign persistent per-NAPI config when initializing NAPIs. Signed-off-by: Joe Damato Reviewed-by: Eric Dumazet Reviewed-by: Jakub Kicinski --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethern= et/broadcom/bnxt/bnxt.c index 6e422e24750a..f5da2dace982 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10986,7 +10986,8 @@ static void bnxt_init_napi(struct bnxt *bp) cp_nr_rings--; for (i =3D 0; i < cp_nr_rings; i++) { bnapi =3D bp->bnapi[i]; - netif_napi_add(bp->dev, &bnapi->napi, poll_fn); + netif_napi_add_config(bp->dev, &bnapi->napi, poll_fn, + bnapi->index); } if (BNXT_CHIP_TYPE_NITRO_A0(bp)) { bnapi =3D bp->bnapi[cp_nr_rings]; --=20 2.34.1 From nobody Wed Nov 27 16:33:25 2024 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 4C50718EAB for ; Wed, 9 Oct 2024 00:56:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728435377; cv=none; b=KcRfQUzwYPILNETnI4tNlku9nf33imhbayvw9KHkh3QdMxoa9ddMfG92zCzxUJvUkRdkFPeZ9zGUi4eoAkM0o7CqPKHmXIEo1ectWvZ16bH33kL7o+Mr6KdG7XIRPYj+71Id0m89kqdU+tLDIPCetCdQvjxHWE85fGWNQ6LaI7s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728435377; c=relaxed/simple; bh=9AG0+lo9vEUg3YGDMTJw7BHymobbZ1x4BvfJUKFyf90=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n3R32Wd6p4JMS1pYGs6EPaUJuml4sEqbEXtdJYhfp2LTHKr+3X7LsAUI8Go9OStcYJ2Rp9fD1F1vOMw1LGIb1LCgBxccMndYb2tSbxo/wVEts/aNsIICqkpPpa2dqsfUFTYXRhrQX80y/IjojCbxkP28NZgdne5oCOqs7jj6cCk= 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=fGhCcnku; arc=none smtp.client-ip=209.85.214.169 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="fGhCcnku" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-20b833f9b35so54582725ad.2 for ; Tue, 08 Oct 2024 17:56:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1728435374; x=1729040174; 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=AiZhR6ZDOV6PKrXmW0MGtxp50pihY0OuQCjK7Nfyoqk=; b=fGhCcnkuPEPfs4pGreJdyccOUxG+03xH2cz27ZfxnbQmgfVT1sDCJArhle71D6nYZ8 paqmvzO+2aTk5URAhqT2nd2QpcDFZvouljRGQxv82qBEOcAFpD/SDmtE9mPJ3+Y+1BGS WbeKbNkzGVcIryWTdOaJStX0e1vZNRzmyomOY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728435374; x=1729040174; 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=AiZhR6ZDOV6PKrXmW0MGtxp50pihY0OuQCjK7Nfyoqk=; b=G43alSps0TPK2iZRg9PYA+A4Iys1Eg4vwzSf4IFRxJsbWhcmnBI3g+5+WAG9LfT516 XolNJxK+CXv4QOQ66iChV03C7B+4Hg9IE6hUksi4Y7qsbvo3MOXPRZ+pBNPRwir0B2XO d0Na4YVO6CBgGRGExTS2PBoLECycA0JWWndc6NVGiDWhmP6uMM66ImPzT6QU7I+aWWpc wOLz6IolGosyNUwmWQN0MGFh0jEcwmVcERktuoOFdLIEzS8GjaeyXbhOVUYAfmfbuIOL WU0CiidVjb7cJGCVbnHrblf7O24CMcVZspMMoksVJoqFY7A0j5dNTe8aDdS0g2CkDn4h Ueow== X-Forwarded-Encrypted: i=1; AJvYcCWHJ+3aC6w2a3fUWzvERfHfWsiR+I02y7bOFvXAIfN9o2Gkr5t5/aETkJi5luEEbHQBfb0U9KgAeJ4ornc=@vger.kernel.org X-Gm-Message-State: AOJu0YwxN54k/BG50saKnkttROmV3Vv7+C8tcYk/Dc1iuGgLkzZA34tL lUpxA9CG28r8IlZrID/EfkzQ1f7Mnc/xVEDMRWn/EpoFR7BK2XTPseZ1SBwIs+c= X-Google-Smtp-Source: AGHT+IH6h1S0EIM9d4SunI15VDvdI8I+pNVG0304L1KJl7mZQ1dQzI5hTEQrUahwl6H9gOdnwxmgrA== X-Received: by 2002:a17:903:228f:b0:20b:9088:6545 with SMTP id d9443c01a7336-20c6380574dmr12981235ad.46.1728435374645; Tue, 08 Oct 2024 17:56:14 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cec92sm60996045ad.101.2024.10.08.17.56.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:56:14 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, willemdebruijn.kernel@gmail.com, Joe Damato , Saeed Mahameed , Tariq Toukan , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-rdma@vger.kernel.org (open list:MELLANOX MLX5 core VPI driver), linux-kernel@vger.kernel.org (open list) Subject: [net-next v5 8/9] mlx5: Add support for persistent NAPI config Date: Wed, 9 Oct 2024 00:55:02 +0000 Message-Id: <20241009005525.13651-9-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241009005525.13651-1-jdamato@fastly.com> References: <20241009005525.13651-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" Use netif_napi_add_config to assign persistent per-NAPI config when initializing NAPIs. Signed-off-by: Joe Damato Reviewed-by: Eric Dumazet Reviewed-by: Jakub Kicinski --- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/ne= t/ethernet/mellanox/mlx5/core/en_main.c index a5659c0c4236..09ab7ac07c29 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -2697,7 +2697,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv= , int ix, c->aff_mask =3D irq_get_effective_affinity_mask(irq); c->lag_port =3D mlx5e_enumerate_lag_port(mdev, ix); =20 - netif_napi_add(netdev, &c->napi, mlx5e_napi_poll); + netif_napi_add_config(netdev, &c->napi, mlx5e_napi_poll, ix); netif_napi_set_irq(&c->napi, irq); =20 err =3D mlx5e_open_queues(c, params, cparam); --=20 2.34.1 From nobody Wed Nov 27 16:33:25 2024 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 DCB3A13D890 for ; Wed, 9 Oct 2024 00:56:16 +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=1728435378; cv=none; b=efvI0Auyx2UFZaY8OSIeyuNd/o4jl2F9ht3sr0SUSUDTICTve265tu5A6kuAeZiFCWzSkU3/6qzuT7PqK3JWBNUyCwzSmabFY2KQQ0mG8f3tXm+aoLlXdebWM0JZWdqR9zGCxyQz4KeNljl69ITpkcl583mvOz/KIFcfg3++XaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728435378; c=relaxed/simple; bh=w3PyoCLDwvBpb9QcaTe+IfR5xAs/HBKMLh3YZwzD30c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=H7T6/yfyYPW8EuC4aDyC/Swh1dHwlmlNgcr+BDBoe6yoPh/aom/0dsZJbi14yGlr/N5Q181IgxKilc2un0DCxWXvsTjuQKMiZzmZikMtj8rNa0CCqH+kwqjYLiUZ4XmV6lnMNIzNkLC8Ep/Zo1OJtIQv/w5O9b0jkZETwrqstWE= 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=Rz0gI6bP; 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="Rz0gI6bP" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-208cf673b8dso69084145ad.3 for ; Tue, 08 Oct 2024 17:56:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1728435376; x=1729040176; 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=5Z75IqLrMWdIhV00xNDkOvX+v1lJa5CtaV8sWjNm85A=; b=Rz0gI6bPkY2U5VG3VCfjpfObFPsG2+U/jQgsOgszmifH7Mp5RnIabIBEun5O2S5/8s DZ/Z1PrHtTXRxkw5XJdcdSvA43hujlgA7owMhPbQoZxRQ2gAfdbGC0nAYZh0TS0OCmOK oQqLNmAGVIDaRxZvfLBCdBE9OlOYIMZ84I+RY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728435376; x=1729040176; 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=5Z75IqLrMWdIhV00xNDkOvX+v1lJa5CtaV8sWjNm85A=; b=Dz4opDkUCSNqHUU32Y1ajki80XQHt4E+mO2xK4vaniQ3tLiQdJxT9EqxFW9s+ggXH9 P1Kqwr7jXWcrwtLuvAjtfom8BDWNA4Btm8zZLEFzcrtXJcLAxW1ko5Ig1HUfcC62lHT9 i7a82iGfet6x9wB87v+0BFC44CXFo/9oDpUoFkfahpnPeY2fKVO8G0SV5maIEj3j3pR+ dRIucI8FZxbGCJZoQMjKEzj/xl8cmEcD+CAOlzpV72uql6DemXHaSm/usqxejmnjEEs2 nsIzvaKbVBjKDuJ2PW+1afCYDQQseupHI26E+BgLPOaWed0egON2KQx+n1Iooh3Am4Mh xILg== X-Forwarded-Encrypted: i=1; AJvYcCUHW9uxZY7ToJ1RjuN/GNnidWOis/jtDEBQ1+q2WZZPSkG5E2DV+P1fkfE8UU0bYsPavMJBwI7RCTlq/1s=@vger.kernel.org X-Gm-Message-State: AOJu0Yzj1aNNII3eoyXfePtVoBUZNTAoCYKP/cqfdWve/yAvfNbfKVOf ATA0UfroilBByyZ1agBera9emjSoEnftJCa8Rg7cwxZY5Q76UN0P+JG8xv5MMZM= X-Google-Smtp-Source: AGHT+IFKh8PQ2F6a8qI4cgzTsO1otx8ErNT8oz4yduW9Kr/C9SXF+H773RpC0hS0cgYHwndSbOKE+Q== X-Received: by 2002:a17:903:2349:b0:20b:6d5c:8e1 with SMTP id d9443c01a7336-20c636dd062mr11743245ad.7.1728435376507; Tue, 08 Oct 2024 17:56:16 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138cec92sm60996045ad.101.2024.10.08.17.56.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 17:56:16 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, willemdebruijn.kernel@gmail.com, Joe Damato , Tariq Toukan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-rdma@vger.kernel.org (open list:MELLANOX MLX4 core VPI driver), linux-kernel@vger.kernel.org (open list) Subject: [net-next v5 9/9] mlx4: Add support for persistent NAPI config to RX CQs Date: Wed, 9 Oct 2024 00:55:03 +0000 Message-Id: <20241009005525.13651-10-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241009005525.13651-1-jdamato@fastly.com> References: <20241009005525.13651-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" Use netif_napi_add_config to assign persistent per-NAPI config when initializing RX CQ NAPIs. Presently, struct napi_config only has support for two fields used for RX, so there is no need to support them with TX CQs, yet. Signed-off-by: Joe Damato Reviewed-by for the v6. Reviewed-by: Eric Dumazet Reviewed-by: Jakub Kicinski --- drivers/net/ethernet/mellanox/mlx4/en_cq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_cq.c b/drivers/net/ether= net/mellanox/mlx4/en_cq.c index 461cc2c79c71..0e92956e84cf 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_cq.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_cq.c @@ -156,7 +156,8 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, stru= ct mlx4_en_cq *cq, break; case RX: cq->mcq.comp =3D mlx4_en_rx_irq; - netif_napi_add(cq->dev, &cq->napi, mlx4_en_poll_rx_cq); + netif_napi_add_config(cq->dev, &cq->napi, mlx4_en_poll_rx_cq, + cq_idx); netif_napi_set_irq(&cq->napi, irq); napi_enable(&cq->napi); netif_queue_set_napi(cq->dev, cq_idx, NETDEV_QUEUE_TYPE_RX, &cq->napi); --=20 2.34.1