From patchwork Tue Oct 1 23:52:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13819047 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 57BB31E00AF for ; Tue, 1 Oct 2024 23:53:36 +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=1727826817; cv=none; b=ZU5Q/+PYzfo+7DVXTrJcNTZBUy0mx5Hb2nDKL4wr/6ZQZ0255zEN0SYNeAUbbD5jzjRyndRApV5yDtJ6ny1RJS71Wr8ICXZ01h2x6qXwN9bAkZCV7GOdyv5iL2Sxhz6tMM80/NW/jXHlG6mdhCrpzO5f8sjJr16pQdLsyvLd6ks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826817; c=relaxed/simple; bh=NKSjiGMl8HVeQM8T+1w9Wip+oPRlHTP1Per56Ka6OO4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YBZSuibIix5cVQ7ROYO7gO5H4/4uk9A9RMfJScanaWXmBXayDWUsIqyx0/CF3RigODkV8baO7gmqXVnW7X1JR6irWJo8Sj5ZrghTLGCvpnPUQ8gnykj/H3ezvCyXRA6ROVRRiDWKPTLMfap5v73lVu7SrlE8NiE4CkOxzxUqJII= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=V2TSWNFp; arc=none smtp.client-ip=209.85.215.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="V2TSWNFp" Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-7db4c1a54easo3887649a12.1 for ; Tue, 01 Oct 2024 16:53:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727826815; x=1728431615; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fNxcXSwfx56FZIl6Cm7lpquz7kJ98h6HMSLIQEYkHDY=; b=V2TSWNFpjMKCzXWbOQ2fhlGWG1CoRSycziw8NOfXZFwXMyFXRC/UudQkzvKBQBt5fb AwxhOSekCXt7pjJlaUovQcDZzryQv95gKFs2AjhczgAtG2eLh6qnT7aKUHC7PVT1DAdM W5SzKdO7TGrhEyUBqZep3rRLBTw3UACn+GeTA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727826815; x=1728431615; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fNxcXSwfx56FZIl6Cm7lpquz7kJ98h6HMSLIQEYkHDY=; b=xPFvgGl6gJWXGEEfDmVaBrZ7bF2K1c6QPq0XIjWbT9eaWvzbR5RapdgZyr2VLuG8xk hoWHtNzI8/g7Aa0qFhRTm99q0EIc2gD1ycstFjWjSaE0BvHT69xLPnYzf7iq630mbeR+ ND+701mHb0YmHMybP6A6NCjRKl2uzP0c6Wj80QzSKe7edBMk/sHIZi5BdQ0elrMynzBx 4lKjMYXyoyhOuu9Ik89lYvfNSoKj6RI7YZZZejx17sOJRbMB+WtAdZSO5x3869i2djBx ELbj9LSf1aQO78CE+xu30ZiYoeIX09n9DH0B3NryzHKpvcUbDI2qPMGEqvP9zARo/grB VFBg== X-Gm-Message-State: AOJu0YwjhOLxYZm7l4sqZUP7bLRVVUu9xK+T/gkRDXmcnaCR/KIltV+4 twQ5L9acOamykeFvwzXZObgrOSP0B0tZGfM1lqTzoPcQn17UCyEkYJDNJDCtBTQtQykqXESbQ3S h1tUYrk4Qml+L3BD06Yasr8F2722jWr/UkGR4zqxhnRvyKNEhwoD3J2YHKqRLbsKQCSgeOef/sT cYlH5g+OuNExO53UYp+qFDRTcfkEgOKm23IoU= X-Google-Smtp-Source: AGHT+IGk/edwwPJhtIujE/fEuThhfDAouuDtB+XD7cDRW7qhVSa/cILWYeRQBLMIALnf0IvrHUAu+w== X-Received: by 2002:a17:90a:c383:b0:2da:da85:b705 with SMTP id 98e67ed59e1d1-2e18466e09cmr1620618a91.14.1727826815119; Tue, 01 Oct 2024 16:53:35 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f89e973sm213130a91.29.2024.10.01.16.53.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 16:53:34 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, willemdebruijn.kernel@gmail.com, Joe Damato , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Jiri Pirko , Sebastian Andrzej Siewior , Lorenzo Bianconi , Kory Maincent , Johannes Berg , Breno Leitao , Alexander Lobakin , linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v4 1/9] net: napi: Make napi_defer_hard_irqs per-NAPI Date: Tue, 1 Oct 2024 23:52:32 +0000 Message-Id: <20241001235302.57609-2-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241001235302.57609-1-jdamato@fastly.com> References: <20241001235302.57609-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: 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 defer_hard_irqs to napi_struct in preparation for per-NAPI settings. The existing sysfs parameter is respected; writes to sysfs will write to all NAPI structs for the device and the net_device defer_hard_irq field. Reads from sysfs show the net_device field. The ability to set defer_hard_irqs on specific NAPI instances will be added in a later commit, via netdev-genl. Signed-off-by: Joe Damato --- .../networking/net_cachelines/net_device.rst | 2 +- include/linux/netdevice.h | 3 +- net/core/dev.c | 10 +++--- net/core/dev.h | 36 +++++++++++++++++++ net/core/net-sysfs.c | 2 +- 5 files changed, 45 insertions(+), 8 deletions(-) diff --git a/Documentation/networking/net_cachelines/net_device.rst b/Documentation/networking/net_cachelines/net_device.rst index 22b07c814f4a..eeeb7c925ec5 100644 --- a/Documentation/networking/net_cachelines/net_device.rst +++ b/Documentation/networking/net_cachelines/net_device.rst @@ -99,7 +99,6 @@ unsigned_int num_rx_queues unsigned_int real_num_rx_queues - read_mostly get_rps_cpu struct_bpf_prog* xdp_prog - read_mostly netif_elide_gro() unsigned_long gro_flush_timeout - read_mostly napi_complete_done -u32 napi_defer_hard_irqs - read_mostly napi_complete_done unsigned_int gro_max_size - read_mostly skb_gro_receive unsigned_int gro_ipv4_max_size - read_mostly skb_gro_receive rx_handler_func_t* rx_handler read_mostly - __netif_receive_skb_core @@ -183,3 +182,4 @@ struct_devlink_port* devlink_port struct_dpll_pin* dpll_pin struct hlist_head page_pools struct dim_irq_moder* irq_moder +u32 napi_defer_hard_irqs diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index e87b5e488325..55764efc5c93 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -377,6 +377,7 @@ struct napi_struct { struct list_head dev_list; struct hlist_node napi_hash_node; int irq; + u32 defer_hard_irqs; }; enum { @@ -2075,7 +2076,6 @@ struct net_device { unsigned int real_num_rx_queues; struct netdev_rx_queue *_rx; unsigned long gro_flush_timeout; - u32 napi_defer_hard_irqs; unsigned int gro_max_size; unsigned int gro_ipv4_max_size; rx_handler_func_t __rcu *rx_handler; @@ -2398,6 +2398,7 @@ struct net_device { /** @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 cd479f5f22f6..748739958d2a 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6227,7 +6227,7 @@ bool napi_complete_done(struct napi_struct *n, int 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--; @@ -6365,7 +6365,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); @@ -6647,6 +6647,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); @@ -11053,7 +11054,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); @@ -11991,7 +11992,6 @@ static void __init net_dev_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, real_num_rx_queues); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, _rx); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, gro_flush_timeout); - CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, napi_defer_hard_irqs); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, gro_max_size); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, gro_ipv4_max_size); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, rx_handler); @@ -12003,7 +12003,7 @@ static void __init net_dev_struct_check(void) #ifdef CONFIG_NET_XGRESS CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, tcx_ingress); #endif - CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_rx, 104); + CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_rx, 100); } /* diff --git a/net/core/dev.h b/net/core/dev.h index 5654325c5b71..b3792219879b 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -138,6 +138,42 @@ static inline void netif_set_gro_ipv4_max_size(struct net_device *dev, WRITE_ONCE(dev->gro_ipv4_max_size, size); } +/** + * napi_get_defer_hard_irqs - get the NAPI's defer_hard_irqs + * @n: napi struct to get the defer_hard_irqs field from + * + * Return: the per-NAPI value of the defar_hard_irqs field. + */ +static inline u32 napi_get_defer_hard_irqs(const struct napi_struct *n) +{ + return READ_ONCE(n->defer_hard_irqs); +} + +/** + * napi_set_defer_hard_irqs - set the defer_hard_irqs for a napi + * @n: napi_struct to set the defer_hard_irqs field + * @defer: the value the field should be set to + */ +static inline void napi_set_defer_hard_irqs(struct napi_struct *n, u32 defer) +{ + WRITE_ONCE(n->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 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 05cf5347f25e..25125f356a15 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -429,7 +429,7 @@ static int change_napi_defer_hard_irqs(struct net_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 Tue Oct 1 23:52:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13819048 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (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 D8CB21E0B73 for ; Tue, 1 Oct 2024 23:53:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826822; cv=none; b=Lv4+OPAM+jeb4zIfgmJ21+e1tQWpsaxJVZAr/XUJIiMNGWLiFD1Pmy2LLWBoOnfkTVluBtYD82bBiary1D5xXYy1og/FVpnN22TE/c2LKl/6HWrhqctFgxPAsG4QKcV4Mkx1UQZ3MycdMDn6N5oEzjACUnwefPFM491Q+4CTigE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826822; c=relaxed/simple; bh=kAEG1Am3qGuk35HDrwWkcGYK2JXUX2VXmCklQAjtsYs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=c0RL9zL2xLwJz3YfqngQYWqro95tLsbJ7srT+i81QynG0ZBCVnq5SLBGRZmpNUy4OaC0NCUc6jNQqFXclW5gXbyf3zbJi9tCsmxjZsijW63MQZnTfq0t222+rj42deLBv3byY6OM15rsWyqPJaP06Zo+UdRHzeR9PPjCu3eDewM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=r3rpdxy5; arc=none smtp.client-ip=209.85.216.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="r3rpdxy5" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2e0a950e2f2so4879074a91.2 for ; Tue, 01 Oct 2024 16:53:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727826820; x=1728431620; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lrVj7Azlfps/B75TfmvK6tL6oA2kiOEMADlEWkkR0JI=; b=r3rpdxy5WzAxFcJJNI43O4TieaDRF5ppGwabok26WN7D165h0VUvprqM1u/+kzxc/V PrHwNvIoP5AYQxvoZy3DxIhzJ+6d8E2tYO2OJXjrJIRcOEpd+/21vFp6XOcokj4DDW5Q Q/Smmc6mp97ZI4r1MMKK3VQNOHIlsyNBPJkCY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727826820; x=1728431620; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lrVj7Azlfps/B75TfmvK6tL6oA2kiOEMADlEWkkR0JI=; b=YAkhIbcSeiGv8rA8bp8/qcooWIl8LXnaTbEjir5+Fl6epJsUzKxffPvPcLISeJyp/a WUhawDNovrOrXy9zxt4/yxewUMSMw2Wm+9Szr9VwfpcTgZT2X8y2wGsYPihvNESasHfF hc2RTkeJS8KYVNcR+ZCxiLyAQ5OBeGUHa02yLTtOFILhBrnN+jyNFarwb7wspEjVy3Jl gjMwTFsWUZJXJydAHwzGC5tZn3g6BDc4D5gTJvis5RKXKz2wzq72PTLwEqAZ+ZFWFawy FFmcbD8v61h0Np8dSJeN+gMKHYx503XTNbEYUaqVaLz8CkI2gjnb5B11nBUrm7j/dF8+ SMBw== X-Gm-Message-State: AOJu0YzJ+GqIEsxLGlvcMRv+U+J7v8wokfC3lnzSdoRBP4N90BgG8+OZ qq+yFE4VDi28sKn9KYkpCuZ1o7nuag84QvR+WvQ31kdif6Ts6lGY8Gy7Y7VZ0owN5QN5Rhk3pkw UKo9NYw5ldcc/FBjeB1X0Th5do6mwOIKs8m8rUBUo7FXHfP42hH4YEGAoJdM2sfRAsA3I1JPYdJ AAy48gufgU2Dg3724iqRo2yIIUUMAhFGfkuJQ= X-Google-Smtp-Source: AGHT+IGpgJ1rgzHrxwtT40rOkt57kYCh2EC90ybm6qKtAfpKHRyK6AeHjlpVi+lwyDuEEFYJtQbb5w== X-Received: by 2002:a17:90a:8c18:b0:2d3:cd27:c480 with SMTP id 98e67ed59e1d1-2e1849e437bmr1829345a91.33.1727826819796; Tue, 01 Oct 2024 16:53:39 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f89e973sm213130a91.29.2024.10.01.16.53.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 16:53:39 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, willemdebruijn.kernel@gmail.com, Joe Damato , Donald Hunter , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jesper Dangaard Brouer , Mina Almasry , Xuan Zhuo , linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v4 2/9] netdev-genl: Dump napi_defer_hard_irqs Date: Tue, 1 Oct 2024 23:52:33 +0000 Message-Id: <20241001235302.57609-3-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241001235302.57609-1-jdamato@fastly.com> References: <20241001235302.57609-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: 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 | 6 ++++++ tools/include/uapi/linux/netdev.h | 1 + 4 files changed, 16 insertions(+) diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlink/specs/netdev.yaml index 08412c279297..585e87ec3c16 100644 --- a/Documentation/netlink/specs/netdev.yaml +++ b/Documentation/netlink/specs/netdev.yaml @@ -248,6 +248,13 @@ attribute-sets: threaded mode. If NAPI is not in threaded mode (i.e. uses normal softirq context), the attribute will be absent. type: u32 + - + name: defer-hard-irqs + doc: The number of consecutive empty polls before IRQ deferral ends + and hardware IRQs are re-enabled. + type: u32 + checks: + max: s32-max - name: queue attributes: @@ -636,6 +643,7 @@ operations: - ifindex - irq - pid + - defer-hard-irqs dump: request: attributes: diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h index 7c308f04e7a0..13dc0b027e86 100644 --- a/include/uapi/linux/netdev.h +++ b/include/uapi/linux/netdev.h @@ -122,6 +122,7 @@ enum { NETDEV_A_NAPI_ID, NETDEV_A_NAPI_IRQ, NETDEV_A_NAPI_PID, + NETDEV_A_NAPI_DEFER_HARD_IRQS, __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 1cb954f2d39e..de9bd76f43f8 100644 --- a/net/core/netdev-genl.c +++ b/net/core/netdev-genl.c @@ -161,6 +161,7 @@ static int netdev_nl_napi_fill_one(struct sk_buff *rsp, struct napi_struct *napi, const struct genl_info *info) { + u32 napi_defer_hard_irqs; void *hdr; pid_t pid; @@ -189,6 +190,11 @@ 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 7c308f04e7a0..13dc0b027e86 100644 --- a/tools/include/uapi/linux/netdev.h +++ b/tools/include/uapi/linux/netdev.h @@ -122,6 +122,7 @@ enum { NETDEV_A_NAPI_ID, NETDEV_A_NAPI_IRQ, NETDEV_A_NAPI_PID, + NETDEV_A_NAPI_DEFER_HARD_IRQS, __NETDEV_A_NAPI_MAX, NETDEV_A_NAPI_MAX = (__NETDEV_A_NAPI_MAX - 1) From patchwork Tue Oct 1 23:52:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13819049 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E599E1D4343 for ; Tue, 1 Oct 2024 23:53:46 +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=1727826828; cv=none; b=A8a3pL8aXA1E71ALovynHxfFiYikdyY/JCTMLeQqxvJmarwPnGSKVdul53PKH5TvIwbmei3KIpVbMiGQPrnHIQayW7A+s2kTNWXt7xtErZ/z7D+7BiZDlKfhKpzQwwjFRBQ0NvXoWQbDD9ZjZ1LvvfpWITkunWSaJft/EhebOM4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826828; c=relaxed/simple; bh=QaU3GRuNJYHoKKjvrelHYx5nDgWJ2NGSPgRMJp/+Dww=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ntqQ0wtXXGjRPRgPH41v9wg65jaYssFhASOo9OHcKYVSGyxrp2k7S8yAz3uRc2uJgKwYLMrFZOewoD+Ee1/ENl/wUQWw+tC6Fp3IhF7EU+3T9a8miZlrs7IJCq1Be4Mxpdp4hOTAT6cXhnNNQSbx3E7WGl6ry0BA8gx2+Jilq2M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=dtOOPy3a; arc=none smtp.client-ip=209.85.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="dtOOPy3a" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-20b84bfbdfcso2322935ad.0 for ; Tue, 01 Oct 2024 16:53:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727826826; x=1728431626; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8jeH1LephSM3GFjcVzcycSI9hrM1DyHIRSwagoq7Cvo=; b=dtOOPy3a5lzDSM3+S12qUgKyEVsNTvNWX4WReuz/JGy+8zcNycbnYvCzlax4/L5IAl pIzM8xJsknx9bM94QpPzMWS6yRM0GQezr/v0lk1ZZhFIt+jhQRELeC3ACJRRG8DTAWbQ 9mCw2nCTK0x4mv9hupbLNjy9DUq4z8qWjBFMM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727826826; x=1728431626; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8jeH1LephSM3GFjcVzcycSI9hrM1DyHIRSwagoq7Cvo=; b=wjlbfnx9WHrypMLiNUyTCdM+C/ljqymjKvYE8VFx/d0kqz2ns0/Uxq1BKmGkkVWGVV 8kk1PMLnWdrQgdXEEHITvTPNq9M+KdwnSI/TRFdAMCNbLbvcUaIw3C8tV2/Aoyv7Q2+s wLd6HZlFWGfMlSiInMQpKxbk7axFVIza/3IQNv9P6IS26iV22EDfP/DSbTipHNQnXR+8 shfKnfSY6h1lr1Ns44fY6rwVnKbrdzXdKK1yIPDYmcxvINj1EJrJ+363rCcUERcSxv8l VTdLs6y9b0pFgzrZ9vGj2p1jBEX6DCQ+usDI9uhS3I8XF8voYiPSoqUoDc5mO/YX5ieE uUEA== X-Gm-Message-State: AOJu0YwjAL72H6nfdUqH6yo6QqIct8NjLqfnD27emS5oA0GqklZo/zoH qM096Gq/wQmUULmGjjtEkck9eBpr7c0aY0UBvL5i0DIX2gEt/EceKMRwYBXag+TxsbL6hbZ7tRf 4FVDDfklHvy6AadsYfzZDwCvjD6jfZJo6gPdhPDKl12Wi0Wfq7z2/m0h3vctg7CD1sJt8HflYrz ak6HGcS2t0emeDMYypGSfgaORBJLDq6EYtjlY= X-Google-Smtp-Source: AGHT+IHnD47ZafzdaY5Hlr1/2gXXQgmcG0+t+WA3Vp+OIdQfqS4Lc5McbW2j0MHbRJNSn6aoWeQjew== X-Received: by 2002:a17:90a:f484:b0:2da:8b9f:5b74 with SMTP id 98e67ed59e1d1-2e1853e76femr1920261a91.13.1727826825726; Tue, 01 Oct 2024 16:53:45 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f89e973sm213130a91.29.2024.10.01.16.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 16:53:45 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, willemdebruijn.kernel@gmail.com, Joe Damato , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Tony Nguyen , Przemek Kitszel , Jiri Pirko , Sebastian Andrzej Siewior , Lorenzo Bianconi , David Ahern , Kory Maincent , Johannes Berg , Breno Leitao , Alexander Lobakin , linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-kernel@vger.kernel.org (open list), intel-wired-lan@lists.osuosl.org (moderated list:INTEL ETHERNET DRIVERS) Subject: [RFC net-next v4 3/9] net: napi: Make gro_flush_timeout per-NAPI Date: Tue, 1 Oct 2024 23:52:34 +0000 Message-Id: <20241001235302.57609-4-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241001235302.57609-1-jdamato@fastly.com> References: <20241001235302.57609-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: 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. Note that idpf has embedded napi_struct in its internals and has established some series of asserts that involve the size of napi structure. Since this change increases the napi_struct size from 400 to 416 (according to pahole on my system), I've increased the assertion in idpf by 16 bytes. No attention whatsoever was paid to the cacheline placement of idpf internals as a result of this change. Signed-off-by: Joe Damato --- .../networking/net_cachelines/net_device.rst | 2 +- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 2 +- include/linux/netdevice.h | 3 +- net/core/dev.c | 12 +++--- net/core/dev.h | 40 +++++++++++++++++++ net/core/net-sysfs.c | 2 +- 6 files changed, 51 insertions(+), 10 deletions(-) diff --git a/Documentation/networking/net_cachelines/net_device.rst b/Documentation/networking/net_cachelines/net_device.rst index eeeb7c925ec5..3d02ae79c850 100644 --- a/Documentation/networking/net_cachelines/net_device.rst +++ b/Documentation/networking/net_cachelines/net_device.rst @@ -98,7 +98,6 @@ struct_netdev_queue* _rx read_mostly unsigned_int num_rx_queues unsigned_int real_num_rx_queues - read_mostly get_rps_cpu struct_bpf_prog* xdp_prog - read_mostly netif_elide_gro() -unsigned_long gro_flush_timeout - read_mostly napi_complete_done unsigned_int gro_max_size - read_mostly skb_gro_receive unsigned_int gro_ipv4_max_size - read_mostly skb_gro_receive rx_handler_func_t* rx_handler read_mostly - __netif_receive_skb_core @@ -182,4 +181,5 @@ struct_devlink_port* devlink_port struct_dpll_pin* dpll_pin struct hlist_head page_pools struct dim_irq_moder* irq_moder +unsigned_long gro_flush_timeout u32 napi_defer_hard_irqs diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.h b/drivers/net/ethernet/intel/idpf/idpf_txrx.h index f0537826f840..fcdf73486d46 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_txrx.h +++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.h @@ -438,7 +438,7 @@ struct idpf_q_vector { __cacheline_group_end_aligned(cold); }; libeth_cacheline_set_assert(struct idpf_q_vector, 112, - 424 + 2 * sizeof(struct dim), + 440 + 2 * sizeof(struct dim), 8 + sizeof(cpumask_var_t)); struct idpf_rx_queue_stats { diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 55764efc5c93..33897edd16c8 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -377,6 +377,7 @@ struct napi_struct { struct list_head dev_list; struct hlist_node napi_hash_node; int irq; + unsigned long gro_flush_timeout; u32 defer_hard_irqs; }; @@ -2075,7 +2076,6 @@ struct net_device { int ifindex; unsigned int real_num_rx_queues; struct netdev_rx_queue *_rx; - unsigned long gro_flush_timeout; unsigned int gro_max_size; unsigned int gro_ipv4_max_size; rx_handler_func_t __rcu *rx_handler; @@ -2398,6 +2398,7 @@ struct net_device { /** @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/net/core/dev.c b/net/core/dev.c index 748739958d2a..056ed44f766f 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6226,12 +6226,12 @@ bool napi_complete_done(struct napi_struct *n, int work_done) 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; } @@ -6366,7 +6366,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; @@ -6648,6 +6648,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); @@ -11053,7 +11054,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); } } @@ -11991,7 +11992,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); @@ -12003,7 +12003,7 @@ static void __init net_dev_struct_check(void) #ifdef CONFIG_NET_XGRESS CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, tcx_ingress); #endif - CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_rx, 100); + CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_rx, 92); } /* diff --git a/net/core/dev.h b/net/core/dev.h index b3792219879b..26e598aa56c3 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -174,6 +174,46 @@ static inline void netdev_set_defer_hard_irqs(struct 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) +{ + return READ_ONCE(n->gro_flush_timeout); +} + +/** + * napi_set_gro_flush_timeout - set the gro_flush_timeout for a napi + * @n: napi struct to set the gro_flush_timeout + * @timeout: timeout value to set + * + * napi_set_gro_flush_timeout sets the per-NAPI gro_flush_timeout + */ +static inline void napi_set_gro_flush_timeout(struct napi_struct *n, + unsigned long timeout) +{ + WRITE_ONCE(n->gro_flush_timeout, timeout); +} + +/** + * netdev_set_gro_flush_timeout - set gro_flush_timeout of a netdev's NAPIs + * @netdev: the net_device for which all NAPIs will have gro_flush_timeout set + * @timeout: the timeout value to set + */ +static inline void netdev_set_gro_flush_timeout(struct net_device *netdev, + unsigned long timeout) +{ + struct napi_struct *napi; + + WRITE_ONCE(netdev->gro_flush_timeout, timeout); + list_for_each_entry(napi, &netdev->napi_list, dev_list) + napi_set_gro_flush_timeout(napi, timeout); +} + int rps_cpumask_housekeeping(struct cpumask *mask); #if defined(CONFIG_DEBUG_NET) && defined(CONFIG_BPF_SYSCALL) diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 25125f356a15..2d9afc6e2161 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -409,7 +409,7 @@ NETDEVICE_SHOW_RW(tx_queue_len, fmt_dec); 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; } From patchwork Tue Oct 1 23:52: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: 13819050 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (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 882A41E1313 for ; Tue, 1 Oct 2024 23:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826833; cv=none; b=igYC7SW/Lw0C95kHWr+d6Zt1wRyId74WFjFPzeAtPfAFlpn9bfvL07cp4JXvtL05ZvFZMHn04lPLZFxCtU++U4sJj/pdGowvpyjydLOQlVKObFWAPd10cFnK0RAK+iIrPKKYw7GD+XB14UBuDm2Zsz8YNmB949MtXQMTBcvhaTo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826833; c=relaxed/simple; bh=A4ctw+2b8yq0sCbFcjdY3SVzbWEsxT2TUGSyUg6wK0s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RNEy+WG6VM9i1wb8YihS8jbLZgkIQTpLx8GqMzJsf6n8846ROb48an8IchxoFQsY6gHcGuegKgjP8BR8xDharCERze5zGBEiIFgldvpDWuEQVmcov5VTL4YmdBmS0aYI6EMt0bGLGd53J3CCTM1e9KnNE6xVXpQOIhhtObRQyl0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=t+8yrxtO; arc=none smtp.client-ip=209.85.216.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="t+8yrxtO" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2e18293a5efso350903a91.3 for ; Tue, 01 Oct 2024 16:53:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727826830; x=1728431630; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KQII9ub/bVtxy0ntEn1HGx1uSFXeUqoutb/T7bvVeMk=; b=t+8yrxtO5Y8sW0RctPlO9mtJZCzMt8sLCn93CwLonDirnK/LcLh0yewHcD32G4/20s UHIc1iOguDL8aU7jso/NpAc7q7JRoF5gySmeAX+zZrICQA03tySjU4xNWdTZuevRceF3 VVFrLuP7rexiDWxJFJyFFPI6ybijM2u/uWxiM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727826830; x=1728431630; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KQII9ub/bVtxy0ntEn1HGx1uSFXeUqoutb/T7bvVeMk=; b=W2l7dufAr44VU9kTEDZ+tlukGYGWZZ45SU1J9QXLDgGCfXSmA40jc2vGW2XCeDF2be 5GBOcKUdzMnIgIyWZx5iC0lnqSjfCbSpZMdAYRyGMqzbiIrecB20WZBKXObpFc0mxdLO Jk4E/W5eLrJXJyaEZKdIx9kwK49JOy++2S/mh9g2gjmSD8LoIVcgcaZxd/DQxPECLMlE GoCPNBOqMAxWfv3XhFPDV+PkqfVtsI3MaXEjsu+PypKzXZ/9mpcpjNwOOS6IcLwUsvi9 wpPETG2PP/L7lZ49jbH75T+pGTp1UHejTl4jmDiCyZFZec9PD7vBX4FiIM6FEHEZR3Lj PJXQ== X-Gm-Message-State: AOJu0YyvQP8jBEijH2++Ci/RFQOSD2eI+9ZlKuv2Ix5qurdCQJwBIGNN hyU2Ta+uuGNItclevk8C2rBK0VQ9Zvjx5FGkRzhhvUPsAI+/5vaLZ0bYdSXICkdVmvi4SRAR9qj AczLyp9cmeCXHZBs5MWb+Z2/VXzCXp+iRM5/9JNl6eCUPFiK7hbKY/2S+0ojhUYic/0jG1rlZD2 dl+0Z8syhL1s2iqGa2Rb3OyZzR9f8oBLkBLfA= X-Google-Smtp-Source: AGHT+IH6y8TLEoNcS3CIY1eRqDcl6J9ZIkBmPCtlp4ki4860wF8VxL5+YVU+aQ3guijKYC2ciYrGKQ== X-Received: by 2002:a17:90a:f192:b0:2e0:59af:b998 with SMTP id 98e67ed59e1d1-2e184943fdfmr1601328a91.39.1727826830385; Tue, 01 Oct 2024 16:53:50 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f89e973sm213130a91.29.2024.10.01.16.53.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 16:53:50 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, willemdebruijn.kernel@gmail.com, Joe Damato , Donald Hunter , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jesper Dangaard Brouer , Mina Almasry , Xuan Zhuo , Daniel Jurgens , linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v4 4/9] netdev-genl: Dump gro_flush_timeout Date: Tue, 1 Oct 2024 23:52:35 +0000 Message-Id: <20241001235302.57609-5-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241001235302.57609-1-jdamato@fastly.com> References: <20241001235302.57609-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: 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 gro_flush_timeout for a NAPI ID. Signed-off-by: Joe Damato --- Documentation/netlink/specs/netdev.yaml | 6 ++++++ include/uapi/linux/netdev.h | 1 + net/core/netdev-genl.c | 6 ++++++ tools/include/uapi/linux/netdev.h | 1 + 4 files changed, 14 insertions(+) diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlink/specs/netdev.yaml index 585e87ec3c16..bf13613eaa0d 100644 --- a/Documentation/netlink/specs/netdev.yaml +++ b/Documentation/netlink/specs/netdev.yaml @@ -255,6 +255,11 @@ attribute-sets: type: u32 checks: max: s32-max + - + name: gro-flush-timeout + doc: The timeout, in nanoseconds, of when to trigger the NAPI + watchdog timer and schedule NAPI processing. + type: uint - name: queue attributes: @@ -644,6 +649,7 @@ operations: - irq - pid - defer-hard-irqs + - gro-flush-timeout dump: request: attributes: diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h index 13dc0b027e86..cacd33359c76 100644 --- a/include/uapi/linux/netdev.h +++ b/include/uapi/linux/netdev.h @@ -123,6 +123,7 @@ enum { NETDEV_A_NAPI_IRQ, NETDEV_A_NAPI_PID, NETDEV_A_NAPI_DEFER_HARD_IRQS, + NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT, __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 de9bd76f43f8..64e5e4cee60d 100644 --- a/net/core/netdev-genl.c +++ b/net/core/netdev-genl.c @@ -161,6 +161,7 @@ static int netdev_nl_napi_fill_one(struct sk_buff *rsp, struct napi_struct *napi, const struct genl_info *info) { + unsigned long gro_flush_timeout; u32 napi_defer_hard_irqs; void *hdr; pid_t pid; @@ -195,6 +196,11 @@ netdev_nl_napi_fill_one(struct sk_buff *rsp, struct napi_struct *napi, 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 13dc0b027e86..cacd33359c76 100644 --- a/tools/include/uapi/linux/netdev.h +++ b/tools/include/uapi/linux/netdev.h @@ -123,6 +123,7 @@ enum { NETDEV_A_NAPI_IRQ, NETDEV_A_NAPI_PID, NETDEV_A_NAPI_DEFER_HARD_IRQS, + NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT, __NETDEV_A_NAPI_MAX, NETDEV_A_NAPI_MAX = (__NETDEV_A_NAPI_MAX - 1) From patchwork Tue Oct 1 23:52: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: 13819051 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (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 10A0F1E1334 for ; Tue, 1 Oct 2024 23:53:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826837; cv=none; b=CPjesEgQ4wGZtKdDi4MTae38c/V6BuxBt41DCzBSdvPfrPNFeXf1zf6LPdA1XAm21oLCsvzSmRs/4hwV7H0sH9nVArTuiyX7JvIQjOma+V/ItT5pvXjKY4GZpWhsoW6BiJt7OTi4rNV8Y17Ys+yTz2WOE+aOn/wCcExA5vAKjlE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826837; c=relaxed/simple; bh=zto/izfmmguhKhVHdEZdiijUzaBXpzkbp1KqyItqIxo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QYOI6s5mFeDBUEKEN35Di48XcBVBk1dAq4YF4kWXEz7CzgWjE5Pg5kLf9iXChmZPPpihGDbqn5qEuKaZWvbQGopuwm4T1suW26QOgEx29vJD7fWb5V/liJvHAiK2HrRngjnPh0gvZNnUu15ASqwbWs67QUIkO7uwK9gbwIhor+s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=iE9GiHBY; arc=none smtp.client-ip=209.85.216.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="iE9GiHBY" Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-2e0a74ce880so5043403a91.2 for ; Tue, 01 Oct 2024 16:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727826835; x=1728431635; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wlIWZP5hxY7Z7ed2/y3QCNWpfTA3UWwpTpt+lr7sIBg=; b=iE9GiHBYF+WhLpT3RBv1V+mfW8Wgm3Yu9wy/VmhIK74mxvKpN1VWtseoOuV1eLE7/f P5femz9h5P+u4RYDvI8lrmuunCnYT6+XaZC6YfEBjejNc6GRbVuKdaMj4KXtymAmjhGp 2ndF8394YUpVGLHchbKmNl/S4Y5/Ld1PQ/uI8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727826835; x=1728431635; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wlIWZP5hxY7Z7ed2/y3QCNWpfTA3UWwpTpt+lr7sIBg=; b=A3jsLvWK1Do9u9sDheiHoYhiGmNjD3Raztk4q3ENOAv7ldOTiCgmNAPulRbw2xoEGp LtvKHNg5h0yy7GLEgfWTc1EGwt8m7BoZDcI16bKMdp0qTxupJ0m2RtOuhaGhM2EtMzl1 Nlfa7T7zOt+ldeWPfuVFj18Txa0D7Bo2SK5CFROuDJSyGekuuxWSOn+JQncwEJVGMNxc AGjBPhQrN5BYOOU3gAxhP12fhUx40DF8/nnc1yHI/r2jALUv6plbnhsC01/LpViufP2U F3007Ygr/0RrCshDkPzK0vwnjBQ6rVa6uceb8xCo3EbTQK/ZcNOvJj5G+zSuNfD/HPzy iTQA== X-Gm-Message-State: AOJu0Ywt2TzboTwjATjDbesIEPKWyts9WnsvKtfzoofqbmlzRnZzedYK DjehTXOgbw+xjxc8MH7DnXcHCASgoyp3B0+DIpQSZXNUZAieiZFGveqYwAk69bV4+/OlagRdI+v PMkMf6dMUw7qo9/b7Jaol8RdrNwv/Bzez85mfVWcfQuCjsLn7e+lS+N+YFBGs53Z6DjWZMhpdew YzQyy/co2IoMlFRYGCErX4DtEnhZwFsDYIqG8= X-Google-Smtp-Source: AGHT+IFPu7lvhG4uUYOO2d1rHoWdVGH9+8y4NJPM7S8ebIb+AWvoza2AwcPTUtXv++qlhFapQqZP5w== X-Received: by 2002:a17:90a:ff0d:b0:2e0:875a:f72d with SMTP id 98e67ed59e1d1-2e182c80442mr1777548a91.0.1727826834967; Tue, 01 Oct 2024 16:53:54 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f89e973sm213130a91.29.2024.10.01.16.53.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 16:53:54 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, willemdebruijn.kernel@gmail.com, Joe Damato , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Jiri Pirko , Sebastian Andrzej Siewior , Lorenzo Bianconi , Johannes Berg , linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v4 5/9] net: napi: Add napi_config Date: Tue, 1 Oct 2024 23:52:36 +0000 Message-Id: <20241001235302.57609-6-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241001235302.57609-1-jdamato@fastly.com> References: <20241001235302.57609-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: 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 config area for NAPI configuration to the core. Drivers opt-in to setting the persistent config for a NAPI by passing an index when calling netif_napi_add_config. napi_config is allocated in alloc_netdev_mqs, freed in free_netdev (after the NAPIs are deleted). Drivers which call netif_napi_add_config will have persistent per-NAPI settings: NAPI IDs, gro_flush_timeout, and defer_hard_irq settings. Per-NAPI settings are saved in napi_disable and restored in napi_enable. Co-developed-by: Martin Karsten Signed-off-by: Martin Karsten Signed-off-by: Joe Damato --- .../networking/net_cachelines/net_device.rst | 1 + include/linux/netdevice.h | 32 ++++++++ net/core/dev.c | 79 +++++++++++++++++-- net/core/dev.h | 14 ++++ 4 files changed, 119 insertions(+), 7 deletions(-) diff --git a/Documentation/networking/net_cachelines/net_device.rst b/Documentation/networking/net_cachelines/net_device.rst index 3d02ae79c850..11d659051f5e 100644 --- a/Documentation/networking/net_cachelines/net_device.rst +++ b/Documentation/networking/net_cachelines/net_device.rst @@ -183,3 +183,4 @@ struct hlist_head page_pools struct dim_irq_moder* irq_moder unsigned_long gro_flush_timeout u32 napi_defer_hard_irqs +struct napi_config* napi_config diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 33897edd16c8..51cff55e7ab8 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -342,6 +342,15 @@ struct gro_list { */ #define GRO_HASH_BUCKETS 8 +/* + * Structure for per-NAPI config + */ +struct napi_config { + u64 gro_flush_timeout; + u32 defer_hard_irqs; + unsigned int napi_id; +}; + /* * Structure for NAPI scheduling similar to tasklet but with weighting */ @@ -379,6 +388,8 @@ struct napi_struct { int irq; unsigned long gro_flush_timeout; u32 defer_hard_irqs; + int index; + struct napi_config *config; }; enum { @@ -2011,6 +2022,9 @@ enum netdev_reg_state { * @dpll_pin: Pointer to the SyncE source pin of a DPLL subsystem, * where the clock is recovered. * + * @napi_config: An array of napi_config structures containing per-NAPI + * settings. + * * FIXME: cleanup struct net_device such that network protocol info * moves out. */ @@ -2400,6 +2414,7 @@ struct net_device { struct dim_irq_moder *irq_moder; unsigned long gro_flush_timeout; u32 napi_defer_hard_irqs; + struct napi_config *napi_config; u8 priv[] ____cacheline_aligned __counted_by(priv_len); @@ -2650,6 +2665,23 @@ netif_napi_add_tx_weight(struct net_device *dev, netif_napi_add_weight(dev, napi, poll, weight); } +/** + * netif_napi_add_config - initialize a NAPI context with persistent config + * @dev: network device + * @napi: NAPI context + * @poll: polling function + * @weight: the poll weight of this NAPI + * @index: the NAPI index + */ +static inline void +netif_napi_add_config(struct net_device *dev, struct napi_struct *napi, + int (*poll)(struct napi_struct *, int), int index) +{ + napi->index = index; + napi->config = &dev->napi_config[index]; + netif_napi_add_weight(dev, napi, poll, NAPI_POLL_WEIGHT); +} + /** * netif_napi_add_tx() - initialize a NAPI context to be used for Tx only * @dev: network device diff --git a/net/core/dev.c b/net/core/dev.c index 056ed44f766f..9acb6db19200 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6499,6 +6499,22 @@ EXPORT_SYMBOL(napi_busy_loop); #endif /* CONFIG_NET_RX_BUSY_POLL */ +static void __napi_hash_add_with_id(struct napi_struct *napi, + unsigned int napi_id) +{ + napi->napi_id = napi_id; + hlist_add_head_rcu(&napi->napi_hash_node, + &napi_hash[napi->napi_id % HASH_SIZE(napi_hash)]); +} + +static void napi_hash_add_with_id(struct napi_struct *napi, + unsigned int napi_id) +{ + spin_lock(&napi_hash_lock); + __napi_hash_add_with_id(napi, napi_id); + spin_unlock(&napi_hash_lock); +} + static void napi_hash_add(struct napi_struct *napi) { if (test_bit(NAPI_STATE_NO_BUSY_POLL, &napi->state)) @@ -6511,10 +6527,8 @@ static void napi_hash_add(struct napi_struct *napi) if (unlikely(++napi_gen_id < MIN_NAPI_ID)) napi_gen_id = MIN_NAPI_ID; } while (napi_by_id(napi_gen_id)); - napi->napi_id = napi_gen_id; - hlist_add_head_rcu(&napi->napi_hash_node, - &napi_hash[napi->napi_id % HASH_SIZE(napi_hash)]); + __napi_hash_add_with_id(napi, napi_gen_id); spin_unlock(&napi_hash_lock); } @@ -6637,6 +6651,28 @@ void netif_queue_set_napi(struct net_device *dev, unsigned int queue_index, } EXPORT_SYMBOL(netif_queue_set_napi); +static void napi_restore_config(struct napi_struct *n) +{ + n->defer_hard_irqs = n->config->defer_hard_irqs; + n->gro_flush_timeout = n->config->gro_flush_timeout; + /* a NAPI ID might be stored in the config, if so use it. if not, use + * napi_hash_add to generate one for us. It will be saved to the config + * in napi_disable. + */ + if (n->config->napi_id) + napi_hash_add_with_id(n, n->config->napi_id); + else + napi_hash_add(n); +} + +static void napi_save_config(struct napi_struct *n) +{ + n->config->defer_hard_irqs = n->defer_hard_irqs; + n->config->gro_flush_timeout = n->gro_flush_timeout; + n->config->napi_id = n->napi_id; + napi_hash_del(n); +} + void netif_napi_add_weight(struct net_device *dev, struct napi_struct *napi, int (*poll)(struct napi_struct *, int), int weight) { @@ -6647,8 +6683,6 @@ 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)); - 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); @@ -6666,7 +6700,13 @@ void netif_napi_add_weight(struct net_device *dev, struct napi_struct *napi, set_bit(NAPI_STATE_SCHED, &napi->state); set_bit(NAPI_STATE_NPSVC, &napi->state); list_add_rcu(&napi->dev_list, &dev->napi_list); - napi_hash_add(napi); + + /* default settings from sysfs are applied to all NAPIs. any per-NAPI + * configuration will be loaded in napi_enable + */ + napi_set_defer_hard_irqs(napi, READ_ONCE(dev->napi_defer_hard_irqs)); + napi_set_gro_flush_timeout(napi, READ_ONCE(dev->gro_flush_timeout)); + napi_get_frags_check(napi); /* Create kthread for this napi if dev->threaded is set. * Clear dev->threaded if kthread creation failed so that @@ -6698,6 +6738,11 @@ void napi_disable(struct napi_struct *n) hrtimer_cancel(&n->timer); + if (n->config) + napi_save_config(n); + else + napi_hash_del(n); + clear_bit(NAPI_STATE_DISABLE, &n->state); } EXPORT_SYMBOL(napi_disable); @@ -6713,6 +6758,11 @@ void napi_enable(struct napi_struct *n) { unsigned long new, val = READ_ONCE(n->state); + if (n->config) + napi_restore_config(n); + else + napi_hash_add(n); + do { BUG_ON(!test_bit(NAPI_STATE_SCHED, &val)); @@ -6742,7 +6792,11 @@ void __netif_napi_del(struct napi_struct *napi) if (!test_and_clear_bit(NAPI_STATE_LISTED, &napi->state)) return; - napi_hash_del(napi); + if (napi->config) { + napi->index = -1; + napi->config = NULL; + } + list_del_rcu(&napi->dev_list); napi_free_frags(napi); @@ -11079,6 +11133,8 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, unsigned int txqs, unsigned int rxqs) { struct net_device *dev; + size_t napi_config_sz; + unsigned int maxqs; BUG_ON(strlen(name) >= sizeof(dev->name)); @@ -11092,6 +11148,8 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, return NULL; } + maxqs = max(txqs, rxqs); + dev = kvzalloc(struct_size(dev, priv, sizeof_priv), GFP_KERNEL_ACCOUNT | __GFP_RETRY_MAYFAIL); if (!dev) @@ -11166,6 +11224,11 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, if (!dev->ethtool) goto free_all; + napi_config_sz = array_size(maxqs, sizeof(*dev->napi_config)); + dev->napi_config = kvzalloc(napi_config_sz, GFP_KERNEL_ACCOUNT); + if (!dev->napi_config) + goto free_all; + strscpy(dev->name, name); dev->name_assign_type = name_assign_type; dev->group = INIT_NETDEV_GROUP; @@ -11227,6 +11290,8 @@ void free_netdev(struct net_device *dev) list_for_each_entry_safe(p, n, &dev->napi_list, dev_list) netif_napi_del(p); + kvfree(dev->napi_config); + ref_tracker_dir_exit(&dev->refcnt_tracker); #ifdef CONFIG_PCPU_DEV_REFCNT free_percpu(dev->pcpu_refcnt); diff --git a/net/core/dev.h b/net/core/dev.h index 26e598aa56c3..7365fa0ffdc7 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -167,11 +167,18 @@ static inline void napi_set_defer_hard_irqs(struct napi_struct *n, u32 defer) static inline void netdev_set_defer_hard_irqs(struct net_device *netdev, u32 defer) { + unsigned int count = max(netdev->num_rx_queues, + netdev->num_tx_queues); struct napi_struct *napi; + int i; WRITE_ONCE(netdev->napi_defer_hard_irqs, defer); list_for_each_entry(napi, &netdev->napi_list, dev_list) napi_set_defer_hard_irqs(napi, defer); + + if (netdev->napi_config) + for (i = 0; i < count; i++) + netdev->napi_config[i].defer_hard_irqs = defer; } /** @@ -207,11 +214,18 @@ static inline void napi_set_gro_flush_timeout(struct napi_struct *n, static inline void netdev_set_gro_flush_timeout(struct net_device *netdev, unsigned long timeout) { + unsigned int count = max(netdev->num_rx_queues, + netdev->num_tx_queues); struct napi_struct *napi; + int i; WRITE_ONCE(netdev->gro_flush_timeout, timeout); list_for_each_entry(napi, &netdev->napi_list, dev_list) napi_set_gro_flush_timeout(napi, timeout); + + if (netdev->napi_config) + for (i = 0; i < count; i++) + netdev->napi_config[i].gro_flush_timeout = timeout; } int rps_cpumask_housekeeping(struct cpumask *mask); From patchwork Tue Oct 1 23:52: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: 13819052 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (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 BDBFB1E00A1 for ; Tue, 1 Oct 2024 23:54:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826844; cv=none; b=JflZAPyAeAnODCSzPCNPTLrDSnztGWYn1qG/1FUil6wNE9bHrPnB21cV6i4EcGyTRYWyfKnG7hDo+X3Jrx3KfjDE/0WNiS65JNqafmLIO9PwN31UO6T3xkVxmvd00cp2zqU+sgQKNw7ICfkwUsI1imxzlGTkM4WBZWJklL9BuHc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826844; c=relaxed/simple; bh=etJ5QQq7z0hnczvA60rILD3Y/1LYpD2GBa8P+y6My1c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DqtkVPBqlDDjw/iiTEkfN4dbKVP9QycDH1kWwN8UGmDUDBoegROaLMxtLRADb9lBOColyr/n+GUER/w98h6CA4l0aMLzvy7HN8/Mmg9zxu+Z8Xcf+z9xGYV6+QB9gCJn9GwsTaVzgG8sQfVRS/VAp5Ev/RrVbMsO8/9exHHjyJI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=ExodRjaV; arc=none smtp.client-ip=209.85.216.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="ExodRjaV" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2e0b9bca173so3701445a91.0 for ; Tue, 01 Oct 2024 16:54:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727826841; x=1728431641; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vp6xBU2Yo2PWr8F48aHYbzV3nL3kOi+Sh9yDhDyEv0E=; b=ExodRjaV6byjxnO5/ZZ5xaMB4R0Kh+Xaq5z0OGKKeCHzXLmhj8uyel2IG2JurQA7Og H5w8FN2jOnti6VlDltXrl+V/gj/i6moX9tFthH+8fb5LY819zbaqoI3KhGoPcyzN0BFr 5lCsvIfoLRGnzK88/tKLTTuj/saCDAn1b/kt8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727826841; x=1728431641; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vp6xBU2Yo2PWr8F48aHYbzV3nL3kOi+Sh9yDhDyEv0E=; b=iGwsLZy7FzpxARgDuWhp+419cfOH/4cRcXnevZ1ayTclPUb/R1mdqA0D/XlVMVjh0p UxQz2Q+KUV+kfKzQMqg+icrysF0LPmfTdlyjTIhj3leBuh88aqc2FRee08Boj0z3xM6r 3Df04TyOLFQHYicMu3uACxEdVqj6/JEaLS21PUc6iHAM3kCt/UIf7VV4n7sc3qzDSIVo NFhezif2+27baDWTWRnGZ9NY4JQqwIcUr7JWUS3WUnGkhOvbZRTNMxDjGgTGaThtxWKJ oPket3cvI2ohTiyKS1vMPlgu5R5HfhhGrujhAgKNDJ30W+Ed1plgaZYihkxC/LdqZLtW hBxQ== X-Gm-Message-State: AOJu0Yy0RU1n14baIlFRNBoiI0QZhMwv2qIR30U+jZvcenpR3Wbwc7SR OO8jA0XQmOnPfJyho8PTaTItf6vBbBG1u+nTdQki/x/0QCQOa1YWcEkDZxIh6axaUHu81yn8WPA g1doQt7xN5uKJfOGSUHBMP9m0iuvZL6OF+Ja+bgPpepcsYX/K733xUYV0gWvZqUfJEC83K+QZ9d MSAQUlsjYbDIz+ebFu2J69NglF5e8O4eiqp5I= X-Google-Smtp-Source: AGHT+IEoHQYE+xaLebe1pVy16LZPHUGrAQAE2ajk4dV/5lmrgMHS7is6fxTq38YsNokwFPUG2Bz0xA== X-Received: by 2002:a17:90a:fb4b:b0:2e0:a0ab:7fd0 with SMTP id 98e67ed59e1d1-2e1846b5446mr1574787a91.16.1727826841525; Tue, 01 Oct 2024 16:54:01 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f89e973sm213130a91.29.2024.10.01.16.54.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 16:54:01 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, willemdebruijn.kernel@gmail.com, Joe Damato , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Donald Hunter , Jesper Dangaard Brouer , Mina Almasry , Xuan Zhuo , Daniel Jurgens , linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v4 6/9] netdev-genl: Support setting per-NAPI config values Date: Tue, 1 Oct 2024 23:52:37 +0000 Message-Id: <20241001235302.57609-7-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241001235302.57609-1-jdamato@fastly.com> References: <20241001235302.57609-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: 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 | 11 ++++++ include/uapi/linux/netdev.h | 1 + net/core/netdev-genl-gen.c | 14 ++++++++ net/core/netdev-genl-gen.h | 1 + net/core/netdev-genl.c | 45 +++++++++++++++++++++++++ tools/include/uapi/linux/netdev.h | 1 + 6 files changed, 73 insertions(+) diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlink/specs/netdev.yaml index bf13613eaa0d..7f8d2489c68c 100644 --- a/Documentation/netlink/specs/netdev.yaml +++ b/Documentation/netlink/specs/netdev.yaml @@ -690,6 +690,17 @@ operations: reply: attributes: - id + - + name: napi-set + doc: Set configurable NAPI instance settings. + attribute-set: napi + flags: [ admin-perm ] + do: + request: + attributes: + - napi-id + - defer-hard-irqs + - gro-flush-timeout kernel-family: headers: [ "linux/list.h"] diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h index cacd33359c76..e3ebb49f60d2 100644 --- a/include/uapi/linux/netdev.h +++ b/include/uapi/linux/netdev.h @@ -201,6 +201,7 @@ enum { NETDEV_CMD_NAPI_GET, NETDEV_CMD_QSTATS_GET, NETDEV_CMD_BIND_RX, + NETDEV_CMD_NAPI_SET, __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 b28424ae06d5..901c6f65b735 100644 --- a/net/core/netdev-genl-gen.c +++ b/net/core/netdev-genl-gen.c @@ -87,6 +87,13 @@ static const struct nla_policy netdev_bind_rx_nl_policy[NETDEV_A_DMABUF_FD + 1] [NETDEV_A_DMABUF_QUEUES] = NLA_POLICY_NESTED(netdev_queue_id_nl_policy), }; +/* 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_ID] = { .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[] = { { @@ -171,6 +178,13 @@ static const struct genl_split_ops netdev_nl_ops[] = { .maxattr = NETDEV_A_DMABUF_FD, .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, }, + { + .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 8cda334fd042..85e6d7c95ada 100644 --- a/net/core/netdev-genl-gen.h +++ b/net/core/netdev-genl-gen.h @@ -30,6 +30,7 @@ int netdev_nl_queue_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb); int netdev_nl_napi_get_doit(struct sk_buff *skb, struct genl_info *info); int netdev_nl_napi_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb); +int netdev_nl_napi_set_doit(struct sk_buff *skb, struct genl_info *info); int netdev_nl_qstats_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb); int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info); diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c index 64e5e4cee60d..59523318d620 100644 --- a/net/core/netdev-genl.c +++ b/net/core/netdev-genl.c @@ -303,6 +303,51 @@ int netdev_nl_napi_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb) return err; } +static int +netdev_nl_napi_set_config(struct napi_struct *napi, struct genl_info *info) +{ + u64 gro_flush_timeout = 0; + u32 defer = 0; + + if (info->attrs[NETDEV_A_NAPI_DEFER_HARD_IRQS]) { + defer = nla_get_u32(info->attrs[NETDEV_A_NAPI_DEFER_HARD_IRQS]); + napi_set_defer_hard_irqs(napi, defer); + } + + if (info->attrs[NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT]) { + gro_flush_timeout = nla_get_uint(info->attrs[NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT]); + napi_set_gro_flush_timeout(napi, gro_flush_timeout); + } + + return 0; +} + +int netdev_nl_napi_set_doit(struct sk_buff *skb, struct genl_info *info) +{ + struct napi_struct *napi; + unsigned int napi_id; + int err; + + if (GENL_REQ_ATTR_CHECK(info, NETDEV_A_NAPI_ID)) + return -EINVAL; + + napi_id = nla_get_u32(info->attrs[NETDEV_A_NAPI_ID]); + + rtnl_lock(); + + napi = napi_by_id(napi_id); + if (napi) { + err = netdev_nl_napi_set_config(napi, info); + } else { + NL_SET_BAD_ATTR(info->extack, info->attrs[NETDEV_A_NAPI_ID]); + err = -ENOENT; + } + + rtnl_unlock(); + + return err; +} + static int netdev_nl_queue_fill_one(struct sk_buff *rsp, struct net_device *netdev, u32 q_idx, u32 q_type, const struct genl_info *info) diff --git a/tools/include/uapi/linux/netdev.h b/tools/include/uapi/linux/netdev.h index cacd33359c76..e3ebb49f60d2 100644 --- a/tools/include/uapi/linux/netdev.h +++ b/tools/include/uapi/linux/netdev.h @@ -201,6 +201,7 @@ enum { NETDEV_CMD_NAPI_GET, NETDEV_CMD_QSTATS_GET, NETDEV_CMD_BIND_RX, + NETDEV_CMD_NAPI_SET, __NETDEV_CMD_MAX, NETDEV_CMD_MAX = (__NETDEV_CMD_MAX - 1) From patchwork Tue Oct 1 23:52: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: 13819053 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (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 4761E1E0B9A for ; Tue, 1 Oct 2024 23:54:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826845; cv=none; b=U3aKFdfnSlwFtBlMlvFSymFO7kTfjLee12ns8TaHTohummRdnqXpvHGanJ/5t/fTdYvlCeXx/U5ObVyze0Z46qwIctGTwY/VzSKpM4DFCMr/SeoKk5DIAI179vtJC0sCDYfJILdwroc+yHP2lqlwedM4NTJXrkUGaxxhNQlbOYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826845; c=relaxed/simple; bh=o3D87lP+KNy+Jir/fY7fvLsBvMyy9THUtqA+9zYkCpo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IbqTYYdNvolBTwpIBmkXRbnNXZYZDWCKpzf2KfcgdW8axjBl4RfDwbBAx1rZ786RIRmyhYQ1bsxwj/lYz1llU7900s1xOX1cvzJDNBR7x1+xtisITGZHfSh+3KN0bWyKxTqRlc14sPvYzQ8IBDJNEJNZqBUheNoPqKmeNMx4Sxc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=vvSlo9Ee; arc=none smtp.client-ip=209.85.216.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="vvSlo9Ee" Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-2e109539aedso2675855a91.0 for ; Tue, 01 Oct 2024 16:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727826843; x=1728431643; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PLF63g3UxuFOgNadANGg2+qqv3YqiRQyKEar+/98gi0=; b=vvSlo9Eelee5097/8c3VFUiWk5vJI1GPF+ur0suqFmVXNp4IQa68jwxMIzjarE2L2p /gSLra0OAbxh4K4QH4DPjMiUbE/q0nRGq5uyN5t2DKLzC5vHRNSfc1q0ldj8l6RnfqdY 1/DRSiviWHyyHh7JVOO+HeZSZ9lFKBRCu4iBQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727826843; x=1728431643; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PLF63g3UxuFOgNadANGg2+qqv3YqiRQyKEar+/98gi0=; b=W+l7j9TREQqkPnWkZOgh4HLy4hqYWY1/qNiBCTQFaubUWqJyNte6m9vQYda3Nq3+zX to8OMQ8kt/1K/FvQRNbabBbH0f6hwDCoAqHQfSCrtcz63oSbkAdWYNpHGnxrmjBiqN0j 6aB8lbo1/PR06dh4Ujn9FKILs4RJJqVaVF6rXlFc7Pkt44nEizcuu6fu3FT/Mqj89+U9 6Ba58DycAeGouhZ2YtF27uw0ZtMhylfNeTS6ss/Q8gMdtJLHEOiCTEXvIfq2E3pISoJS MLnyIi+l4kC63oz1ZyJQz4UUJ6t3LeXpd4MEgeqKipomTJ9M1U78wV60WAe/hDYWL85I oFXQ== X-Gm-Message-State: AOJu0YxF5TiwHHvu3ZDFfkULGMQGZDtfp8CppVyOkKMCyLc7lqW4AqVW lt34pFmZammOtW58qyUNirLOC3R9fGpTGy3VOVRDJQA/GwCTXWCke964nQCh7YQ7NxhPJZzW272 hHKFhamw8/xotyB241UOzCb1fl74BTS044vgPUzxXxn740gtTIfDmfqNedW48DLTPGnMnRfenSG WDqr6X6mRZNlChPBFYgB3J2YsGtfxCkEdqNXs= X-Google-Smtp-Source: AGHT+IEziOa7A+MAB9R2Y08fOCLGpcavYwRLkZ94iRWB4+/kdOklKsQcBgrXg0q1p/jteWgh+MwIQQ== X-Received: by 2002:a17:90a:1b89:b0:2d8:89ad:a67e with SMTP id 98e67ed59e1d1-2e1845511e2mr1931370a91.1.1727826843241; Tue, 01 Oct 2024 16:54:03 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f89e973sm213130a91.29.2024.10.01.16.54.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 16:54:02 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, willemdebruijn.kernel@gmail.com, Joe Damato , Michael Chan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v4 7/9] bnxt: Add support for persistent NAPI config Date: Tue, 1 Oct 2024 23:52:38 +0000 Message-Id: <20241001235302.57609-8-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241001235302.57609-1-jdamato@fastly.com> References: <20241001235302.57609-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: 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_config to assign persistent per-NAPI config when initializing NAPIs. Signed-off-by: Joe Damato --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 6e422e24750a..f5da2dace982 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10986,7 +10986,8 @@ static void bnxt_init_napi(struct bnxt *bp) cp_nr_rings--; for (i = 0; i < cp_nr_rings; i++) { bnapi = bp->bnapi[i]; - netif_napi_add(bp->dev, &bnapi->napi, poll_fn); + netif_napi_add_config(bp->dev, &bnapi->napi, poll_fn, + bnapi->index); } if (BNXT_CHIP_TYPE_NITRO_A0(bp)) { bnapi = bp->bnapi[cp_nr_rings]; From patchwork Tue Oct 1 23:52: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: 13819054 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (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 550A71E1A3F for ; Tue, 1 Oct 2024 23:54:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826847; cv=none; b=BvbRNZA4YX1gmVvfUKaVV49qboxi3Ce37JxggLj/z/jlo/Gz7vgrEpSlAxI9x/vJilkR3re+Rbr1+KEOCKChNs8ZTYVhPH4MYxbXiz+tjrXCUxxzSAgrjLun4VDtTUBK8OpQjTP4Ig0b05HRiZSlOn+Djz2y0zpTtB+oFyKoXJM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826847; c=relaxed/simple; bh=V1cs8PIynlwOrqpZWUDccPgmCikFp/sP5CKLnXd9jKQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SDeZWen0+/u3SgU7yKaksgFTHk6+qNndEypmRzcijPbyewCCJaM3PEH7dVgUufszm12RZDSBPFT0PZUwbGgZ2dB7ulsVX1xjyuQpcJ5u2gQ7wmGxrk3oUDwjy7XU6b8XeBo8xLkBJXAz5NnwOnQyAtdF4TBx2X8u5FYfEduakYo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=EpY8Z0zX; arc=none smtp.client-ip=209.85.216.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="EpY8Z0zX" Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-2e07d85e956so5184975a91.3 for ; Tue, 01 Oct 2024 16:54:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727826845; x=1728431645; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aGBwpUl9kCiLHYdWMLl9DJsonbhtGhnaZmowBhBViU8=; b=EpY8Z0zXPyx4D8vghd4Og9TjmOW7gDpPw2BctIZ0EKOI2CwOyGK6Ypqf/h78/VSyW8 PJISXlt5wEkx8bpSNkSSNgY2qtNWuIvZ/wUujvTfeXh1APCzlDLY2JGiRdmFdVojerTq odGryhVp9wz1xmxKWHmWmABLlHdEWs9/flG1w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727826845; x=1728431645; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aGBwpUl9kCiLHYdWMLl9DJsonbhtGhnaZmowBhBViU8=; b=qAFKuds4PTCTZZIBh17sy6Yqqc9URcyGmCti9e3w4lOQoIFQ2hJrkRK2HLUpq4IgzU nEgcuJAoKy8DAK3yvRQA/2OuDYrCI0hzhQeeFl4j0TX74W/isZuxUIGPXz9JC0Q6lmTN Mv+c4nHwK8GYJLaxymJXPWTXnUFkY0DOwH1cT7v/qZM64RcxYkuiwUG2pTLFufBTQBET CffDGdDZ/Eabwhmjr+gCcn4/HQEU+pMrg9cODqcHAuQNlwWjTTw0vBhf6vnDo2Wt83c1 +h0cjHMVgVe+/y2a0wtS1txMU7F7tgC5AMLUVD0kMYfXg5+PT01ggC+LvR5nhBgtRxmf 3idw== X-Gm-Message-State: AOJu0YwEM6GWUDRAMVV9NFo6hleTkwqsr8cq5LhQDpKJKZU/zayTZa73 MMOltX55HGO6T2Ixfwmu3zd7wrvrkr9nyn2OS422UMk7qTCQWPt0ju3ExyjyD+CvSjqYpq61mw6 1YqPUUG+glrY+kIYYYiBwTWzZQRv7O1Dm3Dzul9tn3FSGFRq1ujyPR4oXQ3OHR80KypTwFuvo7s tLHmILbKEHqAhO0I3JaSAGboauCpHOiwBuVQ4= X-Google-Smtp-Source: AGHT+IHH0M+tYuCS0vhSmHV9gXbNu6UtuY0Q3nfoA1P+p7ZvG4sPDyAAL0B88yi8W5maqglkVlbXeg== X-Received: by 2002:a17:90a:604b:b0:2d3:c638:ec67 with SMTP id 98e67ed59e1d1-2e182ca768fmr1714582a91.0.1727826845207; Tue, 01 Oct 2024 16:54:05 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f89e973sm213130a91.29.2024.10.01.16.54.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 16:54:04 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, willemdebruijn.kernel@gmail.com, Joe Damato , Saeed Mahameed , Tariq Toukan , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-rdma@vger.kernel.org (open list:MELLANOX MLX5 core VPI driver), linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v4 8/9] mlx5: Add support for persistent NAPI config Date: Tue, 1 Oct 2024 23:52:39 +0000 Message-Id: <20241001235302.57609-9-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241001235302.57609-1-jdamato@fastly.com> References: <20241001235302.57609-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: 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_config to assign persistent per-NAPI config when initializing NAPIs. Signed-off-by: Joe Damato --- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index a5659c0c4236..09ab7ac07c29 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -2697,7 +2697,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix, c->aff_mask = 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_config(netdev, &c->napi, mlx5e_napi_poll, ix); netif_napi_set_irq(&c->napi, irq); err = mlx5e_open_queues(c, params, cparam); From patchwork Tue Oct 1 23:52: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: 13819055 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) (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 049841E411C for ; Tue, 1 Oct 2024 23:54:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826849; cv=none; b=VYWG92bsynLlDbUlJAtAcqEuR13coYiy66esjg+T5PYFmy9G3Pn8YNDCsmA00gZdZWmwq78V90Qk0P1JsgZ0BQOt84YqwLkLFn9cRylv2/pkNL82NmzBrb+FIWmaoNMy7Axkde9xVO2Q6X9cjrHQX6GGb1dvY5MGwF6m2DHZGt8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727826849; c=relaxed/simple; bh=acO4k3Tl1873YqlB+9+oRM1/HbYr6wa8DEvdBbXxJoQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BxaFypc+NhPDgYk5D0vvlkprArEiWTJYQJ9xJVxXj73hQ1PNFZbmPZGj4CVWZx1emeIooTPIx43ZsJ2DhmrUkE0edET0OOv/RmPY0c1DE+7/2nWtc8EEgWH2ZfhdMIrk/7hWyqlUJ7yrpUbK8gHbJQ5tEXpNzfbe9yiYWH99csM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=I9CuXGuZ; arc=none smtp.client-ip=209.85.216.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="I9CuXGuZ" Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-2e0a74ce880so5043516a91.2 for ; Tue, 01 Oct 2024 16:54:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1727826847; x=1728431647; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PGtnVysYWBB+XDp/kZF0mQyFvrv7Ut5AwNUz8on3uqI=; b=I9CuXGuZCTP3ykMhvyDAZ3l2VCzD+7AFe15fY10/SC64P7jfCeMu44RPAapDArvRNa +O9ayxq+2/5owICuq02oO5dZ9kAd00aJK+IsJ5aEuNo3NUOH/CRoN6i7UMAagl24I4Q3 aJF29Wq5iOl8V13wSgyVBST713b896eQivgFU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727826847; x=1728431647; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PGtnVysYWBB+XDp/kZF0mQyFvrv7Ut5AwNUz8on3uqI=; b=ARzRRtDh6KEU9RAsWblAmJmxLjQd4N5noH0Yzk2ADuPHkuw+Sm6d5oWqThqPc8l/iQ 3kxoMq8aU/MjhT+x2shSfS8PYoRFjWkZ97fpjHbMivXqD9fk93FilW9nrCkmzsa+IhAW GYD4vlknoNV+drCrHqfw518xsXc3kcohtniTdWGPlaHGpnLtLRjcc289Ismfe4DwwRsX rLsWNTUMhQb8kK1ZAApVU+sAc+U/BV4+crROlBFCfX53O86+vZdxrkFxGXZU29jaya0Q ajO3zTMatl9vyi2ULPjSpoRm1ZPr9OYw9VVpneawEyI+Cz+jXkNPfjEnWVRENgmjQkG8 E4lQ== X-Gm-Message-State: AOJu0YwwiG178joF7QbXDHePElM2/DGWk+ELdancphlCo2ImCTJrhwvE /hsMD0Jnh+LAxKP04MFDavSttilmVdXL47ieHT5OC8wuqlDWcaxQrQeBQODhacMnyxwpyGWMmYF 2GWFPcnkJmaYAZwFkQ4okcdGgQ+XLi7kRyS8HjaehaI6CtHPyNA4N0i4f7FRkUqm3G6Y6loxADc 5VtIMocu0ipdtL1ZFEx60cOp/A+EGSyUmQP2U= X-Google-Smtp-Source: AGHT+IFCgBS+YgTB1iRrCXeD774tHuBkiuRdbbUI5qwujyFtDh9/oA9HeddTZv+rnPbzAgKNnb5EZQ== X-Received: by 2002:a17:90a:bd0c:b0:2d8:aa9c:e386 with SMTP id 98e67ed59e1d1-2e18455c8e2mr1759138a91.14.1727826846920; Tue, 01 Oct 2024 16:54:06 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f89e973sm213130a91.29.2024.10.01.16.54.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 16:54:06 -0700 (PDT) From: Joe Damato To: netdev@vger.kernel.org Cc: mkarsten@uwaterloo.ca, skhawaja@google.com, sdf@fomichev.me, bjorn@rivosinc.com, amritha.nambiar@intel.com, sridhar.samudrala@intel.com, willemdebruijn.kernel@gmail.com, Joe Damato , Tariq Toukan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-rdma@vger.kernel.org (open list:MELLANOX MLX4 core VPI driver), linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v4 9/9] mlx4: Add support for persistent NAPI config to RX CQs Date: Tue, 1 Oct 2024 23:52:40 +0000 Message-Id: <20241001235302.57609-10-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241001235302.57609-1-jdamato@fastly.com> References: <20241001235302.57609-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: 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_config to assign persistent per-NAPI config when initializing RX CQ NAPIs. Presently, struct napi_config only has support for two fields used for RX, so there is no need to support them with TX CQs, yet. Signed-off-by: Joe Damato --- drivers/net/ethernet/mellanox/mlx4/en_cq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_cq.c b/drivers/net/ethernet/mellanox/mlx4/en_cq.c index 461cc2c79c71..0e92956e84cf 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_cq.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_cq.c @@ -156,7 +156,8 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, 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_config(cq->dev, &cq->napi, mlx4_en_poll_rx_cq, + cq_idx); netif_napi_set_irq(&cq->napi, irq); napi_enable(&cq->napi); netif_queue_set_napi(cq->dev, cq_idx, NETDEV_QUEUE_TYPE_RX, &cq->napi);