From patchwork Sun Sep 8 16:06:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13795556 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 110FF175D3E for ; Sun, 8 Sep 2024 16:08:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811718; cv=none; b=jPDIxA8Oy70igx4cqGbbPPBTnV0xNnWX2yQi4Vl8q4y4ILgK9nlIvuheDhDWFJufkQt1Gvn1aaAbaIOUKBi7gUC5v2/BYiuWP8ibkgsPf5udbQ80WrorFNA3xI391iJCULyxgIFsKglZpHgTHS044BneDo4+BAc6X1w2TKl+EhQ= 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.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="dKuGZRhq" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-718d985b6bbso1889340b3a.2 for ; Sun, 08 Sep 2024 09:08:36 -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=WFYyRLykcHjUh70ybNRfvWzz8liLnj8aH/lyTl1MSM+rRQhbtGvGCUtLJP7+YKiYym qzbwnfxBcu04vZdadUu4mgtK26kAI+oUTpm7wpef+F2CmGXANlYD18Vg0Telfb381n/1 ST38ij9QMkm6inTpr+jSj7wNLjS3HC6OfPcx++8O8JztVZ/8tPCvWHMAwfJdQPokPW0e qzVKa5iWmG6MHo7Rgysl1yKT0oCpYoYJT7R4N39VdESY6pANUfo6KOjBvj8FdxmhY4BG fKimzSSjokH2KAGyXIq1It/KHfZlXtFiNFvURQJLrKyKXRVsiIBQb3Bi0iJggYuTOwxn WaQw== X-Gm-Message-State: AOJu0YzGYOaypSskj/zBV/0ZDG6IBzxR3D51Orc+1remwsPpzDHRmJDu hqBUx0royaMvS7aivL41FsQeciNk0v2sE6kOnEjxhheq9UjFD9zq7mD0Inv8PD3obUNRpSRIIJ/ FVUzTzVDy8A80EnGvRRIL1xj4mIARDygISVCA9JOZ3vvk94J39NZHSdP8f0ONl90CwNnRzKkv6d H52iNRjOKk8Nu1iVIPWK4qlv7oAoUP2Jn8dYymFuKF 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: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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/Documentation/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 - struct_netdev_queue* ingress_queue read_mostly - 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 unsigned_char broadcast[32] struct_cpu_rmap* rx_cpu_rmap 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 +/* + * 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; }; 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); char name[IFNAMSIZ]; @@ -2648,6 +2662,24 @@ netif_napi_add_tx_weight(struct net_device *dev, netif_napi_add_weight(dev, napi, poll, weight); } +/** + * 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 = index; + napi->napi_storage = &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 = NULL; + napi->index = -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 |= 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); @@ -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; BUG_ON(strlen(name) >= sizeof(dev->name)); @@ -11067,6 +11072,9 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, return NULL; } + WARN_ON_ONCE(txqs != rxqs); + maxqs = max(txqs, rxqs); + dev = 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_priv, const char *name, if (!dev->ethtool) goto free_all; + napi_storage_sz = array_size(maxqs, sizeof(*dev->napi_storage)); + dev->napi_storage = kvzalloc(napi_storage_sz, GFP_KERNEL_ACCOUNT); + if (!dev->napi_storage) + goto free_all; + strscpy(dev->name, name); dev->name_assign_type = name_assign_type; dev->group = 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); + 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); } /* From patchwork Sun Sep 8 16:06:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13795557 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4CBDD176255 for ; Sun, 8 Sep 2024 16:08:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811721; cv=none; b=isy5oO7LV56Zo9qMczzZoEytMqyr1ywslYePMQH1yaW56MlrwBQlCud6VKKyFcWkAlhT4fPe8xi3ITCOnVKW5462Hv5TIJT7YmQ0YklaajM4KcbRO55lhoARjXJzJRrmMlLbDW8GO5lqgoiimjEpDb2J4/mjD5LyJfJ8if858fM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811721; c=relaxed/simple; bh=BNKvxVYTuL++N+ZYm9W5qpapoauvjei5NqpfkRAMLoI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tu8DjdkeGS9qKtsO/IsQIeteI58o1YS1uWkqlxPX+a7IgLnNxn0gbQ6rFmUADYe1KxdTHY1Jbvf2VIltNVfTRKQc2OlJIfd7DgqQqcv3sP4+Ghsx55qvQg4r9GHi8MQM51e9tlaU525ImgMUMQrvHKUC6jB1pxUKkZG3HzWxYbw= 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.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="HPjlKk2Z" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-718da0821cbso1697736b3a.0 for ; Sun, 08 Sep 2024 09:08:40 -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=Wr3SxFioiN5a1Y1ka/I9GGoTYHopeQQdLr6Qvec3OOLr+uZYC1LfCvcIBvuKv1vewf ukYBhS4vJpA2kcjZAfyMe92nXBNtuOMvhGsED94KjPAy0UfTJEPHKugFB3Et4ybHLN/6 XDJo2LKj8J7K99i7jrVZJ0NqFaj/oAPqhdHd5UwkSUI0ZB0ZNrj08riUMZCZLj4cyJwd n6is1REJ90c9zbomHX5cQZsJFkKdPo3Mm3lYgB2dSih+br6r/aXNwHAZF9wsQA5rWXCu 3sj2rwzJRUTP52sLvUJk3Itai3Jg1S9ld8YTgaacTmnAl6KJ107suYt25j5fjhhl1IMy Tlkg== X-Gm-Message-State: AOJu0YwiGgnnjCkmL0TuhoLBcvb0Z6wjSKoahBAmOHjTUmK7/tGj/qA1 1WP1DNKTjS1a2ysKg0tzSOsLuCzkPOupFrZmp74eXVE0SSGrYHt56KMy8kIrWGHeTFMpK2rUSnr BBWn+7yvsyJ/uVO5n0/cM6+2QHtlCIx68YoE6scax8DIptosv5g4lhGVMwrhRtdsdc1OPV0xGfC mF2185PwMKIHWK2KUw+y4poXlaq1j41QfG1p/Jvj2Q 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: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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/netlink/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 normal 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, __NETDEV_A_NAPI_MAX, NETDEV_A_NAPI_MAX = (__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 napi_struct *napi, if (napi->irq >= 0 && nla_put_u32(rsp, NETDEV_A_NAPI_IRQ, napi->irq)) goto nla_put_failure; + if (napi->index >= 0 && nla_put_u32(rsp, NETDEV_A_NAPI_INDEX, napi->index)) + goto nla_put_failure; + if (napi->thread) { pid = task_pid_nr(napi->thread); if (nla_put_u32(rsp, NETDEV_A_NAPI_PID, pid)) From patchwork Sun Sep 8 16:06:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13795558 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D15F174ECD for ; Sun, 8 Sep 2024 16:08:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811726; cv=none; b=P768yGZYZFRSzBz6Gedbtdrl7SCLjzaqjhG8M4r/i5ZVm6/JjD4IUej3/eq9XX7yTrHVlfDBsmuETHPS84KYId86iqcEkUMOTbvbKvsGXvNts2yIpaszjAkOX1AsdqGrjAZX5orHT8HAgyT+LczMvE3cXpKNMNN/+1EJ7Wou3S8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811726; c=relaxed/simple; bh=qZ0T8CKExRvD5T2B1Yh7TajT/3Et+GX0HYMbFOGpRZQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VAkoaowIXo7aZtUMEbtgxCFQkQYICW5C60sNUpLUu4S5oGszUFW9tevA1Csx97LT9FwI2N/zyOr6anQUjlMUepf7UwI/PGKNPNLaGTcdBVKyTs+Y4BGnF81XUrl2ZKIYuggn3wnj+rIBWeldkq0NVyS6R5fztxjghNZj5vrShls= 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.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="X35UlQLr" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2055136b612so41476365ad.0 for ; Sun, 08 Sep 2024 09:08:44 -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=sEq4vmVflnMJdw4NhkWiMEMiFnpIw2hPBYCHc76dRJH/wKLXi77rtI3sUgB5wnMv95 tk9y1L0+N1rj8R64VDGvP5246ug6wtJwB3PeIWC13txhchT0h/IuxJivGoFMFvi9RUag RZLujo9Yt52cr/AOASZ+u+uFd0vatlQ41BAxkchTNVM3Gpi1DxmiE57prnMr2pQBtiEa YAnMwrFrFE8h89e0XnPWwk3vpyYi61HEuCRDKKUFuJSEAVIoCgyE7d7K3l58ceHhSWQw YYMcOBq3rK3TKNC1JCrrKLXS4SjAIfI0RKOIiGFIHlcMn1EcdhNiaYgg1kpFaI05pbDC cHjg== X-Gm-Message-State: AOJu0Yx2UGRPQYqMcWNEFc+iomsJGrd8wcv+s5HfPnxxDIBTPAcnvNZn LFFNJScZdh106Kfa2DyozV+/b3Z2zxyVmTN/rjJD+MWPMHBNnQC7P1pfUJk4x9ybxBSN3dvFo9U 9JewNNIbA4uZ6Zkl69GwJ2U1RaPOHgkbT2G6ukZz4eyKmFGuVIeV9T3vir/3OLAJAIgWuRyGmNt 8skm+ksX4t5U0OxUDpycKpY70NHv+XUyKDt5VtgOrr 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: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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/Documentation/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 { /** @irq_moder: dim parameters used if IS_ENABLED(CONFIG_DIMLIB). */ struct dim_irq_moder *irq_moder; + u32 napi_defer_hard_irqs; 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 work_done) if (work_done) { if (n->gro_bitmask) timeout = READ_ONCE(n->dev->gro_flush_timeout); - n->defer_hard_irqs_count = READ_ONCE(n->dev->napi_defer_hard_irqs); + n->defer_hard_irqs_count = 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 = bpf_net_ctx_set(&__bpf_net_ctx); if (flags & NAPI_F_PREFER_BUSY_POLL) { - napi->defer_hard_irqs_count = READ_ONCE(napi->dev->napi_defer_hard_irqs); + napi->defer_hard_irqs_count = napi_get_defer_hard_irqs(napi); timeout = 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_PINNED); @@ -6648,6 +6648,7 @@ void netif_napi_add_weight(struct net_device *dev, struct napi_struct *napi, INIT_HLIST_NODE(&napi->napi_hash_node); hrtimer_init(&napi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED); napi->timer.function = napi_watchdog; + napi_set_defer_hard_irqs(napi, READ_ONCE(dev->napi_defer_hard_irqs)); init_gro_hash(napi); napi->skb = NULL; INIT_LIST_HEAD(&napi->rx_list); @@ -11033,7 +11034,7 @@ void netdev_sw_irq_coalesce_default_on(struct net_device *dev) if (!IS_ENABLED(CONFIG_PREEMPT_RT)) { dev->gro_flush_timeout = 20000; - dev->napi_defer_hard_irqs = 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_handler); @@ -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); } /* 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); } +/** + * 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 defer) +{ + 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 netdev + * @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); #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_device *dev, unsigned long val if (val > S32_MAX) return -ERANGE; - WRITE_ONCE(dev->napi_defer_hard_irqs, val); + netdev_set_defer_hard_irqs(dev, (u32)val); return 0; } From patchwork Sun Sep 8 16:06:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13795559 X-Patchwork-Delegate: kuba@kernel.org 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 91438178CF2 for ; Sun, 8 Sep 2024 16:08:48 +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=1725811729; cv=none; b=nLb7/XbOReUvz9EMDCA9b9FV+ugNLTI6KQs8GkERm39f+6URSIXOt72UVTkdiy7KYCI7gPzKKg22GV0louzezR12aG5owKW712OCfyXMkQGD7f7w+bd97/6iVNSd/YPE2Hkvco6Dy2DKi8A0yEqkTkst6EC0URflUiz499CipYY= 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.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="TvY1osHd" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2057835395aso31924865ad.3 for ; Sun, 08 Sep 2024 09:08:48 -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=Hle42oUQlmtC6yC1KtkEotMzSPZhxo8zE8Q5i+3o4HUrpOBw/iAbSB5FkWKoJaTsKC BYo/Pm3pxxNkomOqKKJcktYucM9pciV+nvdExlP2FzzZJ6beAZxvOkPATGr5scTSkhm5 KHlCfJ7BJVwZfPa91eOkLTd2aB8tYKwNSD3M14ZFOwv3+rXLS5VeMYTlhlXSkHZMYj4L kLp06GHd/BEcrHviLE4Hc8O3j+f1WqWdMicSpfS+sspI4F397BaPaI1/0oHzOdX2XaVn 2rkhj9wFiCFsgYNEqXrAg/HgDEjxcINVcAWnENr0tWSAQEQS9daSCxJQncxzQJfLAkCt iYzA== X-Gm-Message-State: AOJu0Yw4pfVTJqF0nHBM3e+Fx8r46xCOKQcFcQMTuT3o5ukrivlF1huA W8qv8yKiFVJrdczW85JlcNhWpC1kbARktKZubvNroSs09KmaMtlCkLHVIQ/I/HdkSYvZgJAvWQN 0AEdS6LJbdECc54dv8egHewBeDPTwnWbjEImuw2Xys2sNptaBHLCHIvLTkG3ADzhGYXNhKUxmYj f6SXYUPf71GJSIPLJo/nwihfJJBAOxIF+IRnQG+eZd 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: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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/netlink/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, __NETDEV_A_NAPI_MAX, NETDEV_A_NAPI_MAX = (__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; @@ -191,6 +192,10 @@ netdev_nl_napi_fill_one(struct sk_buff *rsp, struct napi_struct *napi, goto nla_put_failure; } + napi_defer_hard_irqs = 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); return 0; diff --git a/tools/include/uapi/linux/netdev.h b/tools/include/uapi/linux/netdev.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, __NETDEV_A_NAPI_MAX, NETDEV_A_NAPI_MAX = (__NETDEV_A_NAPI_MAX - 1) From patchwork Sun Sep 8 16:06:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13795560 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09679175D48 for ; Sun, 8 Sep 2024 16:08:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811737; cv=none; b=dte3M2sHuo3v3CslyBcsk5i2yVAvU10E4Qft7cIcP82jGzZKkqGw11fd4KPTgfI4UhEB10TCb62fHUZRwkZb4jqLAsttJnqC+T4Y62ae/3ZriYz65jS0e8JHRCYeXNSs29/2dKvKPtg1E9uE0lHynXaN2ACtoxtmjNIk+fb4czU= 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.215.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="x/CvXFU2" Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-6c5bcb8e8edso2774774a12.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=NhbsQP2ObbDtk2iNV/ihK3wRR3ehJT6gTeWRpqKsl/TzexRff5pCGCBMhWNiRB93Cl 29N51NaCo3Y0vw+Q9eGYmhGd9o87WiqCeToZHAYuM+Ohp9Xkox3uWSpXYswe+xNXecrv 5+6bsdSpYpfS8jQSmBRKHBBaOdIDf94F4MwSxfOx+TdnzpwKKjV9fArUcm0WHDkLPmi9 +ONlWjuacYGuMrCk3IcEJpFvH0OwlrNbWt8yDpQH2cqxMC4qaujUgCbF+dvzEUKEXZm/ Mzyu4X/ENtKK0gSyHQXrWQQ3U0JHdxhtJj8jcxBpvDPF+JtQCDzRuWt7gQGOAHXHEUqR l2zQ== X-Gm-Message-State: AOJu0YzrTgNVId40wECVOm2kRKVR/5v0rNJhbgX6YdKtHzXAWq9ly3wU Vyt0ltcGNWZ9BpPFLLDqmHi0rGS3c6GaPRJk4VQy/S2QmqzsgNujoHEnOZp+j92+AWVPLmdMc/C IQ+Z4Xl6fvWT9zA2WDXd1J0PnfKt0lA1O+A64X1MNf9MsE3CVzzOr52N/+4mBIG0z6bN6Qy8O0k qra4kRXNo5Mwi9CEAXqzbhroySvQ0H0GN2sxhp9WQZ 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: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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/netlink/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/Documentation/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 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 { /** @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; 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, __NETDEV_A_NAPI_MAX, NETDEV_A_NAPI_MAX = (__NETDEV_A_NAPI_MAX - 1) diff --git a/net/core/dev.c b/net/core/dev.c index 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) if (work_done) { if (n->gro_bitmask) - timeout = READ_ONCE(n->dev->gro_flush_timeout); + timeout = napi_get_gro_flush_timeout(n); n->defer_hard_irqs_count = napi_get_defer_hard_irqs(n); } if (n->defer_hard_irqs_count > 0) { n->defer_hard_irqs_count--; - timeout = READ_ONCE(n->dev->gro_flush_timeout); + timeout = napi_get_gro_flush_timeout(n); if (timeout) ret = false; } @@ -6367,7 +6367,7 @@ static void busy_poll_stop(struct napi_struct *napi, void *have_poll_lock, if (flags & NAPI_F_PREFER_BUSY_POLL) { napi->defer_hard_irqs_count = napi_get_defer_hard_irqs(napi); - timeout = READ_ONCE(napi->dev->gro_flush_timeout); + timeout = napi_get_gro_flush_timeout(napi); if (napi->defer_hard_irqs_count && timeout) { hrtimer_start(&napi->timer, ns_to_ktime(timeout), HRTIMER_MODE_REL_PINNED); skip_schedule = true; @@ -6649,6 +6649,7 @@ void netif_napi_add_weight(struct net_device *dev, struct napi_struct *napi, hrtimer_init(&napi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED); napi->timer.function = 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 = NULL; INIT_LIST_HEAD(&napi->rx_list); @@ -11033,7 +11034,7 @@ void netdev_sw_irq_coalesce_default_on(struct net_device *dev) WARN_ON(dev->reg_state == NETREG_REGISTERED); if (!IS_ENABLED(CONFIG_PREEMPT_RT)) { - dev->gro_flush_timeout = 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, ifindex); 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_handler); @@ -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); } /* 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 net_device *netdev, napi_set_defer_hard_irqs(napi, defer); } +/** + * 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) +{ + 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_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); #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); 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; } 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 napi_struct *napi, const struct genl_info *info) { int napi_defer_hard_irqs; + unsigned long gro_flush_timeout; void *hdr; pid_t pid; @@ -196,6 +197,10 @@ netdev_nl_napi_fill_one(struct sk_buff *rsp, struct napi_struct *napi, if (nla_put_s32(rsp, NETDEV_A_NAPI_DEFER_HARD_IRQS, napi_defer_hard_irqs)) goto nla_put_failure; + gro_flush_timeout = napi_get_gro_flush_timeout(napi); + if (nla_put_uint(rsp, NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT, gro_flush_timeout)) + goto nla_put_failure; + genlmsg_end(rsp, hdr); return 0; diff --git a/tools/include/uapi/linux/netdev.h b/tools/include/uapi/linux/netdev.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, __NETDEV_A_NAPI_MAX, NETDEV_A_NAPI_MAX = (__NETDEV_A_NAPI_MAX - 1) From patchwork Sun Sep 8 16:06:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13795561 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACF0C17B428 for ; Sun, 8 Sep 2024 16:09:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811743; cv=none; b=QiiGhZ+1hUitBstzm2n+CkXt0c18CyYRw5nF3tlpuPn+pcowqtjqEIsvggf1/lu/igjbBq6T/bZ7nFHgyL3vtOYXq7Iffk2TAPVjDWCzltCGzREsSFHXdVApjmEphmx5ZxBReiHVuh665FNcsdLxOWGXDOo6ZeTQKde/z14FGZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811743; c=relaxed/simple; bh=xROhpCG/UFEqyPlPHFBjL+Ei3IMKFCnsu+i2mJFrfH0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AgKlWXntVFvFGT8kkaZbYoJGjkbNl60xWTQamZeJObPzvj53DXEfx7+JiS/oyvugjjW/uMHYrglo08Nrk2HnmUKyAWNc9ZQECRSlt3helZqegJBwWy5T97dUO8tS5UmxkTY15+nUDODa9OhuN5YMe4lKZFS//GedvylVktDedz4= 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.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="UcrojUoR" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2059204f448so28706985ad.0 for ; Sun, 08 Sep 2024 09:09:01 -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=la/tq7qeWXHbkdFr+P36z377AFNbxuu+hgkJiIgUehuFQgdP4/dqH0L71O+v3bWxre TeFGqrFC3DxUKI5v6uCXXP0Wrg2ke/IYxhgQDeUEXy5vR0muzxXmS6OdbkKfcqioV0Ht FxKBmxJmO+JA1YCre2R/k53Sk7y9A3DHMklbLUsmV+A43JneePiKz2QZhXQ22p5S88i9 QDvcqMJ8vVdco1UIQn0vwXvDFreCQuG9E3jyhnLvsjscBzRtz5UG3FUEK+z6t3NHSyuc rANHgqws5wa6LI1hGQ/1sJr1XZRWXR2YFGowPVdHJSCCp8HrMVnGnCw09UnsGRvADIIQ hhhA== X-Gm-Message-State: AOJu0YzCemJ1Dw37JwrhalpBXOCvt7uRRcTRXtdrMpp8ioIYTWdTm+Dr ltlw6cbzJTdsWOXR4hhUYtnrtrLSW2cV4KRad0FNwfa8dji0xFsNQzQTtb3i82EIzkpFcJ5oV7w iBEeqSLPd/fVP4y1tekPbub5gk0FoZ5N4FnE2cf/3SwxUau19ddx0/TE/BS7LGC4w2p97d/0RY9 OzlMS+9kOW50LEjRgeiuybZd0Cz+F4BlJY2tPhLA71 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: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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/netlink/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 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, __NETDEV_CMD_MAX, NETDEV_CMD_MAX = (__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_policy[NETDEV_A_QSTATS_SCOPE [NETDEV_A_QSTATS_SCOPE] = NLA_POLICY_MASK(NLA_UINT, 0x1), }; +/* NETDEV_CMD_NAPI_SET - set */ +static const struct nla_policy netdev_napi_set_nl_policy[NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT + 1] = { + [NETDEV_A_NAPI_IFINDEX] = { .type = NLA_U32, }, + [NETDEV_A_NAPI_INDEX] = { .type = NLA_U32, }, + [NETDEV_A_NAPI_DEFER_HARD_IRQS] = { .type = NLA_S32 }, + [NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT] = { .type = NLA_UINT }, +}; + /* Ops table for netdev */ static const struct genl_split_ops netdev_nl_ops[] = { { @@ -151,6 +159,13 @@ static const struct genl_split_ops netdev_nl_ops[] = { .maxattr = NETDEV_A_QSTATS_SCOPE, .flags = GENL_CMD_CAP_DUMP, }, + { + .cmd = NETDEV_CMD_NAPI_SET, + .doit = netdev_nl_napi_set_doit, + .policy = netdev_napi_set_nl_policy, + .maxattr = NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT, + .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, + }, }; static const struct genl_multicast_group netdev_nl_mcgrps[] = { 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); 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, struct netlink_callback *cb) return err; } +static int +netdev_nl_napi_set_config(struct napi_storage *napi_storage, struct genl_info *info) +{ + u64 gro_flush_timeout = 0; + int defer = 0; + + if (info->attrs[NETDEV_A_NAPI_DEFER_HARD_IRQS]) { + defer = 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 = nla_get_uint(info->attrs[NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT]); + 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 = nla_get_u32(info->attrs[NETDEV_A_NAPI_IFINDEX]); + index = nla_get_u32(info->attrs[NETDEV_A_NAPI_INDEX]); + + rtnl_lock(); + + netdev = __dev_get_by_index(genl_info_net(info), ifindex); + if (netdev) { + napi_storage = &netdev->napi_storage[index]; + err = netdev_nl_napi_set_config(napi_storage, info); + } else { + NL_SET_BAD_ATTR(info->extack, info->attrs[NETDEV_A_NAPI_IFINDEX]); + err = -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/netdev.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, __NETDEV_CMD_MAX, NETDEV_CMD_MAX = (__NETDEV_CMD_MAX - 1) From patchwork Sun Sep 8 16:06:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13795562 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.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 E59ED17AE1D for ; Sun, 8 Sep 2024 16:09:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811744; cv=none; b=lOS5B/5cNcUuu4fIqCYfOkB2KtkCMoy1nZEK+BFOGCq+2m03s96QK8XLQ6LPyx46h8z1JXvLR7bE2mAbQawzQiA01tfxz9FxZMNK/oYlSBeXCQ3epFqwoFuCxOjgfrscbP2vzanaLWTdEPyqoirc4fEHY/A9QII+lnOcZIQRpsg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811744; c=relaxed/simple; bh=sHhlasbwVibNkDUBcgYAgRqAvPf6JXUYUczB3y1i5Qk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gM9mWimYybYSJSkEIzH5HM1+OnDm3yfnSbGdxkpNzW6e4+c7qJYEMgzYOxCuXimkp8wEJ9gk5pbJOfoNXumkg9zMPLx4t1wjfclDpC9Dak2Uz0kfB4K7W1a+xMVBcJigOYM4vG9PS5RLBJzqSOR4Sc1RF9GNrRN6IibnkKyeQDI= 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.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="UdSsw1xu" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-718e6299191so428533b3a.2 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=nQm9zia/c5duqYsuzVjQ8sMjGojH6rLWJ86Etb7x7XlP10U1rpMv1oCMkD7yzRsZFc 2ap0aS4WSshFXHlCo6UToYyaAl1yl2D4B4NkFI6R7m+hPpzvCj9jbi7Xk6fOZOwi/LCy Sq+n1HGysFJvQgRtfv7PbOCQ1OxY09XL5HRB2+YLIXz43raFLz6iOePBunVlw7pllrHO axznAWpVC1NTkM5Rt5nVIAQwPwfEaTj8Zawj3YbY3Bbs7uX6KEsf4amtlwkXOS0qFUsC p1pXEPLT5vlDiCTt/Arvd+JeCjX7RKlSX65OVufB8VtdwrmuYB3JNgzdsTNJDCyLKG3/ 9zrg== X-Gm-Message-State: AOJu0YwAVO4yOuko9HF+rrBg0apT0gj/0tyA7IWhgk/54fLOU26L6P1K DPcmkAiMGKfbeI4/73E4Cdr57cGGkSXlp+4BISoNwGuca3DHeZi/MMweMv5ykVuNxyChaZKfBtG oBBL8npOuDfEhaePg/XA1tyUr7X6P97+xaWmh96BxFqHvcfCNW8uej/O58+lKWTUa8URHD5p+Ek ggO/tvdQoB+P6O05cS6Xtr6LL6+m1mZXnAlVvQARcU 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: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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/ethernet/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 = 0; i < cp_nr_rings; i++) { bnapi = 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 = bp->bnapi[cp_nr_rings]; From patchwork Sun Sep 8 16:06:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13795563 X-Patchwork-Delegate: kuba@kernel.org 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 9113A176230 for ; Sun, 8 Sep 2024 16:09:04 +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=1725811746; cv=none; b=ocyM9xqP9u0D4vpkCUZ/r7Dulv5YNxkFq8oBJC4Qr3Tbb4KFqBzi9GtnWcfIpwYAIEeI2GqLxPV127cVALLOzIHnhO37ASkrHhg5XDiqFjkwDnI4C4Ml0OUIQJ5lpC1aqGSXQHxkeCvyfl/xhqIdGeqFXsD5lwCIQWDb3T9m6Ek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811746; c=relaxed/simple; bh=4HEYXckzb30ldYDuv6OJ1NZpctFxN6G/pxcTLPkqpU4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BuK/kOFwMqUHED2LVFuQm/VQDA6JLIuIU6hAvFYyhfIOMfe0tAWOnfB//GN0mpNvshLevtIYi33oq2LTRTkdWk7NZSlJHIHOMpAhkxlsQ0CNCC7giduVsb+ym4NDke8AU+afR1hf+/jC7QNKkt1RfC7gJYtt9lM1ah2hGtVZh90= 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.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="W0eg9OPM" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1fee6435a34so30451175ad.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=uIQ+TZ0JOe16VkVm+PaziD8oqBJouaz53lekS/m+8D3b3FRWPpUYV5JawLw5bKcWDX bdkd9vMIhfLXaCSkP34h302p8Hf5LCG32cY/JIgGYGH5xKiR0mp+Z2sLW4voHc/46VN2 6+b1TdeO+unuMxZzMzuZa6vMnmk7jTkbvODKF2V0QVwuajv+/8UMJJXFE42dT8ZPZuco Z4YoHcdFLhFQEQKcc0bbaoZTzv2+NFgqEq7MjESaPeoDdp3fzb0R6fifX6a6JuEiWxXN xtcoeEUTrla6Kt4r+aw1dzN5+ZM/FBffDs1HJVNIyn+aoqPJwcpfzTJgDmiegff0wEcl aiHg== X-Gm-Message-State: AOJu0YxQg71wxCfu9+uMXwyTKFEP/th1orJJvS3OZIt5anb1yYAw2hY2 RxHbT10nSDED3/mdipNql+5XqaJ8h9fQylPl4kr/4aKA6HVfekq3+P3b3iwBmG2dJJRV8I0FU7Y PymgdjEAgOjpe2nEGMaQhmp+NJhd9pjKcAJF88FE1LeVh9APJxRAp54q2VSPsoO5gC4FzGDzxVU tZQFWMXSl8bvKxP46JVjTMbny/eTLvYcNnYsNs2t61 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: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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/net/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 = irq_get_effective_affinity_mask(irq); c->lag_port = mlx5e_enumerate_lag_port(mdev, ix); - netif_napi_add(netdev, &c->napi, mlx5e_napi_poll); + netif_napi_add_storage(netdev, &c->napi, mlx5e_napi_poll, NAPI_POLL_WEIGHT, ix); netif_napi_set_irq(&c->napi, irq); err = mlx5e_open_queues(c, params, cparam); From patchwork Sun Sep 8 16:06:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13795564 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58BC017C23D for ; Sun, 8 Sep 2024 16:09:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725811747; cv=none; b=fdPrg8+V85h+j+MUf3SBi4IsDNtDuT9Z1lKn90J8t+44Ja5A3A1dirCy42rHVzS7PnvHXqv/mDgEAIz3il1AF1fnSlG1r1Kcf1Q0KWRWoHt8ELqgMe1yssukB8BuO6dwHdOIEHYtvr4Aje0Hf4j//VXK7carIO6Ea968raUS8V0= 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.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="HWjZbpdC" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-206e614953aso26464945ad.1 for ; Sun, 08 Sep 2024 09:09:06 -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=egERvb/3+V9ddLnSTP19VFnrFFd4lrulEhX0AJzAECD67Aj5IzKr8zVBgrBGEBEVYf +5pahrpqLipx2h1zEVvydtxbX4B+bb9Qb+UeZYW4iMKnuDCh/xMRqRAhJTUFMjpg3C9a FYbCQ0O664xvaPGEq/o0Imar2S6cEFjRYCz4DY0Iw9rcUYcJBxYlsrizdsF4aa/CZJ7R o74BEhgx3aEPhneLPK8TWISdoqW+ksLiU58waP4EhBf/uyKJ+LEmIW8WO7F9AXR/ffwA wm1kC2zMB45J+DKSIruNdFE2v30FNkdNFCrf1L0dopjfbS9Aw08ZkuuN14SKBrLsBbby LA1w== X-Gm-Message-State: AOJu0Yw7E44LJMHDshZaM4wvUuAbVDLnCYrE3KvVth0/slcWRq9wKMfC HmxrM8CdJ0KxLnyUl0hRQDYSsOToCfiO8b+mE/ki1jxGFm0yXksDUx30k+r+OrTQza4T5Emsh/u LG9PcRtfFKLXKGc2nVIunQZUrHiaxB7895a2I+B4Lhw+Qj46D46jPQdZ8mup+agFlpcEi8e1xIe XdUWcBd0D3ypxFdGsAhh/g+sCJKXPFjq+EfSC0edMD 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: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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/ethernet/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, struct mlx4_en_cq *cq, break; case RX: cq->mcq.comp = 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);