From nobody Sat Nov 30 16:36:40 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 086A4175D25 for ; Sun, 8 Sep 2024 16:08:35 +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=1725811718; cv=none; b=BOAJuEb2bo8FdBTS3onZeH/bSN6yStd/9xN7GTcBcf1qcJmfO0+hoZS27oAVlmZ7tkhch10GDUMbg8cJ+w3Fdu25OH7CUxrRXYUsgkGdfZABurZr9g5MPVN765ujbAAf/y7sSEFKsWrKrNxmxpQ7iWbyUaosFzEXo8FD06pyvt4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811718; c=relaxed/simple; bh=TEopUeuNpArQzjNi0/ijxKYlco4fqs+wda8kEBuhDiU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pXzM1iHY0lxXtv8tFNat3IltCG5l9DYgyV06oiGXNdwGtMj9FSFLeV6xdBeM0VicMS7EHaZWZYXb6Q9vNVx73JDRslbOyTSwuLZeiv4GobLeVCT5atUOtCVhuWqJYjaRDTOixqK1QCciz0jQawz13gbSbmLZiVzoArsJ45xPLFM= 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=dKuGZRhq; 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="dKuGZRhq" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-20688fbaeafso34510855ad.0 for ; Sun, 08 Sep 2024 09:08:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1725811715; x=1726416515; 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=x49fADX7wQzdDZdnsJnfx2RtW4EZX6aPDebcZANzv7Q=; b=dKuGZRhqdIJrtKr0C/6GnrYPGUVAXSHtBbi1OKNpUy7/DFwDC70T3UOtzgwxXUHRAm R9N728pgf0cTg1mgEhO9FEeR7hpV3Z57z4ETx6pCUV7+BXzif+O6/n4JQmCCjkcJp5KD Cbe6xKBDrIlbMbfPNj8F1GlTdJClUdGk6O1Mo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725811715; x=1726416515; 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=x49fADX7wQzdDZdnsJnfx2RtW4EZX6aPDebcZANzv7Q=; b=g1z45oJ/+DRQrTNFy5pxORj8Sdc9XXBkMVi/arhP0pdI03dSzmE2NnUfq/850iUh7m wFoGNeJUYeqW7Wy9Db8S8eTrDrT6oMq2XoZ5pon2DZ69ZQYcKWnRIhVkwimj7xkpJyou Xtjg1KhUudWkIGCg/U/l1nwvXAGJzHWZVlrv5x6QFRrzHQU7+33tKQ68Fch53fqmBGpx 0TmOurqwGMeSs8XEBEneSmUPGu8dRz8rRPJ90FKSQXwoXoqHkpjcDOOH01fqKJS/zhbS 65D45vrUe3ongtxDw2qoMlogPCSWo5oDmyzCAlVMbSWfKtfmjyJBAXOPOvOaCz6d+bIR 8yvg== X-Forwarded-Encrypted: i=1; AJvYcCWfXteOSIM+TX+o0l1Tr33b0yzWvXWL8ogHn/QEptTosQtkEXVrycU+kSYWyuO/VmGBCOd7o0BsbkDUs0g=@vger.kernel.org X-Gm-Message-State: AOJu0YwMI/E5fF2Lefk7YHxjqZwf2pD0APYFosGqLRN8v+nlg+eeAULB nHnn01fEofaUaM07xis8dvHI/RH6+MOplWF5WAlJ2x3WlzM4QGRzjGggcFLFEfI= X-Google-Smtp-Source: AGHT+IE3kHdpTxCt3sf1n/2nkPKmrrFiS28bSOkpaARZ0WbViQPWroW4ok4KOIVg7NpKcj3hfUxghg== X-Received: by 2002:a17:902:ec8f:b0:202:4666:f018 with SMTP id d9443c01a7336-206f04e55c3mr118419965ad.15.1725811715224; Sun, 08 Sep 2024 09:08:35 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20710f3179fsm21412535ad.258.2024.09.08.09.08.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Sep 2024 09:08:34 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, kuba@kernel.org, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, Joe Damato , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jonathan Corbet , Jiri Pirko , Sebastian Andrzej Siewior , Lorenzo Bianconi , linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v2 1/9] net: napi: Add napi_storage Date: Sun, 8 Sep 2024 16:06:35 +0000 Message-Id: <20240908160702.56618-2-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240908160702.56618-1-jdamato@fastly.com> References: <20240908160702.56618-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 storage area for NAPI configuration to the core. Drivers opt-in to setting the storage for a NAPI by passing an index when calling netif_napi_add_storage. napi_storage is allocated in alloc_netdev_mqs, freed in free_netdev (after the NAPIs are deleted), and set to 0 when napi_enable is called. Signed-off-by: Joe Damato --- .../networking/net_cachelines/net_device.rst | 1 + include/linux/netdevice.h | 34 +++++++++++++++++++ net/core/dev.c | 18 +++++++++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/Documentation/networking/net_cachelines/net_device.rst b/Docum= entation/networking/net_cachelines/net_device.rst index 22b07c814f4a..a82751c88d18 100644 --- a/Documentation/networking/net_cachelines/net_device.rst +++ b/Documentation/networking/net_cachelines/net_device.rst @@ -106,6 +106,7 @@ rx_handler_func_t* rx_handler = read_mostly void* rx_handler_data read_mostly = - =20 struct_netdev_queue* ingress_queue read_mostly = - =20 struct_bpf_mprog_entry tcx_ingress - = read_mostly sch_handle_ingress +struct napi_storage* napi_storage - = read_mostly napi_complete_done struct_nf_hook_entries* nf_hooks_ingress = =20 unsigned_char broadcast[32] = =20 struct_cpu_rmap* rx_cpu_rmap = =20 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index b47c00657bd0..54da1c800e65 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -342,6 +342,14 @@ struct gro_list { */ #define GRO_HASH_BUCKETS 8 =20 +/* + * Structure for per-NAPI storage + */ +struct napi_storage { + u64 gro_flush_timeout; + u32 defer_hard_irqs; +}; + /* * Structure for NAPI scheduling similar to tasklet but with weighting */ @@ -377,6 +385,8 @@ struct napi_struct { struct list_head dev_list; struct hlist_node napi_hash_node; int irq; + int index; + struct napi_storage *napi_storage; }; =20 enum { @@ -2009,6 +2019,9 @@ enum netdev_reg_state { * @dpll_pin: Pointer to the SyncE source pin of a DPLL subsystem, * where the clock is recovered. * + * @napi_storage: An array of napi_storage structures containing per-NAPI + * settings. + * * FIXME: cleanup struct net_device such that network protocol info * moves out. */ @@ -2087,6 +2100,7 @@ struct net_device { #ifdef CONFIG_NET_XGRESS struct bpf_mprog_entry __rcu *tcx_ingress; #endif + struct napi_storage *napi_storage; __cacheline_group_end(net_device_read_rx); =20 char name[IFNAMSIZ]; @@ -2648,6 +2662,24 @@ netif_napi_add_tx_weight(struct net_device *dev, netif_napi_add_weight(dev, napi, poll, weight); } =20 +/** + * netif_napi_add_storage - initialize a NAPI context and set storage area + * @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_storage(struct net_device *dev, struct napi_struct *napi, + int (*poll)(struct napi_struct *, int), int weight, + int index) +{ + napi->index =3D index; + napi->napi_storage =3D &dev->napi_storage[index]; + netif_napi_add_weight(dev, napi, poll, weight); +} + /** * netif_napi_add_tx() - initialize a NAPI context to be used for Tx only * @dev: network device @@ -2683,6 +2715,8 @@ void __netif_napi_del(struct napi_struct *napi); */ static inline void netif_napi_del(struct napi_struct *napi) { + napi->napi_storage =3D NULL; + napi->index =3D -1; __netif_napi_del(napi); synchronize_net(); } diff --git a/net/core/dev.c b/net/core/dev.c index 22c3f14d9287..ca90e8cab121 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6719,6 +6719,9 @@ void napi_enable(struct napi_struct *n) if (n->dev->threaded && n->thread) new |=3D NAPIF_STATE_THREADED; } while (!try_cmpxchg(&n->state, &val, new)); + + if (n->napi_storage) + memset(n->napi_storage, 0, sizeof(*n->napi_storage)); } EXPORT_SYMBOL(napi_enable); =20 @@ -11054,6 +11057,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_storage_sz; + unsigned int maxqs; =20 BUG_ON(strlen(name) >=3D sizeof(dev->name)); =20 @@ -11067,6 +11072,9 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv= , const char *name, return NULL; } =20 + WARN_ON_ONCE(txqs !=3D rxqs); + maxqs =3D max(txqs, rxqs); + dev =3D kvzalloc(struct_size(dev, priv, sizeof_priv), GFP_KERNEL_ACCOUNT | __GFP_RETRY_MAYFAIL); if (!dev) @@ -11141,6 +11149,11 @@ struct net_device *alloc_netdev_mqs(int sizeof_pri= v, const char *name, if (!dev->ethtool) goto free_all; =20 + napi_storage_sz =3D array_size(maxqs, sizeof(*dev->napi_storage)); + dev->napi_storage =3D kvzalloc(napi_storage_sz, GFP_KERNEL_ACCOUNT); + if (!dev->napi_storage) + goto free_all; + strscpy(dev->name, name); dev->name_assign_type =3D name_assign_type; dev->group =3D INIT_NETDEV_GROUP; @@ -11202,6 +11215,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_storage); + ref_tracker_dir_exit(&dev->refcnt_tracker); #ifdef CONFIG_PCPU_DEV_REFCNT free_percpu(dev->pcpu_refcnt); @@ -11979,7 +11994,8 @@ 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_MEMBER(struct net_device, net_device_read_rx, napi= _storage); + CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_rx, 112); } =20 /* --=20 2.25.1 From nobody Sat Nov 30 16:36:40 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 582C8176237 for ; Sun, 8 Sep 2024 16:08:39 +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=1725811720; cv=none; b=bnBIWwq2G5DDYShBef0hC7ZdRkQa5giJ4iCBY8AAkBG/P7CQL8YeDnOG4Jb00LlzbxJ68GTq72m8V6pfmRi30nldNeez29+Tirp1MqJfw6YFOBLjBiuGTmz2JZrghPXYR/qmL7BEZV5rdC5iIVvSWMXt3sj2YrDVZ1dgYQokrvk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811720; c=relaxed/simple; bh=BNKvxVYTuL++N+ZYm9W5qpapoauvjei5NqpfkRAMLoI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eqhE+AbelCwvoSgn/8B2rdzR1gGRxGu2EbK8IF/P7MMNw6EpWaVzPv/jRDB63ImR6FZGmeiUXQGJuERNSGTEjs/D0sgftAzYYDA1Z1UiWGwD21guUSI+0yUPM4WzCA1S0lSYBLlaPKeuKKiOGQtXBcBgQ90X7AFF4+A22PnAQpY= 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=HPjlKk2Z; 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="HPjlKk2Z" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2068bee21d8so34946685ad.2 for ; Sun, 08 Sep 2024 09:08:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1725811719; x=1726416519; 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=XALJ7SdzaDOWVbMSTdcXBR+9NoF8QqBzXwj7wqN3oPE=; b=HPjlKk2ZuTa/atl77mD7Im12rUTZ0Z0HtN55HX4fx7qAQVRzjx7R4pwu/D9ReNtMx1 7434M3+Lg/FGOJT4qbEe0XODccNBfUZWbBzcBd4wuQP77g/DdDy+bMg14PaZhn2Gnakg GYw9vn0O6CZC3n+RDSqQYGOU+zlMKvYAAlXNQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725811719; x=1726416519; 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=XALJ7SdzaDOWVbMSTdcXBR+9NoF8QqBzXwj7wqN3oPE=; b=fGOVUcbwl0qLaq/SvuPmczWjtUcQz87F85pqLVQrGoeYoJjcorEN0hNaiio9Idq23N PkKCbw083fXiW5nDkbaD+3b+KXGndDJCF6U0uB3RPYNoaxtwJTpBQTrAgK0Z6wSur9gx IkCK884v8/2qf9UkF2L43ocPwMVW4E6tvViQK/A2gAQ3CpZTLLsb+U4HM/cXtPRzdUEy b4Ju2H2nlAYtDViie8LfdH7w14odYqmaQ7Abp8mxRPsp1jWaiOR1U6eOzTwOYClQGrLZ TTTrFjkoRnCjfDtpvgxYLQc0YGjGNx+2CE7AhKAG6xPGiVX3Q3YIw4LH0qK5OAKcuh5X QtEw== X-Forwarded-Encrypted: i=1; AJvYcCWisjEOLdQWyrLJ93Et81htXLQiVxYbESf9M2KhBmnA1BWvrYJ3r3fml4d8yeTcPNrDHFeA39PsYQlIZbA=@vger.kernel.org X-Gm-Message-State: AOJu0YzbIhU7VI/qz0GU30tnDwdMMzQdcTz3KMJktmUJ5KvITX+9GvMW xm8ORwdNc7Q7NWJ7LRO2eyVZ+beKGq/KoFyvEOETW+PiJeMCg/dJ5Tf1E7mPR38= X-Google-Smtp-Source: AGHT+IFSF82ScYVZRAI2likR2SsKzoBk6rQOgSbeMrGcT+1n67/wRDaY703WCe1MsbvqtuQbVhJ/Ww== X-Received: by 2002:a17:902:f68e:b0:202:9b7:1dc with SMTP id d9443c01a7336-2070c1c74c7mr74584625ad.54.1725811718448; Sun, 08 Sep 2024 09:08:38 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20710f3179fsm21412535ad.258.2024.09.08.09.08.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Sep 2024 09:08:38 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, kuba@kernel.org, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, Joe Damato , "David S. Miller" , Eric Dumazet , Paolo Abeni , Donald Hunter , Jesper Dangaard Brouer , Xuan Zhuo , Daniel Jurgens , linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v2 2/9] netdev-genl: Export NAPI index Date: Sun, 8 Sep 2024 16:06:36 +0000 Message-Id: <20240908160702.56618-3-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240908160702.56618-1-jdamato@fastly.com> References: <20240908160702.56618-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" Export the NAPI index on napi-get operations. This index will be used in future commits to set per-NAPI parameters. Signed-off-by: Joe Damato --- Documentation/netlink/specs/netdev.yaml | 9 +++++++++ include/uapi/linux/netdev.h | 1 + net/core/netdev-genl.c | 3 +++ 3 files changed, 13 insertions(+) diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlin= k/specs/netdev.yaml index 959755be4d7f..cf3e77c6fd5e 100644 --- a/Documentation/netlink/specs/netdev.yaml +++ b/Documentation/netlink/specs/netdev.yaml @@ -244,6 +244,14 @@ 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: index + doc: The index of the NAPI instance. Refers to persistent storage = for + any NAPI with the same index. + type: u32 + checks: + min: 0 + max: s32-max - name: queue attributes: @@ -593,6 +601,7 @@ operations: - ifindex - irq - pid + - index dump: request: attributes: diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h index 43742ac5b00d..e06e33acb6fd 100644 --- a/include/uapi/linux/netdev.h +++ b/include/uapi/linux/netdev.h @@ -121,6 +121,7 @@ enum { NETDEV_A_NAPI_ID, NETDEV_A_NAPI_IRQ, NETDEV_A_NAPI_PID, + NETDEV_A_NAPI_INDEX, =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 a17d7eaeb001..9561841b9d2d 100644 --- a/net/core/netdev-genl.c +++ b/net/core/netdev-genl.c @@ -182,6 +182,9 @@ netdev_nl_napi_fill_one(struct sk_buff *rsp, struct nap= i_struct *napi, if (napi->irq >=3D 0 && nla_put_u32(rsp, NETDEV_A_NAPI_IRQ, napi->irq)) goto nla_put_failure; =20 + if (napi->index >=3D 0 && nla_put_u32(rsp, NETDEV_A_NAPI_INDEX, napi->ind= ex)) + goto nla_put_failure; + if (napi->thread) { pid =3D task_pid_nr(napi->thread); if (nla_put_u32(rsp, NETDEV_A_NAPI_PID, pid)) --=20 2.25.1 From nobody Sat Nov 30 16:36:40 2024 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.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 0E67E176237 for ; Sun, 8 Sep 2024 16:08:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811725; cv=none; b=fpJFfArqbdhsQUeXaXtp8g7lj2sYlEHCTFr50NSP86Irtx9zmLOWgxHaLpK/YZ2EYrsic6ej/VcQWZo8YTnb3ZtcOb4IusN24diG5nA29gavdcKnpcVX8J6t8Ef+ao1+J6tFw/miRPV6bHz4Tm2c/2X46M4hszJ/WP8abGeJIVA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811725; c=relaxed/simple; bh=qZ0T8CKExRvD5T2B1Yh7TajT/3Et+GX0HYMbFOGpRZQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oy0UyJEsA3tJHSEjBcleHB1xOrzvolvGYCl8OzPRsCwgGnlqL1EkLL41H0EOFJsQrEz5G7utBrXFftRleFGGEXQc+mHeoFOG5xjLp1NHz2+JvUHjW/bwJRemos7kn5kce4lDogJmDz39iDc82oNSnwF5JpezLqSZx5sPNQK7iAk= 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=X35UlQLr; arc=none smtp.client-ip=209.85.214.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="X35UlQLr" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-206aee4073cso35927895ad.1 for ; Sun, 08 Sep 2024 09:08:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1725811723; x=1726416523; 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=iiyI3KUrh2IbLXgMecroHUMIkcTz7Cey6giPzmfBc6M=; b=X35UlQLrm27ddHTcUnU2CVgp3rFZosh/uCoNiay7/1ArTVzzq9dU5qCTSMhgMnUhow 1hxVXG0GdsdSpwW4rjTpSvQbF2mP9xVdE95BLRQG/fIPyqJy2A2obBkSjqXejdUpiKwS d5yKr66ITZi6A0fmPcJFKYZ9O/SKHEEuXVkuI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725811723; x=1726416523; 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=iiyI3KUrh2IbLXgMecroHUMIkcTz7Cey6giPzmfBc6M=; b=W26xSiBIx302TFmTQZnMllawQ0Y3r76CvAtKMoINUCGheDAR+IA2PiLNTNxGbXmUNX hkp3p0xZLkaeYofzoWQ/IpMoirMMcfkL0dh1PXQwmXffCYK62DlYtZBSuQqEcn2a8PkA 0KFrY6rWmpqyn263/PhIqUVGjHZBK0T8VyZ6ZlzJpBjY9ZptNmv29sMo1ArkXOWex7Tl Ji8tfxHXm5p/Xo3Pkl3rLbntsz+NrYlD3wsiIpwHv8qDLziDnhB/cn75Mr/tG0AB4ihg Hk54pQ+fqbAKbvZ+FhTTSwaDJNLFBe9nNKNb0aPWT9KIQ+ulq8NAdF8vEWhYFvIxLgLI NDBA== X-Forwarded-Encrypted: i=1; AJvYcCXzsKza6h2lDLrWdqKFr+qLHFrWAmUt06LWdIUQUOT6gjdl8DVeUobjFi2BctaLXIdRGB1IdaVnHsSotEc=@vger.kernel.org X-Gm-Message-State: AOJu0YytigLJygvUixEsN7icf95qO57l1FYY7Tr+zGD00sXKCs9if6ew Z/9tqxkYqZvDHCLCZLDZcLCz/orIxIc3cKxQhxpaRqu/7pciFGgoYxmqaiOrP90= X-Google-Smtp-Source: AGHT+IGn8u85dwq4o1reUH1GhhZmDtmxxPG4rQjIJ7eMol+kaITAp2KDE1rStg8cebOoGXifDmTKXQ== X-Received: by 2002:a17:902:e888:b0:202:2fc8:da35 with SMTP id d9443c01a7336-206f06241femr125103985ad.55.1725811723333; Sun, 08 Sep 2024 09:08:43 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20710f3179fsm21412535ad.258.2024.09.08.09.08.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Sep 2024 09:08:42 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, kuba@kernel.org, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, Joe Damato , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jonathan Corbet , Jiri Pirko , Sebastian Andrzej Siewior , Lorenzo Bianconi , David Ahern , 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 v2 3/9] net: napi: Make napi_defer_hard_irqs per-NAPI Date: Sun, 8 Sep 2024 16:06:37 +0000 Message-Id: <20240908160702.56618-4-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240908160702.56618-1-jdamato@fastly.com> References: <20240908160702.56618-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 defer_hard_irqs setting. 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 will read from the net_device field. sysfs code was updated to guard against what appears to be a potential overflow as the field is an int, but the value passed in is an unsigned long. 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 | 1 - include/linux/netdevice.h | 2 +- net/core/dev.c | 10 ++--- net/core/dev.h | 40 +++++++++++++++++++ net/core/net-sysfs.c | 2 +- 5 files changed, 47 insertions(+), 8 deletions(-) diff --git a/Documentation/networking/net_cachelines/net_device.rst b/Docum= entation/networking/net_cachelines/net_device.rst index a82751c88d18..4cd801398c4e 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 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 54da1c800e65..5a58cf61539e 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2088,7 +2088,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; @@ -2412,6 +2411,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 ca90e8cab121..9495448fedaa 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6228,7 +6228,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--; @@ -6366,7 +6366,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); @@ -6648,6 +6648,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); @@ -11033,7 +11034,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); @@ -11982,7 +11983,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); @@ -11995,7 +11995,7 @@ static void __init net_dev_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, tcx_= ingress); #endif CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, napi= _storage); - CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_rx, 112); + CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_rx, 108); } =20 /* diff --git a/net/core/dev.h b/net/core/dev.h index 5654325c5b71..2584a7de189f 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -138,6 +138,46 @@ 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) +{ + if (n->napi_storage) + return READ_ONCE(n->napi_storage->defer_hard_irqs); + else + return READ_ONCE(n->dev->napi_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) +{ + if (n->napi_storage) + WRITE_ONCE(n->napi_storage->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 their defer_hard_= irqs set + * @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 0648dbf0e234..0a0bbbfb39b4 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 Sat Nov 30 16:36:40 2024 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.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 0BE551369B4 for ; Sun, 8 Sep 2024 16:08:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811729; cv=none; b=u+AwkvXWoD/DadkqKeHss5H8qqkNMmPhFG8CtE+EBDZWYZOsO7X7gT9fGAC4EEQbxEvJD6sFvs7tLGHRi4NQT6UgH6FIobSnif1+UJQA8Z2yZ7b0aj33bHsogYpjGA9nMnagdJ7gV1LBrhAqKrwcoBhKhz/r9vrTTVBcefGkMGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811729; c=relaxed/simple; bh=S6PZndeVLZnfh6ZqdJsAlBwaDjFgBkDRfqKlXOKQG7Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Nt4LWmGQXedKDzA6kmh5EZUCw7868wxuVURab7Hnok5bkNx1kztyQsERO20UPcZ0YvdlXYA3qpKDm0jHfgl3dyuS+s/KKRzk0H6quYVGhyNxhZjzFbqFGQDzLc4tCzgwTd0KuZJaaJ4+GqNxVFUukvgAUiKWALWcgwDhBRVPbuk= 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=TvY1osHd; arc=none smtp.client-ip=209.85.214.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="TvY1osHd" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-205909afad3so35448385ad.2 for ; Sun, 08 Sep 2024 09:08:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1725811727; x=1726416527; 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=ITiLh+mkz38oBRCpyHHyb5jRcgvfzTrPSkEX4VapaAc=; b=TvY1osHdU7jojtlmef8LyN4PZxcZbLUreT1yDtc+H5+azxhQeu0kH2fKeMYFd/o4oN e59vEOKGDoFcj3jAsXeZ4QC0JcLjJE+5qh7RwoShvqGGdbmz0wtcsDo06LmHicC2Y+BM A3pZDldsOgqNtdViC7Nqnr3T8yPb4secEriJA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725811727; x=1726416527; 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=ITiLh+mkz38oBRCpyHHyb5jRcgvfzTrPSkEX4VapaAc=; b=YditUiACtory/Wl64OeVn0SmQppfoYGkOUMO7SUHftd3twj2tWF7wGsGf+HegdD7Qu SPvsUMJ+NDR6LVnjNAF8mn50EuFriWgSc0W04QtjGMm69Ms6ogp8dCHUGM9R5Awc/WGG EnrkO2WQqXeJfKWmbaGLNP+fH3V8vzvXXz5+lxmo/FZAQ4iijGF25qUrcXeN0azHV/Bl TN8sT+AmxprfjcVpaFbp1SM3UcgunXGfnYG4TlDhWCzMz2rf7pq1sXXiLJaRPnQ+csJS qOyhn1DtKeFW/EZXMkSElA7EyuvwhzOOLe40Gwc0FMe7yTaxQZYfynJJP58XOwGgukjf Kppw== X-Forwarded-Encrypted: i=1; AJvYcCXzp64jFa73Msx3sZ2Q2qRR1XmRFqXtl0H8PywGVG2eiYUeoXoNmxEQUGb0LbP3Gvecvj54wttOPKShjOI=@vger.kernel.org X-Gm-Message-State: AOJu0Yx26LGDh+NkW6cddBa+yFAElGhYRVfTF6hCcrFhIZnP+mYkmzHG 61FXfRqzFhOaVn2fNuv0Z+AUrUld6NDmZklguqFQkYrEgigwQox4OX78n7cenI0= X-Google-Smtp-Source: AGHT+IFJzkoh2w79YY2G7uU21hfkz80FED0X4UGg87fkUXsPO7qkO/RCEE4WoM3GHcjxmcv7th1ddA== X-Received: by 2002:a17:902:b696:b0:205:709e:1949 with SMTP id d9443c01a7336-2070a817383mr52725005ad.57.1725811727148; Sun, 08 Sep 2024 09:08:47 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20710f3179fsm21412535ad.258.2024.09.08.09.08.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Sep 2024 09:08:46 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, kuba@kernel.org, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, Joe Damato , Donald Hunter , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jesper Dangaard Brouer , Xuan Zhuo , linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v2 4/9] netdev-genl: Dump napi_defer_hard_irqs Date: Sun, 8 Sep 2024 16:06:38 +0000 Message-Id: <20240908160702.56618-5-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240908160702.56618-1-jdamato@fastly.com> References: <20240908160702.56618-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 | 5 +++++ tools/include/uapi/linux/netdev.h | 1 + 4 files changed, 15 insertions(+) diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlin= k/specs/netdev.yaml index cf3e77c6fd5e..e4219bfff08d 100644 --- a/Documentation/netlink/specs/netdev.yaml +++ b/Documentation/netlink/specs/netdev.yaml @@ -252,6 +252,13 @@ attribute-sets: checks: min: 0 max: s32-max + - + 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: @@ -602,6 +609,7 @@ operations: - irq - pid - index + - defer-hard-irqs dump: request: attributes: diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h index e06e33acb6fd..bcc95b7ebd92 100644 --- a/include/uapi/linux/netdev.h +++ b/include/uapi/linux/netdev.h @@ -122,6 +122,7 @@ enum { NETDEV_A_NAPI_IRQ, NETDEV_A_NAPI_PID, NETDEV_A_NAPI_INDEX, + 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 9561841b9d2d..f1e505ad069f 100644 --- a/net/core/netdev-genl.c +++ b/net/core/netdev-genl.c @@ -160,6 +160,7 @@ static int netdev_nl_napi_fill_one(struct sk_buff *rsp, struct napi_struct *napi, const struct genl_info *info) { + int napi_defer_hard_irqs; void *hdr; pid_t pid; =20 @@ -191,6 +192,10 @@ 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 43742ac5b00d..43bb1aad9611 100644 --- a/tools/include/uapi/linux/netdev.h +++ b/tools/include/uapi/linux/netdev.h @@ -121,6 +121,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 Sat Nov 30 16:36:40 2024 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 997CA174EF0 for ; Sun, 8 Sep 2024 16:08:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811737; cv=none; b=Bj2od881ih3wmPskp/9EeIxXZqsaOwJHeWwK+fPGyZv/hNCbFQ3XrQCIq+mJiaX/E3xg0cVX5/L0Nut/z2VGa4/GZH+rsR/A88jj4MQTSeNVltFamJaF4Sx1J7N0y5YVzGVlfkyMATQsqoMiU1Vsuyov/65vxU2jvQHWsu2wX0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811737; c=relaxed/simple; bh=ryiIpJm632xkb94Po//mkHBaEu4pHuYO0ox2yGhmVr8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WX1PtRRQmBSVCWc+cQ5sGQC+4WM7o+YSUQH6YPWyffSVTp/6CeSbWpXwUW+koY+TsJku7TyIqHdsjfqxWvjLzZDTM3HA48jDcDAy1HoOLBF7/Or6g3LA8g0Q2/wS1TInIKvR9h09HUz8k0lcbk0l/Oxxir6Zzzv7FNlIc6NX3HU= 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=x/CvXFU2; arc=none smtp.client-ip=209.85.214.180 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="x/CvXFU2" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-20551e2f1f8so34371925ad.2 for ; Sun, 08 Sep 2024 09:08:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1725811735; x=1726416535; 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=cutCYiW5AvtHkH16vmOwslCfo3Rvow8Fok3IyNUjOYE=; b=x/CvXFU2tldNguxf4BZQYjL19lFWInvFIL6qurT322g0Gx5gcIvH8jmDiy/kPQtpNu e4Jj8iG0aJiGkjSszYFgDlZ1vQ8lC5mZD5fChnr5P461qVX79aep+eeZi2pG7klBlfPo LFTW3JDShoj+R/qiCbRtoK2QpJUmanXJQiqkA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725811735; x=1726416535; 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=cutCYiW5AvtHkH16vmOwslCfo3Rvow8Fok3IyNUjOYE=; b=kx1H5FEfZWTlnVj+2oGfkm2//vQnFbX3+ZES4WbPSyWn8NIIxsIMKsIUC1yPekXMnk Xd1uzO8kaq4ZZiqVmkSBDwBlkb8u0eQvZKjL1Yra/z/GWqgubXijm+YndLKyt7X5O+HX /BABKhwqCFzuqag+QAEjkZU4bxmF/xxJQpS1AWa+AwynBnl/rrgPQu+jDzt5hfdu7S8O 4J5fOH5RfuHsd+bVQF2sYhCvi9x+hGh4y8CLSZxrHnJxnYkpCLNBmKhv4SAwuV3eZG4F MfA2GonC2mN7O6lzxLE5h3+Ec4r0BA5TkzjfojEGNLOWhw81RZAQBBCMIqql49koy6EG NWaw== X-Forwarded-Encrypted: i=1; AJvYcCXiVsJhjDUT6F6STCUD1fp4Y0hf2bKX/FcEtZs0Of2D3/4dtRnv/KoPwNTBrXql/eotxQ6P8ClUarQGQGM=@vger.kernel.org X-Gm-Message-State: AOJu0YwYmVA5IoF0opKQ738ud8PpM+Vj2iebWYDQyeG8shF2lVZ6qvrT Pc3qeDz5u3F1cK8HFko48LJg0jzY0CESx1ci2PBVKvI8M0EXa+OVflt5ZAjdMbA= X-Google-Smtp-Source: AGHT+IEWn/lj45KjkHGmx7MMlkVr2Mul+kgjJQboW48psCjqGuteovTVrXAuGcae64GwI2Y49ge7pA== X-Received: by 2002:a17:903:41c6:b0:205:82d5:2368 with SMTP id d9443c01a7336-206f05f6136mr97268875ad.49.1725811734523; Sun, 08 Sep 2024 09:08:54 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20710f3179fsm21412535ad.258.2024.09.08.09.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Sep 2024 09:08:54 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, kuba@kernel.org, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, Joe Damato , "David S. Miller" , Eric Dumazet , Paolo Abeni , Donald Hunter , Jonathan Corbet , Jesper Dangaard Brouer , Xuan Zhuo , Jiri Pirko , Sebastian Andrzej Siewior , Lorenzo Bianconi , David Ahern , Johannes Berg , Breno Leitao , Alexander Lobakin , Daniel Jurgens , linux-kernel@vger.kernel.org (open list), linux-doc@vger.kernel.org (open list:DOCUMENTATION) Subject: [RFC net-next v2 5/9] net: napi: Make gro_flush_timeout per-NAPI Date: Sun, 8 Sep 2024 16:06:39 +0000 Message-Id: <20240908160702.56618-6-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240908160702.56618-1-jdamato@fastly.com> References: <20240908160702.56618-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 --- Documentation/netlink/specs/netdev.yaml | 6 +++ .../networking/net_cachelines/net_device.rst | 1 - include/linux/netdevice.h | 2 +- include/uapi/linux/netdev.h | 1 + net/core/dev.c | 12 +++--- net/core/dev.h | 43 +++++++++++++++++++ net/core/net-sysfs.c | 2 +- net/core/netdev-genl.c | 5 +++ tools/include/uapi/linux/netdev.h | 1 + 9 files changed, 64 insertions(+), 9 deletions(-) diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlin= k/specs/netdev.yaml index e4219bfff08d..3034c480d0b4 100644 --- a/Documentation/netlink/specs/netdev.yaml +++ b/Documentation/netlink/specs/netdev.yaml @@ -259,6 +259,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: @@ -610,6 +615,7 @@ operations: - pid - index - defer-hard-irqs + - gro-flush-timeout dump: request: attributes: diff --git a/Documentation/networking/net_cachelines/net_device.rst b/Docum= entation/networking/net_cachelines/net_device.rst index 4cd801398c4e..048cc9d1eafc 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 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 5a58cf61539e..862c835bcf09 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2087,7 +2087,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; @@ -2411,6 +2410,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/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h index bcc95b7ebd92..fd02b5b3b081 100644 --- a/include/uapi/linux/netdev.h +++ b/include/uapi/linux/netdev.h @@ -123,6 +123,7 @@ enum { NETDEV_A_NAPI_PID, NETDEV_A_NAPI_INDEX, 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/dev.c b/net/core/dev.c index 9495448fedaa..a45a0dbcf711 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6227,12 +6227,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; } @@ -6367,7 +6367,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; @@ -6649,6 +6649,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); @@ -11033,7 +11034,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); } } @@ -11982,7 +11983,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); @@ -11995,7 +11995,7 @@ static void __init net_dev_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, tcx_= ingress); #endif CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, napi= _storage); - CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_rx, 108); + 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 2584a7de189f..f33d7bcb923f 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -178,6 +178,49 @@ 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_s= truct *n) +{ + if (n->napi_storage) + return READ_ONCE(n->napi_storage->gro_flush_timeout); + else + return READ_ONCE(n->dev->napi_defer_hard_irqs); +} + +/** + * 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) +{ + if (n->napi_storage) + WRITE_ONCE(n->napi_storage->gro_flush_timeout, timeout); +} + +/** + * netdev_set_gro_flush_timeout - set gro_flush_timeout for all NAPIs of a= netdev + * @netdev: the net_device for which all NAPIs will have their gro_flush_t= imeout 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 0a0bbbfb39b4..daa32b5a6623 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 diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c index f1e505ad069f..68ec8265567d 100644 --- a/net/core/netdev-genl.c +++ b/net/core/netdev-genl.c @@ -161,6 +161,7 @@ netdev_nl_napi_fill_one(struct sk_buff *rsp, struct nap= i_struct *napi, const struct genl_info *info) { int napi_defer_hard_irqs; + unsigned long gro_flush_timeout; void *hdr; pid_t pid; =20 @@ -196,6 +197,10 @@ netdev_nl_napi_fill_one(struct sk_buff *rsp, struct na= pi_struct *napi, if (nla_put_s32(rsp, NETDEV_A_NAPI_DEFER_HARD_IRQS, 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 43bb1aad9611..b088a34e9254 100644 --- a/tools/include/uapi/linux/netdev.h +++ b/tools/include/uapi/linux/netdev.h @@ -122,6 +122,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 Sat Nov 30 16:36:40 2024 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (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 D53A7175D59 for ; Sun, 8 Sep 2024 16:09:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811742; cv=none; b=fpM4EQCsatcqIUymeJnpJXQirPhs/N0F3gEpT6fSAGvzgGBQRxWDYBAnOqRP/tsFlIJArivcBFjZhP+zrn0HuET+GPyOZ/sSRqs4Z2vo5OgdCiViDBxkBaWxFzb+Tjb+xR6uhzkw4h4toNF+2ZxwixIgTkvEIefn3o+q0X0Wbtk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811742; c=relaxed/simple; bh=xROhpCG/UFEqyPlPHFBjL+Ei3IMKFCnsu+i2mJFrfH0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TLnHUmarV2MIhiiPuna+vv8ldcGuwsCgt2EmCkgHhgJHGB5GwjYZVYYWHmoEKQ+plb8DHEhMIBXvbbsIy5VxRFfMqup5DWBMiXGyZy/hwOgbR8fkzKWEJNOsL8U8MRvej5Hs8KRCque9+ZinVRU8kVNhzTrKRjLbZOg2S5hMqTY= 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=UcrojUoR; arc=none smtp.client-ip=209.85.210.180 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="UcrojUoR" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-718d606726cso1645547b3a.3 for ; Sun, 08 Sep 2024 09:09:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1725811740; x=1726416540; 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=jjuOdM76RGp3MQYm8FNYFfW8Ad8/c/uFJG5zKSZKRs4=; b=UcrojUoR47QsbVddSVJXoRJrwtGmBnePKrStMsH5hZI8pzuMaxIoZhPO8V3Y8fI5TT YqFbLq716nPBXKUdU7UZRj8zOEJhLMNA8AzO8bDNtd4nbt0dQL+b/XPAUky4rvcC/DJ+ 8oMzgdGQC2bLGf94bXRiZr21yNk3WQdQsgmAw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725811740; x=1726416540; 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=jjuOdM76RGp3MQYm8FNYFfW8Ad8/c/uFJG5zKSZKRs4=; b=rsu2VD+kCWOe19BNgzTCqVH6bF2u8B3Yu/0mb6sA6veU/t1zQ1buOjLrj66AlMa4W6 2vjEbARm+OdLxJzfEBAaqEDedzOto1nJ3FGa7vWARVFRHBv+oqtW1iSgXnxe1Nlww+MI rYk33jcPw8TnfkE19yFIm8z16/aTDt90RgrtFZasNttg9BCyy5SQVU2XcZQvIMAKM5RH fOfyF1RYurL3p5wHkl4L8mWTrROz6YMxVEdUMlqS06cl3Koq7toTy5k1F8NB7hwj2VfL sEz8tTjCPQiu4x8OoD7Ao3rdx+dUs5ZqAh9lv1iWHNiNofMI3d9DCg+6WkrHQc31Yzrj 4D4A== X-Forwarded-Encrypted: i=1; AJvYcCXl84cWXU3mB60wjSRPf+V7DyQUR9vdufVttk4roXXc92E1iey95NYYTsNAuzo8XEHSETlWxtPQNTFZMwA=@vger.kernel.org X-Gm-Message-State: AOJu0Yy0ZliACI1QAnIqgDS0wdMAuEbxr8O7EPfaQgb1PNcQadSBLhGi atufo/p3kKL8AzeJa+GngKfy/isTVPcU3SkI1ymtz0TTFvZH6/iMxZwa4xwN8S8= X-Google-Smtp-Source: AGHT+IFc2+MJ78cW07NMZFUPaJZvV2Tyokj10k8rhRH/L30+78xT+3ctMyGfzd0g5mcjr2mR8Wy2DQ== X-Received: by 2002:a17:903:1ca:b0:205:80e7:dcc5 with SMTP id d9443c01a7336-206f0612c3fmr130641445ad.44.1725811740001; Sun, 08 Sep 2024 09:09:00 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20710f3179fsm21412535ad.258.2024.09.08.09.08.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Sep 2024 09:08:59 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, kuba@kernel.org, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, Joe Damato , Donald Hunter , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jesper Dangaard Brouer , Xuan Zhuo , linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v2 6/9] netdev-genl: Support setting per-NAPI config values Date: Sun, 8 Sep 2024 16:06:40 +0000 Message-Id: <20240908160702.56618-7-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240908160702.56618-1-jdamato@fastly.com> References: <20240908160702.56618-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 | 12 ++++++ include/uapi/linux/netdev.h | 1 + net/core/netdev-genl-gen.c | 15 +++++++ net/core/netdev-genl-gen.h | 1 + net/core/netdev-genl.c | 52 +++++++++++++++++++++++++ tools/include/uapi/linux/netdev.h | 1 + 6 files changed, 82 insertions(+) diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlin= k/specs/netdev.yaml index 3034c480d0b4..7c0c25e5b808 100644 --- a/Documentation/netlink/specs/netdev.yaml +++ b/Documentation/netlink/specs/netdev.yaml @@ -642,6 +642,18 @@ operations: - rx-bytes - tx-packets - tx-bytes + - + name: napi-set + doc: Set configurable NAPI instance settings. + attribute-set: napi + flags: [ admin-perm ] + do: + request: + attributes: + - ifindex + - index + - defer-hard-irqs + - gro-flush-timeout =20 mcast-groups: list: diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h index fd02b5b3b081..4e6941b45f3e 100644 --- a/include/uapi/linux/netdev.h +++ b/include/uapi/linux/netdev.h @@ -189,6 +189,7 @@ enum { NETDEV_CMD_QUEUE_GET, NETDEV_CMD_NAPI_GET, NETDEV_CMD_QSTATS_GET, + 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 8350a0afa9ec..209c56cf08f1 100644 --- a/net/core/netdev-genl-gen.c +++ b/net/core/netdev-genl-gen.c @@ -74,6 +74,14 @@ static const struct nla_policy netdev_qstats_get_nl_poli= cy[NETDEV_A_QSTATS_SCOPE [NETDEV_A_QSTATS_SCOPE] =3D NLA_POLICY_MASK(NLA_UINT, 0x1), }; =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_IFINDEX] =3D { .type =3D NLA_U32, }, + [NETDEV_A_NAPI_INDEX] =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 { { @@ -151,6 +159,13 @@ static const struct genl_split_ops netdev_nl_ops[] =3D= { .maxattr =3D NETDEV_A_QSTATS_SCOPE, .flags =3D GENL_CMD_CAP_DUMP, }, + { + .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 4db40fd5b4a9..b70cb0f20acb 100644 --- a/net/core/netdev-genl-gen.h +++ b/net/core/netdev-genl-gen.h @@ -28,6 +28,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); =20 diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c index 68ec8265567d..fca1670706cc 100644 --- a/net/core/netdev-genl.c +++ b/net/core/netdev-genl.c @@ -303,6 +303,58 @@ 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_storage *napi_storage, struct genl_i= nfo *info) +{ + u64 gro_flush_timeout =3D 0; + int defer =3D 0; + + if (info->attrs[NETDEV_A_NAPI_DEFER_HARD_IRQS]) { + defer =3D nla_get_s32(info->attrs[NETDEV_A_NAPI_DEFER_HARD_IRQS]); + WRITE_ONCE(napi_storage->defer_hard_irqs, 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]); + WRITE_ONCE(napi_storage->gro_flush_timeout, gro_flush_timeout); + } + + return 0; +} + +int netdev_nl_napi_set_doit(struct sk_buff *skb, struct genl_info *info) +{ + struct napi_storage *napi_storage; + struct net_device *netdev; + u32 ifindex; + u32 index; + int err; + + if (GENL_REQ_ATTR_CHECK(info, NETDEV_A_NAPI_IFINDEX)) + return -EINVAL; + + if (GENL_REQ_ATTR_CHECK(info, NETDEV_A_NAPI_INDEX)) + return -EINVAL; + + ifindex =3D nla_get_u32(info->attrs[NETDEV_A_NAPI_IFINDEX]); + index =3D nla_get_u32(info->attrs[NETDEV_A_NAPI_INDEX]); + + rtnl_lock(); + + netdev =3D __dev_get_by_index(genl_info_net(info), ifindex); + if (netdev) { + napi_storage =3D &netdev->napi_storage[index]; + err =3D netdev_nl_napi_set_config(napi_storage, info); + } else { + NL_SET_BAD_ATTR(info->extack, info->attrs[NETDEV_A_NAPI_IFINDEX]); + err =3D -ENODEV; + } + + 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 b088a34e9254..4c5bfbc85504 100644 --- a/tools/include/uapi/linux/netdev.h +++ b/tools/include/uapi/linux/netdev.h @@ -188,6 +188,7 @@ enum { NETDEV_CMD_QUEUE_GET, NETDEV_CMD_NAPI_GET, NETDEV_CMD_QSTATS_GET, + NETDEV_CMD_NAPI_SET, =20 __NETDEV_CMD_MAX, NETDEV_CMD_MAX =3D (__NETDEV_CMD_MAX - 1) --=20 2.25.1 From nobody Sat Nov 30 16:36:40 2024 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.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 6AA2317B402 for ; Sun, 8 Sep 2024 16:09:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811743; cv=none; b=hAoHywEimvJXGiDPPgPKZ4Nm7NVbPhpELhm/4ip35E3zsvn9hqH7tdIRYKLU/BuTR97ZtENQipzSW7h2t40xhYHKsjVKU9CFHE7jXdEpNpZl7OvgVGaKLkRkTO/hFya9XmaVAadZnPfyBHGRyRJ3hy7NR488YZf/oXEv6hPidGo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811743; c=relaxed/simple; bh=sHhlasbwVibNkDUBcgYAgRqAvPf6JXUYUczB3y1i5Qk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ObhCKgpFzgFHAv14EOOHLmWNHW4/0yGXOizRxwUvccuI6YUlOKRJtcWxSm6xQd0Vie587VWqHVobXix0t24XuSe796j5l5my0TMJghoc84stMKOSf+QgiVgOk6b75Cy9jIkePmVT+Mn88wNH8MMAOu+QFfxJ7bywaRQitwKGFkk= 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=UdSsw1xu; arc=none smtp.client-ip=209.85.210.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="UdSsw1xu" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-717911ef035so2727027b3a.3 for ; Sun, 08 Sep 2024 09:09:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1725811742; x=1726416542; 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=LBjxY6TwnFpEzcM0rCGHkoag3b+h+m2LlFoiqk6FpQ4=; b=UdSsw1xu2zxAdxGDVzh0RGT27Zwr+T4mt/eleZqCVq6rQKxU45nvv3l0X07q9uKsHu 72EpCTWEs5FksIy4sBEWbcUuJseZPLgAoD3vaR6sQbbITt1/G86ABBhWcFcq4z9oboV6 xU/cOGIkk+tCLm3WOQuZeqWQd3Y0qchQli5XA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725811742; x=1726416542; 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=LBjxY6TwnFpEzcM0rCGHkoag3b+h+m2LlFoiqk6FpQ4=; b=oapvPhIhdQEj0fIu/7PLo9dy5e2ObIxpnit2dshorueBqcKbvn+/wae26iB+T8C6sv Lxy0ekEMi8UhUAyfkQFBvb/psGJiYUp0JQOokatpwHHGZx8OUVGnvAMrjTWVI8MKGWBp UqmdEryFHzpP7c9GGGRke9v9SXNG7tnJZZ75WEFPgInmjaX4vG+I/pWuFeGw3KdP3Do7 VdrV76EY2/N2mmRqBo+ZtFbqWuNYbXiNCGxigBSVjpZk8b1+jReuQOUJw8bagClLDuzq xPHdBqFXr7MC6BKGiEvdvyygHepS9Xqprwx3D7W+FfRFwIZYCvea4oVAqfPC4TukISRK FNqA== X-Forwarded-Encrypted: i=1; AJvYcCUTcwDqCTEl3cXYVT6S/+ecLo0cw5enqFTTm/aYiq0mMXn8bopKYKDwS/3EHud+ryX6LiV2FE2QdSCcppw=@vger.kernel.org X-Gm-Message-State: AOJu0YxTvABabqVlS62uv5ZbS4gL+Q0iEyVW6th11E95BP+XSYivR9MT cNDB/W/8bEm1PQoh3lWmjHiXFWa4CUGY1NHYdwfQt9P5z1bDebxrchPiRz/f1fE= X-Google-Smtp-Source: AGHT+IHqM6CtrXmsR793CAG4W9wDsYIOiyXLouRIaKFNMJRjMOv0JN+CqWwdUpDW1v2w42mf6KOc6g== X-Received: by 2002:a05:6a21:6b0c:b0:1cf:38b0:57ff with SMTP id adf61e73a8af0-1cf38b059c3mr1076308637.48.1725811741803; Sun, 08 Sep 2024 09:09:01 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20710f3179fsm21412535ad.258.2024.09.08.09.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Sep 2024 09:09:01 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, kuba@kernel.org, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, Joe Damato , Michael Chan , "David S. Miller" , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v2 7/9] bnxt: Add support for napi storage Date: Sun, 8 Sep 2024 16:06:41 +0000 Message-Id: <20240908160702.56618-8-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240908160702.56618-1-jdamato@fastly.com> References: <20240908160702.56618-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_storage to assign per-NAPI storage 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 c9248ed9330c..6f231a43775b 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_storage(bp->dev, &bnapi->napi, poll_fn, + NAPI_POLL_WEIGHT, bnapi->index); } if (BNXT_CHIP_TYPE_NITRO_A0(bp)) { bnapi =3D bp->bnapi[cp_nr_rings]; --=20 2.25.1 From nobody Sat Nov 30 16:36:40 2024 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3644417BB17 for ; Sun, 8 Sep 2024 16:09:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811745; cv=none; b=STZute3zUMhnKJ+GxbqxgMkrTdqgegr97M9QMnXRtQ3Y6lUHxqP0ladCkOHA6J1VKNssPB4r3ggpBp/caMbHFDxti7Xqz2/WFG583mrIdpXiWOhROhAg9QM9keCJBC2YTy1G1uGEiU8o8Er6tajLSd3JPvaIpzzQRA8zWh0A3sg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811745; c=relaxed/simple; bh=4HEYXckzb30ldYDuv6OJ1NZpctFxN6G/pxcTLPkqpU4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=I8rPdUbOeyMjjR261GujM1GHrt1mY9PJEc69FFQ1RZhno5d6nFIpmTb8qFw3hv53aw3pNNwKZ5QqqxMjLOyWlXtb6qm6Sb3gPailK8081FfbxPIbVJnHn9L2Yly5vpefcvZHtJdVo65XqTNv5E4WR5cuFXe+u7IdszRwEv9s05s= 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=W0eg9OPM; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="W0eg9OPM" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1fee6435a34so30451165ad.0 for ; Sun, 08 Sep 2024 09:09:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1725811743; x=1726416543; 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=gPqS0EtM6+tGmEgcYaXfQxu3vZbAasBMjVTJ7sHaKBI=; b=W0eg9OPMngSp6ybIFB5oq4IB6cv9G+mpQ0SAqvEzmC9MkxSjbxC5Xw3zXG67zs0jFk KbgUglMGRj2AQbmtWReAVdvJyCN3B5iCsNGaivaxZnNzyB528qdctatcSNonK+IYCiNP 6GKLdo12yk/oYHkC3d6yWJZf7laXTUU4fKElM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725811743; x=1726416543; 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=gPqS0EtM6+tGmEgcYaXfQxu3vZbAasBMjVTJ7sHaKBI=; b=HR1bYzOnpZo8TEauLDE85aICXGyBhq7MV2k4s073FCF2DhDqoSYf2PuS5LGgVac4w6 TDQufCNbaJHhc8H1pphNhYgZXRVBwJMglDQp0cv5PrBnOtm1Xae5H0UO85VfUsePlVPq sJA/It8Rd6a86MMD/FORl/YOjkhUfd2iiQd9+3bmUaCn5NAC2a3cv7hjRKlJTouy9g0/ +AnFnxp3EJRuhvD56kEBo2RkTHtk8eoMOMukSvMX/of8L3WSqNpUqwzFfU6ctPz1S+XN 5TyRpoS08Sd6mUsUkxR8D0nnDYbilHiOqBKZilukLXrqC/4HXvkk5Ohaq6AkgyKdTaIs WfMQ== X-Forwarded-Encrypted: i=1; AJvYcCUtnZwLHECcycsjhKi850uBPTtd5GwHM6/aJB5OZm2lwWJp2w+9Gsv+jpZfrIqUIp1PWuWcmAZwpFBHYTw=@vger.kernel.org X-Gm-Message-State: AOJu0YwST+9JFisII/c5wTudakH9sYboBpavTKyYCUNjWlCRsM5i4hUo 94lsWori/ukLxR7z4NqpLlambGhLgDEN9dvNOqNSZUwJqQoARN7s48ki3SyYqbU= X-Google-Smtp-Source: AGHT+IGK4rR7SL/3525ecrLJrxwc+z1VKN6ygfWdTXmVhAnwErckliz5jxK7Lr6ScN1xS4HxwJmdDA== X-Received: by 2002:a17:902:f64e:b0:205:9220:aa37 with SMTP id d9443c01a7336-206f051e59emr78713005ad.22.1725811743466; Sun, 08 Sep 2024 09:09:03 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20710f3179fsm21412535ad.258.2024.09.08.09.09.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Sep 2024 09:09:03 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, kuba@kernel.org, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, Joe Damato , Saeed Mahameed , Tariq Toukan , Leon Romanovsky , "David S. Miller" , Eric Dumazet , 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 v2 8/9] mlx5: Add support for napi storage Date: Sun, 8 Sep 2024 16:06:42 +0000 Message-Id: <20240908160702.56618-9-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240908160702.56618-1-jdamato@fastly.com> References: <20240908160702.56618-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_storage to assign per-NAPI storage 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 47e7a80d221b..2b718ee61140 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -2696,7 +2696,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_storage(netdev, &c->napi, mlx5e_napi_poll, NAPI_POLL_WEIGH= T, ix); netif_napi_set_irq(&c->napi, irq); =20 err =3D mlx5e_open_queues(c, params, cparam); --=20 2.25.1 From nobody Sat Nov 30 16:36:40 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 B6BE817C233 for ; Sun, 8 Sep 2024 16:09:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811747; cv=none; b=F+dTITZr5A9TQnY/XRvzekNVeHP7Bi4DHAeXKewfjm6OajnMd5f4PumrzRA4ZGurYnd3IrDQP7uB+rqpyF7I99CBLqKhPpDyAkc+Bgqat7gTzrsihQMqEIM/+sZjMAIEfHQaWtoq9RS8KIoFHGCrh3NMF1FjsBe75nFkl1BaYPw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811747; c=relaxed/simple; bh=HIV7bkoPSQ3rxlaFpK7J86ATOFDCNnMGhMFf+TgF5jE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=W4JyxgvzGj8kSsnY3WsMmZOxL5Y+Y2m21+2gumdkWv10pFq/QH5lI0dH+27MDUmNWRI1RmJlqlnPeHLbh0DJjR8b6LMMK05G3kfN8TPNS5uNS6EFGnh7QdYAQZ4BrA5OZtOLFa7YyeZjHUbbp8ntV8SnnxtonspLRun2qBbQI9w= 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=HWjZbpdC; 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="HWjZbpdC" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-206e614953aso26464895ad.1 for ; Sun, 08 Sep 2024 09:09:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1725811745; x=1726416545; 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=LGhj6cfvUKa56g6O8vcdWhred6v1jtnORdUuxs2iulk=; b=HWjZbpdC7/EXlidULkCI1N46DMduufGoO6rTjl3UCirvdYy7vu0090SK7CU5KXtYZt LULa/5pt6JfNsFH3Fvp2r+q60+X4ywZI50F4rPBhMuAUM5/X8mL+dP3NXOThjnejSvsX CIT5tqU7SGwlOqZPOzZsoBnGR9xT1bcQ5o8YU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725811745; x=1726416545; 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=LGhj6cfvUKa56g6O8vcdWhred6v1jtnORdUuxs2iulk=; b=T//r/jq21FgAmw14eMolPKYdXZ3uZ3yyIaUsyJSPrd+rMrhtBfOEy5/yq2d0QtBwVs 71bjeFfAezN/2XqeuVSwNRHXlG4twHJWLMjeuwTZylkGXnvX6da04w0Put50eZZdUWcX AjT80lYoncnGDE0n30IMhTP5JHMYGakr5yH3YWTYPLNVrmJIHK+HgYy4CBc1sdzWn1zG 2PDLUll3C6HCCt8qzuDASBVBX8uI2vgz22jTA1YEmV+CfndNxKYCQdwyYUMPoNEtnLW5 JkoHGLIFhMjriQbOhdxYKMGhF1glIcToWQrnhZ/zJPmiBRP66LVBqc1PRcmCeLpyn2pt S1pw== X-Forwarded-Encrypted: i=1; AJvYcCUXBIB7Y7OasAMNUfU99WUwNVVLXLMbTOC1f06Kb9Fb1S2sGA2//bqoQ8hGMgRrpgELLJmpv75MerLekDY=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/zvkWWLwyOseLppXZx1sMal3teaoTpaCFq1O0ow6CHbt1veNb BDWYANokd8y0cdi4xZdt6eVcqQkxUGD9KXUrJA2WPHIXX6zjQ2qr7svxnGcJPCY= X-Google-Smtp-Source: AGHT+IFQURgAP0IwRMpYNE1DAaAqoQ3640I7A6bdcacvbt4VU16dYwn8Pnh0y3O4wA8pyPK8qtXIIA== X-Received: by 2002:a17:902:c94f:b0:207:c38:9fd7 with SMTP id d9443c01a7336-2070c38a075mr77160875ad.22.1725811745045; Sun, 08 Sep 2024 09:09:05 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20710f3179fsm21412535ad.258.2024.09.08.09.09.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Sep 2024 09:09:04 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, kuba@kernel.org, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, Joe Damato , Tariq Toukan , "David S. Miller" , Eric Dumazet , 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 v2 9/9] mlx4: Add support for napi storage to RX CQs Date: Sun, 8 Sep 2024 16:06:43 +0000 Message-Id: <20240908160702.56618-10-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240908160702.56618-1-jdamato@fastly.com> References: <20240908160702.56618-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_storage to assign per-NAPI storage when initializing RX CQ NAPIs. Presently, struct napi_storage 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..74f4d8b63ffb 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_storage(cq->dev, &cq->napi, mlx4_en_poll_rx_cq, + NAPI_POLL_WEIGHT, 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