From nobody Thu Nov 28 10:53:15 2024 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.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 E4C9B1E00AB for ; Tue, 1 Oct 2024 23:53:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826817; cv=none; b=fS1jItYApUNPOqor8Pht1ECn9Yiciii2a890Aa5yKhjbgc4cdXV2EtsnQs9EvPOtvvp5Rp37Hq9kJYYwoRQBmPRaxZw41HXjkTT36NawAMlKQXUY4SdVpK8Dk9dA4BkDoWi5q+Kl4GXgeYcWO9ZOqgWw5WsqL+mozn15MhlcpaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826817; c=relaxed/simple; bh=NKSjiGMl8HVeQM8T+1w9Wip+oPRlHTP1Per56Ka6OO4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YBZSuibIix5cVQ7ROYO7gO5H4/4uk9A9RMfJScanaWXmBXayDWUsIqyx0/CF3RigODkV8baO7gmqXVnW7X1JR6irWJo8Sj5ZrghTLGCvpnPUQ8gnykj/H3ezvCyXRA6ROVRRiDWKPTLMfap5v73lVu7SrlE8NiE4CkOxzxUqJII= 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=V2TSWNFp; arc=none smtp.client-ip=209.85.215.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="V2TSWNFp" Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-7db4c1a54easo3887646a12.1 for ; Tue, 01 Oct 2024 16:53:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727826815; x=1728431615; 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=fNxcXSwfx56FZIl6Cm7lpquz7kJ98h6HMSLIQEYkHDY=; b=V2TSWNFpjMKCzXWbOQ2fhlGWG1CoRSycziw8NOfXZFwXMyFXRC/UudQkzvKBQBt5fb AwxhOSekCXt7pjJlaUovQcDZzryQv95gKFs2AjhczgAtG2eLh6qnT7aKUHC7PVT1DAdM W5SzKdO7TGrhEyUBqZep3rRLBTw3UACn+GeTA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727826815; x=1728431615; 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=fNxcXSwfx56FZIl6Cm7lpquz7kJ98h6HMSLIQEYkHDY=; b=AHmWUsDwe4UjCPNAgqk/IoL2NAQieufbHBrtKOzPpPifCEes3PHlZLjxyIHzLYWUng NZo/xUe0p32MZGXjGK2DCpDT0tZTE3sKCIIS2EAXaydo4H/MQ1CknYvXs9p5Uzml6T/r 3sMbjvJ+Fs9C3LBN99chR2yKIfHJWBIUMtEMI08eDlsP+kL7HfQSNgdJGlAvlwf+yRtW GJXPZ4I3XePMm34hSuWcL1D3n7HF6v7+c7lF0MT6rrmDkYLvWktFEXmoD6fWWiFcEW5r g8ME93rPHlREDY4V1/2tP0Wk1A+JDerNHnMx4WwH5XkyH844FoO4X26+MkVDkBOP/xlo 87Vw== X-Forwarded-Encrypted: i=1; AJvYcCWKlSOFK8rw+Swy03OUTeEO7wmWMFXUY9aKzWbc+wLzJgkxudqFumRHNFMPxktPW/d2FCu8sBvqiwBwelo=@vger.kernel.org X-Gm-Message-State: AOJu0YwSFhnLhcQF/YcEx5VEfY8D3u5cqpbiyConzVDuEbjVYusbUkaC tlG66l1dslsBfPTWbN2vnazp5x954aY7ORgVz/ABaozNHq6T7ClGxZawy64nkuw= X-Google-Smtp-Source: AGHT+IGk/edwwPJhtIujE/fEuThhfDAouuDtB+XD7cDRW7qhVSa/cILWYeRQBLMIALnf0IvrHUAu+w== X-Received: by 2002:a17:90a:c383:b0:2da:da85:b705 with SMTP id 98e67ed59e1d1-2e18466e09cmr1620618a91.14.1727826815119; Tue, 01 Oct 2024 16:53:35 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f89e973sm213130a91.29.2024.10.01.16.53.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 16:53:34 -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: [RFC net-next v4 1/9] net: napi: Make napi_defer_hard_irqs per-NAPI Date: Tue, 1 Oct 2024 23:52:32 +0000 Message-Id: <20241001235302.57609-2-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241001235302.57609-1-jdamato@fastly.com> References: <20241001235302.57609-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 --- .../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 22b07c814f4a..eeeb7c925ec5 100644 --- a/Documentation/networking/net_cachelines/net_device.rst +++ b/Documentation/networking/net_cachelines/net_device.rst @@ -99,7 +99,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 @@ -183,3 +182,4 @@ struct_devlink_port* devlink_port struct_dpll_pin* dpll_pin = =20 struct hlist_head page_pools struct dim_irq_moder* irq_moder +u32 napi_defer_hard_irqs diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index e87b5e488325..55764efc5c93 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -377,6 +377,7 @@ struct napi_struct { struct list_head dev_list; struct hlist_node napi_hash_node; int irq; + u32 defer_hard_irqs; }; =20 enum { @@ -2075,7 +2076,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; @@ -2398,6 +2398,7 @@ struct net_device { =20 /** @irq_moder: dim parameters used if IS_ENABLED(CONFIG_DIMLIB). */ struct dim_irq_moder *irq_moder; + 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 cd479f5f22f6..748739958d2a 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6227,7 +6227,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--; @@ -6365,7 +6365,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); @@ -6647,6 +6647,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); @@ -11053,7 +11054,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); @@ -11991,7 +11992,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); @@ -12003,7 +12003,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.25.1 From nobody Thu Nov 28 10:53:15 2024 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (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 63D911E0B71 for ; Tue, 1 Oct 2024 23:53:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826821; cv=none; b=nQgT1JP1ItTJ+W3vMUf6raWR2SP9XbxnspyoS5IQDLBHX7FOhBCaUj8twb8mnvj9ZsdTA/YKIXpYr0kqNVls6CXaV8wSHqzH/u+BFuriTmyZv+07WAATbhRbZroE0wrQlGNrWqAHukv0QE01Jr/aqnSWPYSD/k3pcM0qqXcK34k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826821; c=relaxed/simple; bh=kAEG1Am3qGuk35HDrwWkcGYK2JXUX2VXmCklQAjtsYs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rFnfQQTy5TFN1+wSoErRYOD1AujwDhM/gBP/ENVoQ7u9dlcsReP6ke7T8FOTuQJBmqsC+fU81hd9s3ifax7KnEJ+UCk+pfabrGouI40AaREddUwAfXirxUbXdF67BClxW19IEP6e7K+/oaTM4Y2Y/1P4GguEjG5/KwUycyhNdS4= 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=r3rpdxy5; arc=none smtp.client-ip=209.85.216.45 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="r3rpdxy5" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2e109539aedso2675646a91.0 for ; Tue, 01 Oct 2024 16:53:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727826820; x=1728431620; 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=lrVj7Azlfps/B75TfmvK6tL6oA2kiOEMADlEWkkR0JI=; b=r3rpdxy5WzAxFcJJNI43O4TieaDRF5ppGwabok26WN7D165h0VUvprqM1u/+kzxc/V PrHwNvIoP5AYQxvoZy3DxIhzJ+6d8E2tYO2OJXjrJIRcOEpd+/21vFp6XOcokj4DDW5Q Q/Smmc6mp97ZI4r1MMKK3VQNOHIlsyNBPJkCY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727826820; x=1728431620; 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=lrVj7Azlfps/B75TfmvK6tL6oA2kiOEMADlEWkkR0JI=; b=QsyH6y+SxV9ZXOfgtjdQgWhTrP0E+sfZpAoNGhKgr8unRvTjYfxVwbLQ4txGZQcrkB do6cv7rgjPONYyf1tXnf1lppv9Djz4O4Jz7JpFZg3N5nO+0LtUvoU4ISHT1HXOqviZx+ 0oopk9wACMpNp27yX676B8Nn8OZPzt9SmDibhkgrcdgtgPUU/MNew1ag5to4sOcCRjll rcYZHxyXmvTJNRkusufVHgZ18FtVNS27sTEf9JCda0W3WpKLAt69H8wxoVQjY776xlBQ CKZKtpAcUH7ekjRT4qdcKMap+WLdck1mftvi2YRcx4c5VeMD7dgNe+rik945WkIztd8F nM3Q== X-Forwarded-Encrypted: i=1; AJvYcCVP9COIJBpPfLXCN3fU39iiMMr6R9N1+9y51v2WszXVgbVOYSjCPdRylLJe0pvWSMU7w4XXrTJ7Jq24qBc=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5OVeYZAU3R20XTx2OZpsVXf1m+VLuciKw/zAIcTgB0eyIVsAK mdx6P9WwPTKLF2ZvYsMeiIBMnAJzJmQZPRisX7rbtTO7JOaVRxIQ62ZOFalMFng= X-Google-Smtp-Source: AGHT+IGpgJ1rgzHrxwtT40rOkt57kYCh2EC90ybm6qKtAfpKHRyK6AeHjlpVi+lwyDuEEFYJtQbb5w== X-Received: by 2002:a17:90a:8c18:b0:2d3:cd27:c480 with SMTP id 98e67ed59e1d1-2e1849e437bmr1829345a91.33.1727826819796; Tue, 01 Oct 2024 16:53:39 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f89e973sm213130a91.29.2024.10.01.16.53.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 16:53:39 -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: [RFC net-next v4 2/9] netdev-genl: Dump napi_defer_hard_irqs Date: Tue, 1 Oct 2024 23:52:33 +0000 Message-Id: <20241001235302.57609-3-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241001235302.57609-1-jdamato@fastly.com> References: <20241001235302.57609-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 --- 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.25.1 From nobody Thu Nov 28 10:53:15 2024 Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (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 6E80A1E0098 for ; Tue, 1 Oct 2024 23:53:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826827; cv=none; b=CnFdadaHTFLXvUE/lP67fdriLtsRZvduIBpVGp0iANJ9royCgjS27EPoM1Ui4fA/pVkXLTKGvBoBd7reG0k7B1awZKPTBeiK+ngLblUy2UNrSirEpvvkIcOMnTxGPFGamP0MHhKCY00Z2RgO/sli+CWaJvdmd8SssuyCNl3gIMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826827; c=relaxed/simple; bh=QaU3GRuNJYHoKKjvrelHYx5nDgWJ2NGSPgRMJp/+Dww=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pfnF8ikdztY8eRYQV0pEC1hYmKcOqBayqiiRJ2rkujSy43IU8REnDLXfFo/0fuKqfZcOjIsRTG9LUvy8xG6X6L2DFvLVPpZNnNdHBzwXEJkFeh16sZtg9i5dw9g2QKd5XG+iyq+C6I35ghpnZtnrN/UUVXOa689U1igIvgVBkEQ= 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=dtOOPy3a; arc=none smtp.client-ip=209.85.215.182 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="dtOOPy3a" Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-7db90a28cf6so221708a12.0 for ; Tue, 01 Oct 2024 16:53:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727826826; x=1728431626; 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=8jeH1LephSM3GFjcVzcycSI9hrM1DyHIRSwagoq7Cvo=; b=dtOOPy3a5lzDSM3+S12qUgKyEVsNTvNWX4WReuz/JGy+8zcNycbnYvCzlax4/L5IAl pIzM8xJsknx9bM94QpPzMWS6yRM0GQezr/v0lk1ZZhFIt+jhQRELeC3ACJRRG8DTAWbQ 9mCw2nCTK0x4mv9hupbLNjy9DUq4z8qWjBFMM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727826826; x=1728431626; 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=8jeH1LephSM3GFjcVzcycSI9hrM1DyHIRSwagoq7Cvo=; b=fRGPJRGSSiq3i6Z/0ayjoo9I9vC8z1XaynTDsJ0o/3nUCp/Hjl3fsmre6JlN4ajdVD mtNhA1vnOKy0jsb7ipYeE01a02fG5rmGxh8XzCh01cxrjTL7DMYw7qzWA1t9624yL5lb crJLandAYNM6PBoYtxUHNOI7uLUP64CkLteLksFu98F8WQYyfIGTvEopeV4X3W4Eg//q tNu6URbOfC/RfpM0KlDyoVcR6j+z6IYOpa134MKjoz0tH7/AzbVf23GtHUu+w/vDsbem WfRkSoEfglm+Uvz8tbfCqlap2wqS7GF6RUWtsjNTHrHuld+WEDry2JSdn1j6EaVCEx0s 04DQ== X-Forwarded-Encrypted: i=1; AJvYcCWG+agJFCZgHnOA1pFLzwKeI5ZRJD6RTbS5kMX2DCnUihNSMwCHJ1FkqQu01GNtgD0yC18HzPxN3vPJeoE=@vger.kernel.org X-Gm-Message-State: AOJu0YwQRNdIyRbUIi2URz0l5Ah29xMdUAWZAxdk6ZwpAG2W7WZzh9X8 93Hw/r/1G/r77679Whp8YCjPVfWZe1cV1ypyPVC59abFy171IykGl8svu6OXAfI= X-Google-Smtp-Source: AGHT+IHnD47ZafzdaY5Hlr1/2gXXQgmcG0+t+WA3Vp+OIdQfqS4Lc5McbW2j0MHbRJNSn6aoWeQjew== X-Received: by 2002:a17:90a:f484:b0:2da:8b9f:5b74 with SMTP id 98e67ed59e1d1-2e1853e76femr1920261a91.13.1727826825726; Tue, 01 Oct 2024 16:53:45 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f89e973sm213130a91.29.2024.10.01.16.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 16:53:45 -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 , Tony Nguyen , Przemek Kitszel , Jiri Pirko , Sebastian Andrzej Siewior , Lorenzo Bianconi , David Ahern , Kory Maincent , Johannes Berg , Breno Leitao , Alexander Lobakin , linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-kernel@vger.kernel.org (open list), intel-wired-lan@lists.osuosl.org (moderated list:INTEL ETHERNET DRIVERS) Subject: [RFC net-next v4 3/9] net: napi: Make gro_flush_timeout per-NAPI Date: Tue, 1 Oct 2024 23:52:34 +0000 Message-Id: <20241001235302.57609-4-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241001235302.57609-1-jdamato@fastly.com> References: <20241001235302.57609-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. Note that idpf has embedded napi_struct in its internals and has established some series of asserts that involve the size of napi structure. Since this change increases the napi_struct size from 400 to 416 (according to pahole on my system), I've increased the assertion in idpf by 16 bytes. No attention whatsoever was paid to the cacheline placement of idpf internals as a result of this change. Signed-off-by: Joe Damato --- .../networking/net_cachelines/net_device.rst | 2 +- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 2 +- include/linux/netdevice.h | 3 +- net/core/dev.c | 12 +++--- net/core/dev.h | 40 +++++++++++++++++++ net/core/net-sysfs.c | 2 +- 6 files changed, 51 insertions(+), 10 deletions(-) diff --git a/Documentation/networking/net_cachelines/net_device.rst b/Docum= entation/networking/net_cachelines/net_device.rst index eeeb7c925ec5..3d02ae79c850 100644 --- a/Documentation/networking/net_cachelines/net_device.rst +++ b/Documentation/networking/net_cachelines/net_device.rst @@ -98,7 +98,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 @@ -182,4 +181,5 @@ struct_devlink_port* devlink_port struct_dpll_pin* dpll_pin = =20 struct hlist_head page_pools struct dim_irq_moder* irq_moder +unsigned_long gro_flush_timeout u32 napi_defer_hard_irqs diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.h b/drivers/net/ethe= rnet/intel/idpf/idpf_txrx.h index f0537826f840..fcdf73486d46 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_txrx.h +++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.h @@ -438,7 +438,7 @@ struct idpf_q_vector { __cacheline_group_end_aligned(cold); }; libeth_cacheline_set_assert(struct idpf_q_vector, 112, - 424 + 2 * sizeof(struct dim), + 440 + 2 * sizeof(struct dim), 8 + sizeof(cpumask_var_t)); =20 struct idpf_rx_queue_stats { diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 55764efc5c93..33897edd16c8 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -377,6 +377,7 @@ struct napi_struct { struct list_head dev_list; struct hlist_node napi_hash_node; int irq; + unsigned long gro_flush_timeout; u32 defer_hard_irqs; }; =20 @@ -2075,7 +2076,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; @@ -2398,6 +2398,7 @@ struct net_device { =20 /** @irq_moder: dim parameters used if IS_ENABLED(CONFIG_DIMLIB). */ struct dim_irq_moder *irq_moder; + 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 748739958d2a..056ed44f766f 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6226,12 +6226,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; } @@ -6366,7 +6366,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; @@ -6648,6 +6648,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); @@ -11053,7 +11054,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); } } @@ -11991,7 +11992,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); @@ -12003,7 +12003,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.25.1 From nobody Thu Nov 28 10:53:15 2024 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (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 077D61E00A2 for ; Tue, 1 Oct 2024 23:53:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826833; cv=none; b=fJSXwlIH/xyd/XHjy5W4/hnZZggflsk2RuNT3llaUmxxkSHH+Q+5Bk0vf6YzwsiOfQLa1sItNkZrwLpHWqtCjDRfdlsMhl7zKxEANZu8cZt8qCen2wbOIsb4yGbITisC7lbvkPSHmGpYxoA0zxjvhS2v25LXhxP5nxj4HoOvOIc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826833; c=relaxed/simple; bh=A4ctw+2b8yq0sCbFcjdY3SVzbWEsxT2TUGSyUg6wK0s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RNEy+WG6VM9i1wb8YihS8jbLZgkIQTpLx8GqMzJsf6n8846ROb48an8IchxoFQsY6gHcGuegKgjP8BR8xDharCERze5zGBEiIFgldvpDWuEQVmcov5VTL4YmdBmS0aYI6EMt0bGLGd53J3CCTM1e9KnNE6xVXpQOIhhtObRQyl0= 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=t+8yrxtO; arc=none smtp.client-ip=209.85.215.171 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="t+8yrxtO" Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-7d4fa972cbeso4607265a12.2 for ; Tue, 01 Oct 2024 16:53:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727826830; x=1728431630; 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=KQII9ub/bVtxy0ntEn1HGx1uSFXeUqoutb/T7bvVeMk=; b=t+8yrxtO5Y8sW0RctPlO9mtJZCzMt8sLCn93CwLonDirnK/LcLh0yewHcD32G4/20s UHIc1iOguDL8aU7jso/NpAc7q7JRoF5gySmeAX+zZrICQA03tySjU4xNWdTZuevRceF3 VVFrLuP7rexiDWxJFJyFFPI6ybijM2u/uWxiM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727826830; x=1728431630; 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=KQII9ub/bVtxy0ntEn1HGx1uSFXeUqoutb/T7bvVeMk=; b=RGJ+si9xdLOpHVfUqAUq4SUEFZVt1ifXZVCKuju+H+cdOA2j9PAicG3VUHvj3bVqpL /8i1qPHS+jnbBUPFphaIu2i19Ak1CE24sVuJLn6FT5tDU6qQJwUCiy7zka+zYNbVx5KY nRQyz85kKfNaRGnun18gDRbWSjLnWHNYwIwbrv/GR9EwOWEAiLEeeMO69XXfNpxOkHhh xGP6QOdu1+bu1Koz9lXcbY0oaCmqJJ4nzF6QbvIeA52FsP/4zTc2idltjTXJAKNE/Jj/ TnoumgTBZ2ya89a3iey0kQh4BVy3PMQvU3moOzk4hsd+LSwEP/raLo+XtUoMMGbAXviZ YBqg== X-Forwarded-Encrypted: i=1; AJvYcCUALbIrVCotx/N8Uv2A3b1xu5+/9u6fGrdLLCIZOwxvctW1VrVVSg9P0v2fDzVf31K9STVoW1W6eXQGoSI=@vger.kernel.org X-Gm-Message-State: AOJu0Yw6o+K0UFMywQuJEdCJF6IXyFm2Gm8P/0FmmF+tZvMXgRXo1BjW O3K4BQRGsfbon4UFKVKsMoMYANZZ3aLeWtnJrcfXHBMzDi3SHNgZy3dBrgNdsDI= X-Google-Smtp-Source: AGHT+IH6y8TLEoNcS3CIY1eRqDcl6J9ZIkBmPCtlp4ki4860wF8VxL5+YVU+aQ3guijKYC2ciYrGKQ== X-Received: by 2002:a17:90a:f192:b0:2e0:59af:b998 with SMTP id 98e67ed59e1d1-2e184943fdfmr1601328a91.39.1727826830385; Tue, 01 Oct 2024 16:53:50 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f89e973sm213130a91.29.2024.10.01.16.53.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 16:53:50 -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 , Daniel Jurgens , linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v4 4/9] netdev-genl: Dump gro_flush_timeout Date: Tue, 1 Oct 2024 23:52:35 +0000 Message-Id: <20241001235302.57609-5-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241001235302.57609-1-jdamato@fastly.com> References: <20241001235302.57609-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 --- 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.25.1 From nobody Thu Nov 28 10:53:15 2024 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 B0D3D1E1330 for ; Tue, 1 Oct 2024 23:53:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826837; cv=none; b=Lyv+TCImTwpokR5IPjRg0xQ1brWCDLhS3NwXHwCQN3WX/ekgHuRd+Nojs9GnfSCcERJoWHIXXZke0ei2QNFxX3v7ZiZsQCb6mDdEQKLzQSqyngf+bySP1sQWTzs2W5pTE48/tHw4e7K9sAWVR1nP3LUTjKmUJrFTKRYvPGP/kFA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826837; c=relaxed/simple; bh=zto/izfmmguhKhVHdEZdiijUzaBXpzkbp1KqyItqIxo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QYOI6s5mFeDBUEKEN35Di48XcBVBk1dAq4YF4kWXEz7CzgWjE5Pg5kLf9iXChmZPPpihGDbqn5qEuKaZWvbQGopuwm4T1suW26QOgEx29vJD7fWb5V/liJvHAiK2HrRngjnPh0gvZNnUu15ASqwbWs67QUIkO7uwK9gbwIhor+s= 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=iE9GiHBY; arc=none smtp.client-ip=209.85.216.54 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="iE9GiHBY" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2e0be1afa85so4391672a91.1 for ; Tue, 01 Oct 2024 16:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727826835; x=1728431635; 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=wlIWZP5hxY7Z7ed2/y3QCNWpfTA3UWwpTpt+lr7sIBg=; b=iE9GiHBYF+WhLpT3RBv1V+mfW8Wgm3Yu9wy/VmhIK74mxvKpN1VWtseoOuV1eLE7/f P5femz9h5P+u4RYDvI8lrmuunCnYT6+XaZC6YfEBjejNc6GRbVuKdaMj4KXtymAmjhGp 2ndF8394YUpVGLHchbKmNl/S4Y5/Ld1PQ/uI8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727826835; x=1728431635; 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=wlIWZP5hxY7Z7ed2/y3QCNWpfTA3UWwpTpt+lr7sIBg=; b=Ptrv5ADqLJK7ZPrghfUDg8MVeH/nuaMG1VuI1GPI9LCE7WJLWbm6FLL+dCsCUT0c8Q VwKkjF0VnAb5o4SeTZS6hyaYr8a0gCCUauyA7sa1Sjdlx0vISsot5tVrhaIg1p2sIL4O cgy/ClpPt8EI6Yk9JzMGpqQ3E1BBUWEL4jZmspGZz0Hm+1CJRM7ze9H1PWTMfup1FWIg HtCcYb9d90SacgcCUVrTYVG1Tu1QOdxlw98v4bNBRVJdN2ztdwp7gUrOizZxRtHz1XzO xz6ht/vl3Iqmp1t0mDTIFK/iPzz4e9gsfX7V0UVCOrUX4KBqmYDDC84qzrXYXtxFGSIr Lktg== X-Forwarded-Encrypted: i=1; AJvYcCULovbXObLQYPLN0kEy/zBVZLCQOFOTFZYfDW7jFXnTiSOsQ8CNiJIK4WXEIIG165tBGNWwGC3QZGwQS/E=@vger.kernel.org X-Gm-Message-State: AOJu0Yxyj2Oc2uzFUBtA7Tk7fsBXqwvp55EwGe5wOwXG2AvlTFLftv/V yC0qo7SCsgRrohHf54pZ7naa5NMui5cvXD8Pi32h5M1RUhCqOZGGqUExujNN4iA= X-Google-Smtp-Source: AGHT+IFPu7lvhG4uUYOO2d1rHoWdVGH9+8y4NJPM7S8ebIb+AWvoza2AwcPTUtXv++qlhFapQqZP5w== X-Received: by 2002:a17:90a:ff0d:b0:2e0:875a:f72d with SMTP id 98e67ed59e1d1-2e182c80442mr1777548a91.0.1727826834967; Tue, 01 Oct 2024 16:53:54 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f89e973sm213130a91.29.2024.10.01.16.53.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 16:53:54 -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 , linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v4 5/9] net: napi: Add napi_config Date: Tue, 1 Oct 2024 23:52:36 +0000 Message-Id: <20241001235302.57609-6-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241001235302.57609-1-jdamato@fastly.com> References: <20241001235302.57609-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 --- .../networking/net_cachelines/net_device.rst | 1 + include/linux/netdevice.h | 32 ++++++++ net/core/dev.c | 79 +++++++++++++++++-- net/core/dev.h | 14 ++++ 4 files changed, 119 insertions(+), 7 deletions(-) diff --git a/Documentation/networking/net_cachelines/net_device.rst b/Docum= entation/networking/net_cachelines/net_device.rst index 3d02ae79c850..11d659051f5e 100644 --- a/Documentation/networking/net_cachelines/net_device.rst +++ b/Documentation/networking/net_cachelines/net_device.rst @@ -183,3 +183,4 @@ struct hlist_head page_pools struct dim_irq_moder* irq_moder unsigned_long gro_flush_timeout u32 napi_defer_hard_irqs +struct napi_config* napi_config diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 33897edd16c8..51cff55e7ab8 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 { int irq; unsigned long gro_flush_timeout; u32 defer_hard_irqs; + int index; + struct napi_config *config; }; =20 enum { @@ -2011,6 +2022,9 @@ enum netdev_reg_state { * @dpll_pin: Pointer to the SyncE source pin of a DPLL subsystem, * where the clock is recovered. * + * @napi_config: An array of napi_config structures containing per-NAPI + * settings. + * * FIXME: cleanup struct net_device such that network protocol info * moves out. */ @@ -2400,6 +2414,7 @@ struct net_device { struct dim_irq_moder *irq_moder; unsigned long gro_flush_timeout; u32 napi_defer_hard_irqs; + struct napi_config *napi_config; =20 u8 priv[] ____cacheline_aligned __counted_by(priv_len); @@ -2650,6 +2665,23 @@ 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 + * @weight: the poll weight of this NAPI + * @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 056ed44f766f..9acb6db19200 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6499,6 +6499,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)) @@ -6511,10 +6527,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); } @@ -6637,6 +6651,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) { @@ -6647,8 +6683,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); @@ -6666,7 +6700,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 @@ -6698,6 +6738,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); @@ -6713,6 +6758,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 @@ -6742,7 +6792,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 @@ -11079,6 +11133,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 @@ -11092,6 +11148,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) @@ -11166,6 +11224,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; @@ -11227,6 +11290,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..7365fa0ffdc7 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -167,11 +167,18 @@ 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); + + if (netdev->napi_config) + for (i =3D 0; i < count; i++) + netdev->napi_config[i].defer_hard_irqs =3D defer; } =20 /** @@ -207,11 +214,18 @@ 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); + + if (netdev->napi_config) + 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.25.1 From nobody Thu Nov 28 10:53:15 2024 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (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 49CA71E1A19 for ; Tue, 1 Oct 2024 23:54:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826843; cv=none; b=KUMQZuN3na31VmZnJW3JWy3OmyiK7cO+NXyAagTJa6iX09s1Mep0ZmgZQ1rDO+TtTyKBWSxEuRbeJnghvg2wBRR+jW8bQTzcTg9phOlTRxP+luBie62Blbc1HYAWvUEN5G++TxfNjXEa7HWDF7rDmTHGNWL2MdTnFxb09eosXJI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826843; c=relaxed/simple; bh=etJ5QQq7z0hnczvA60rILD3Y/1LYpD2GBa8P+y6My1c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cbrroSYEnrEmtxujQZjTeT7LyJIjxcUkIS8zNsqWqL2SB9d9QET1q+HDUGX9pLpr3ycjQl4tagsqln/mXRq1xtuCJng4ZfL5MrEG8PYj7s+t8JGhhgqU+xC0RuSRKhXFWzhsL2lCk+SWKdb7G7BGUuRAFNxqzdN2E2TwKrJ8Tpo= 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=ExodRjaV; arc=none smtp.client-ip=209.85.216.52 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="ExodRjaV" Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-2e075ceebdaso4586792a91.2 for ; Tue, 01 Oct 2024 16:54:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727826841; x=1728431641; 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=vp6xBU2Yo2PWr8F48aHYbzV3nL3kOi+Sh9yDhDyEv0E=; b=ExodRjaV6byjxnO5/ZZ5xaMB4R0Kh+Xaq5z0OGKKeCHzXLmhj8uyel2IG2JurQA7Og H5w8FN2jOnti6VlDltXrl+V/gj/i6moX9tFthH+8fb5LY819zbaqoI3KhGoPcyzN0BFr 5lCsvIfoLRGnzK88/tKLTTuj/saCDAn1b/kt8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727826841; x=1728431641; 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=vp6xBU2Yo2PWr8F48aHYbzV3nL3kOi+Sh9yDhDyEv0E=; b=nPjBiqXaxIBH3oSoA+yEPzOIS2S51vBGmjcgkeuUjEhY90DoZbuJaMGKY8IbZikQ4f WSeFPqCeYfgVgvBbY1hQ63VnceMsdx5bEg+dxjUWPbnxI053v3mhCy/agPTsmaIGzETz ZSeBCS1rufx2R1PB9/X25cVsxjEoa4OVzDF5Bzc7ZuPhWEy/bzIOolW6lSBkijcBQoI3 jVdSTy8gNqWVX/YV/ThP6xBI2BpLIMuu8uAP2V1SSo17zaja1I0dGkdoAgicW2c7INBf Vi62XcyD5bPJztRj2lSDxukbPNnQ5Pwn4WAW1cmxVVTHniC0stGKtzVmkiVu5B62E5AL HkRg== X-Forwarded-Encrypted: i=1; AJvYcCWW8x+LNUgsjs3VBQzPDnKPGEZ3KLIG6DAawz16z3BS+CZHdxn10Q+v4xwpaEmPOC+3r06hBjGVBgIzLxM=@vger.kernel.org X-Gm-Message-State: AOJu0YwaBvXP/8fx8wgZe5IU+3VVB7KO7U/Aq/YRVVUHwUEK0r7jfovb IhiDN5zX8RQkvqAfaxA6XLHUt4wnhf4ncQVgqBuVSHmBFh6Dfe2vDJr0baYMWW8= X-Google-Smtp-Source: AGHT+IEoHQYE+xaLebe1pVy16LZPHUGrAQAE2ajk4dV/5lmrgMHS7is6fxTq38YsNokwFPUG2Bz0xA== X-Received: by 2002:a17:90a:fb4b:b0:2e0:a0ab:7fd0 with SMTP id 98e67ed59e1d1-2e1846b5446mr1574787a91.16.1727826841525; Tue, 01 Oct 2024 16:54:01 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f89e973sm213130a91.29.2024.10.01.16.54.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 16:54:01 -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: [RFC net-next v4 6/9] netdev-genl: Support setting per-NAPI config values Date: Tue, 1 Oct 2024 23:52:37 +0000 Message-Id: <20241001235302.57609-7-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241001235302.57609-1-jdamato@fastly.com> References: <20241001235302.57609-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 --- Documentation/netlink/specs/netdev.yaml | 11 ++++++ include/uapi/linux/netdev.h | 1 + net/core/netdev-genl-gen.c | 14 ++++++++ net/core/netdev-genl-gen.h | 1 + net/core/netdev-genl.c | 45 +++++++++++++++++++++++++ tools/include/uapi/linux/netdev.h | 1 + 6 files changed, 73 insertions(+) diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlin= k/specs/netdev.yaml index bf13613eaa0d..7f8d2489c68c 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: + - napi-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..901c6f65b735 100644 --- a/net/core/netdev-genl-gen.c +++ b/net/core/netdev-genl-gen.c @@ -87,6 +87,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 - set */ +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 { .type =3D NLA_S32 }, + [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 +178,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..85e6d7c95ada 100644 --- a/net/core/netdev-genl-gen.h +++ b/net/core/netdev-genl-gen.h @@ -30,6 +30,7 @@ int netdev_nl_queue_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb); int netdev_nl_napi_get_doit(struct sk_buff *skb, struct genl_info *info); int netdev_nl_napi_get_dumpit(struct sk_buff *skb, struct netlink_callback= *cb); +int netdev_nl_napi_set_doit(struct sk_buff *skb, struct genl_info *info); 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); 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.25.1 From nobody Thu Nov 28 10:53:15 2024 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (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 C40271E0B62 for ; Tue, 1 Oct 2024 23:54:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826845; cv=none; b=d4JDLAxAR6xAdGjC7f2Z5O5NBetRwYKB8puMOebUQcMQ6DYAeHoFysQnymAp3Lg2XbDdM7mqGEVJYa5xdOs71geyU8pCS0NY5TohRSSwVFAbm6rF5IY3TUcrptiNAYMipWZKX0eWAf1lirh5PLoYVcIiTUvqxSjGaKhzQAy/l3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826845; c=relaxed/simple; bh=o3D87lP+KNy+Jir/fY7fvLsBvMyy9THUtqA+9zYkCpo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IbqTYYdNvolBTwpIBmkXRbnNXZYZDWCKpzf2KfcgdW8axjBl4RfDwbBAx1rZ786RIRmyhYQ1bsxwj/lYz1llU7900s1xOX1cvzJDNBR7x1+xtisITGZHfSh+3KN0bWyKxTqRlc14sPvYzQ8IBDJNEJNZqBUheNoPqKmeNMx4Sxc= 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=vvSlo9Ee; arc=none smtp.client-ip=209.85.216.45 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="vvSlo9Ee" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2e09f67bc39so5023395a91.1 for ; Tue, 01 Oct 2024 16:54:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727826843; x=1728431643; 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=PLF63g3UxuFOgNadANGg2+qqv3YqiRQyKEar+/98gi0=; b=vvSlo9Eelee5097/8c3VFUiWk5vJI1GPF+ur0suqFmVXNp4IQa68jwxMIzjarE2L2p /gSLra0OAbxh4K4QH4DPjMiUbE/q0nRGq5uyN5t2DKLzC5vHRNSfc1q0ldj8l6RnfqdY 1/DRSiviWHyyHh7JVOO+HeZSZ9lFKBRCu4iBQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727826843; x=1728431643; 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=PLF63g3UxuFOgNadANGg2+qqv3YqiRQyKEar+/98gi0=; b=a/GpyGdnPjgTFdcDwYSU5Nxkq70nc15RQ6TI242EZ/H2ZfaCKTdNnQpJjzMwsY5ZWO p2DYGAM22mXz6tOGfUQtMJ6M2koqDjgWSb/jWlWk8wCTmIyx9Wlwiw+fENV7wDtRBPFQ is6pmcIKDeTa3s8lXeOsgO+Psv5YKGq0o1J1NcXpeqkfbJITMe2YPRVxOZQUkzKhKCGc +szdSBq26jfKNKb6q7WGyADSHQTTF5i9TmVNRzkphoCpdyDUo1WUGWqBuMvx7ITmV/wT qujoFmQ+jPyrCU48B/LGCzch9smYoJG6+Cx82s7dh6FHACthXWLkwYp2fCNtTf0SCy3c A+6Q== X-Forwarded-Encrypted: i=1; AJvYcCVsvO9fYQoZu0rWFK1D78FLQ0kWUetsuMVdW+h1Ne7p/AoFw0Yp7JyucY+OKcUrtuLbuq4GiPC3VzDZM8E=@vger.kernel.org X-Gm-Message-State: AOJu0Ywl9x4T6J4+r7D52vN92BV/INuZ/rTXw6m+W/xKP9e4tkAopHOK 3Z979xoqThBlOXUn7Hejtncbl2pTxby1Ie/r1EbjJhLJx3PhBBJGsXmQHLrmXNM= X-Google-Smtp-Source: AGHT+IEziOa7A+MAB9R2Y08fOCLGpcavYwRLkZ94iRWB4+/kdOklKsQcBgrXg0q1p/jteWgh+MwIQQ== X-Received: by 2002:a17:90a:1b89:b0:2d8:89ad:a67e with SMTP id 98e67ed59e1d1-2e1845511e2mr1931370a91.1.1727826843241; Tue, 01 Oct 2024 16:54:03 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f89e973sm213130a91.29.2024.10.01.16.54.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 16:54:02 -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: [RFC net-next v4 7/9] bnxt: Add support for persistent NAPI config Date: Tue, 1 Oct 2024 23:52:38 +0000 Message-Id: <20241001235302.57609-8-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241001235302.57609-1-jdamato@fastly.com> References: <20241001235302.57609-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 --- 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.25.1 From nobody Thu Nov 28 10:53:15 2024 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (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 D46351E1A35 for ; Tue, 1 Oct 2024 23:54:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826847; cv=none; b=N6HaQviozi9gvIkfTqTKKdyDxWwLWoHb2ouNr/T2Juv78fLZUE1VTvV9iPrTSR2Lt7jWBVGeaBExtmYodyEsEpKQUzHM+Sr8/+cVurlg94bh1xGI/MtPKGl23OmvaRSADBb2bda1Fi/FK46nZd2wtb12VZFEK8lL1j1J+RgeloM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826847; c=relaxed/simple; bh=V1cs8PIynlwOrqpZWUDccPgmCikFp/sP5CKLnXd9jKQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SDeZWen0+/u3SgU7yKaksgFTHk6+qNndEypmRzcijPbyewCCJaM3PEH7dVgUufszm12RZDSBPFT0PZUwbGgZ2dB7ulsVX1xjyuQpcJ5u2gQ7wmGxrk3oUDwjy7XU6b8XeBo8xLkBJXAz5NnwOnQyAtdF4TBx2X8u5FYfEduakYo= 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=EpY8Z0zX; arc=none smtp.client-ip=209.85.216.45 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="EpY8Z0zX" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2e188185365so237828a91.1 for ; Tue, 01 Oct 2024 16:54:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727826845; x=1728431645; 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=aGBwpUl9kCiLHYdWMLl9DJsonbhtGhnaZmowBhBViU8=; b=EpY8Z0zXPyx4D8vghd4Og9TjmOW7gDpPw2BctIZ0EKOI2CwOyGK6Ypqf/h78/VSyW8 PJISXlt5wEkx8bpSNkSSNgY2qtNWuIvZ/wUujvTfeXh1APCzlDLY2JGiRdmFdVojerTq odGryhVp9wz1xmxKWHmWmABLlHdEWs9/flG1w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727826845; x=1728431645; 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=aGBwpUl9kCiLHYdWMLl9DJsonbhtGhnaZmowBhBViU8=; b=c68spAaW2Lj+aBIcB+Et9lCbs5kQq4P9c1HssFf1vR6JU3XBCDsJp506xQHovyML9t y5ELYJj+CX1MPVpdl5U6WqP2L+4aUc2b7FVO9gVtr8uR7bQAvSBJSKrSXxfRm45NoeY6 TiFT+WMqFuzdaXx3W5TZZ26BOAHnZ31cdWYmmXVbrDExft7amoau951Y2H3TizC9Wt/e En7WKoabX1i0ecw4cbBzPfk4kE+l/nW7qMQO4uj+DvgkW6MeWmb9lOCVO1ZYzQJ5bBNo nB6WI4bLsSn1smsdxIdvEXjl9lmdTJVOjnUtgMKorqfUxhHE1c/urzu23kzcnHa1G39J P8ug== X-Forwarded-Encrypted: i=1; AJvYcCX5OX0Nvr2JkpBpVoywUsn5lzA0X50qsXI4LzgDGSNUTcFB+r47UegWIvNcfhejZI/bb3najGqeflbfYyg=@vger.kernel.org X-Gm-Message-State: AOJu0YyvEb7c+CLs2w2v34Sp7a04l8sNTSUxJLRXCHX20jehZHxUX6Hf bhdSIwYoyQ9Tf/e7rdWfrQxd/YzHS+9swB1AZrGTbKsC0L8u5NVaqqZpA4tuBi4= X-Google-Smtp-Source: AGHT+IHH0M+tYuCS0vhSmHV9gXbNu6UtuY0Q3nfoA1P+p7ZvG4sPDyAAL0B88yi8W5maqglkVlbXeg== X-Received: by 2002:a17:90a:604b:b0:2d3:c638:ec67 with SMTP id 98e67ed59e1d1-2e182ca768fmr1714582a91.0.1727826845207; Tue, 01 Oct 2024 16:54:05 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f89e973sm213130a91.29.2024.10.01.16.54.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 16:54:04 -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: [RFC net-next v4 8/9] mlx5: Add support for persistent NAPI config Date: Tue, 1 Oct 2024 23:52:39 +0000 Message-Id: <20241001235302.57609-9-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241001235302.57609-1-jdamato@fastly.com> References: <20241001235302.57609-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 --- 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.25.1 From nobody Thu Nov 28 10:53:15 2024 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (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 81AC61E202D for ; Tue, 1 Oct 2024 23:54:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826849; cv=none; b=EaJICXj+igc8mtx7UyxuAby73unBHnoU7p3gslXUnMWIml+Y9ejHkUqowJi8hi9eYNxiYC5VBleXg+XgVqqhlmwznksh+qw/W96wXC7NH89aDw3BhG+7vky/suSXrl0E3BCvJZaNmnWPDm4Ogqz6MiWmjeQt9XL5C106vSv08nk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826849; c=relaxed/simple; bh=acO4k3Tl1873YqlB+9+oRM1/HbYr6wa8DEvdBbXxJoQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BxaFypc+NhPDgYk5D0vvlkprArEiWTJYQJ9xJVxXj73hQ1PNFZbmPZGj4CVWZx1emeIooTPIx43ZsJ2DhmrUkE0edET0OOv/RmPY0c1DE+7/2nWtc8EEgWH2ZfhdMIrk/7hWyqlUJ7yrpUbK8gHbJQ5tEXpNzfbe9yiYWH99csM= 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=I9CuXGuZ; arc=none smtp.client-ip=209.85.216.44 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="I9CuXGuZ" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-2e0a74ce880so5043514a91.2 for ; Tue, 01 Oct 2024 16:54:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727826847; x=1728431647; 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=PGtnVysYWBB+XDp/kZF0mQyFvrv7Ut5AwNUz8on3uqI=; b=I9CuXGuZCTP3ykMhvyDAZ3l2VCzD+7AFe15fY10/SC64P7jfCeMu44RPAapDArvRNa +O9ayxq+2/5owICuq02oO5dZ9kAd00aJK+IsJ5aEuNo3NUOH/CRoN6i7UMAagl24I4Q3 aJF29Wq5iOl8V13wSgyVBST713b896eQivgFU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727826847; x=1728431647; 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=PGtnVysYWBB+XDp/kZF0mQyFvrv7Ut5AwNUz8on3uqI=; b=UjwawzWWz+PI40pefCEKUJgdI2VqEXOIQHUPtiNe8sxlALV5OqJrfsYymu5EEeaKrx TyWOF+H8h7Oh/Rzbf99e8WcuNKI79XjtR7NczsmDA7fs7XaQozbnA1dnVkHBqqf4ciR0 sgT5xCRTCn/VTQcV9LytyXMczFyWBGlUKi8v/3otm5ppasxfDoDMBE508CquvBpFKBkw beKVXC3VNBE3xGMtTwuUTyNN8KKv/JcZ6CzV82ypB1aHfGEIPTj29XeLlzCB1wNMwaiI 1RWO1IOM4jHSjmeeZ/az7w1WfvDhxMUR7CU9ghgndvSmoOUEZrnB/9nbte7u1mZMs/0U QBvA== X-Forwarded-Encrypted: i=1; AJvYcCW835Llfrrh7YWdOSY+NMnVrEENkgUUceUObUxFbsVTCKPUnyseedWhosicwq/n1PLsOSiFNDhC9tkpq2s=@vger.kernel.org X-Gm-Message-State: AOJu0YziiPIxNgvdljtfI1EY8NidyQFGK8Zg2PxKp1V1xnNN0JpW3y3t 0te5LmM2c1rdsLxMoAd6ZlboUBb1h13lolcx4QKH3inEKME4OwxGWir+xyg3kPk= X-Google-Smtp-Source: AGHT+IFCgBS+YgTB1iRrCXeD774tHuBkiuRdbbUI5qwujyFtDh9/oA9HeddTZv+rnPbzAgKNnb5EZQ== X-Received: by 2002:a17:90a:bd0c:b0:2d8:aa9c:e386 with SMTP id 98e67ed59e1d1-2e18455c8e2mr1759138a91.14.1727826846920; Tue, 01 Oct 2024 16:54:06 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f89e973sm213130a91.29.2024.10.01.16.54.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 16:54:06 -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: [RFC net-next v4 9/9] mlx4: Add support for persistent NAPI config to RX CQs Date: Tue, 1 Oct 2024 23:52:40 +0000 Message-Id: <20241001235302.57609-10-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241001235302.57609-1-jdamato@fastly.com> References: <20241001235302.57609-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 --- 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.25.1