From nobody Sat Nov 30 04:40:47 2024 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 43C1319FA65 for ; Thu, 12 Sep 2024 10:08:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726135694; cv=none; b=u3PVyNA15GE9epMDK6yuZeKfZCEFtnBkJyWwUJxpWb51ahcQgnmCxEx/aeObpZm11txPjX7yNCKdo5aEJg7RU/aYDIYtGhQwfULYDlnxeqO0eJap+EwCQPx9gkbQ4+Gg+bc/KLthW3DJTAEk20yHJhLN1/yjgCszWQ3vTWUoQ2k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726135694; c=relaxed/simple; bh=h6jbFg3yI896qytI1xpUiCGRLIyGARAX6EcPd3lUMvk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Gh7tKUiwySv2cf7UUlk7oG3Qhx7GQpgxS2Mwmv7GNnK01n+cln6PJHWpYKsqrFb5n73EoVGNO/Vl8WWi3tA7Se0DuIkL20G8Igsqa8Sj7eYCUS11YLc8hBpse9d22+O3SaTtPXAzEAeTTbkX+q24XftePMNtJEm38Bf/JD1kZDk= 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=CkMGpgOJ; arc=none smtp.client-ip=209.85.214.181 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="CkMGpgOJ" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2053616fa36so9678125ad.0 for ; Thu, 12 Sep 2024 03:08:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1726135691; x=1726740491; 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=4UBjebpmjpuyVZ0+PgYdCT0hRPVHfzVPHoo8s9iw55o=; b=CkMGpgOJwZhVycbPSf5XB6E8s/k8QuYk7KUjPutD8je/glcguo+bzLVQ7TsiINBKQp d9eg5eE2sAxDY4baKJTtZZM4iQ1S1KgJOFWsNzeltrCoi+T/UrHONdvYysCCVHwXp+3G Y2iZEV3LRyqFpsaIS7yq7YFGtuwW5XPLt0aww= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726135691; x=1726740491; 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=4UBjebpmjpuyVZ0+PgYdCT0hRPVHfzVPHoo8s9iw55o=; b=E1/1yEtbDOpZebrDVY3CT9ERCAwXW7QJVOJLx9CbwgI8kOCIIvjW9Mvc7B/RjUWm73 UF0D+Dqag/kaHQJMyOe3mZ+q1lqhV5IEn+vKkujD8H0fvN92C13K5bUlwSzFBuLWk6oZ HN+iITrSUl0AvtcsQgdF+uKQutj2gDXFuNq4TN7xImAkqTkgtGt+gMBprOBecFZETxsv 64Y0/u+RBuXnYvwRDPaea5adzYPWbd+DG9DponXfnkRTq0wYOmP18fiJGb4AxLB5I5OR P+CTlNeoASsPNyqfR2r8E/W7pJb8K/aUMp2E5TYa4ug5DzUKeDv/7CLY4HgLtzRBRa56 M70w== X-Forwarded-Encrypted: i=1; AJvYcCV6qPpElNPnxDjHL4W6lJZ/jw7IDqdAtRXfBSe9inX8e5Ef26b5HVNb73QIdU3wB5mekEeEkGH3P2ldR9E=@vger.kernel.org X-Gm-Message-State: AOJu0YySoOUd/BMP2cL45XWhrnQtf6LN+SC0BtV0aflC5TVowAribyZq Yl5XbLjg71PHwS+6gWonqFDfDUaB5gNJ6z1mFzDn0pNJcM1FBOadq8eGYEJlVeY= X-Google-Smtp-Source: AGHT+IHp7ODIKlvphCUjxcyN551gTEJqtHlLb5YGCWaSPJNMU99ey9TL4b/oodqIxQqkCxC0tA9LwQ== X-Received: by 2002:a17:903:1c1:b0:207:1848:394e with SMTP id d9443c01a7336-2076e305b0cmr33824425ad.8.1726135690384; Thu, 12 Sep 2024 03:08:10 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2076afe9da3sm11583795ad.239.2024.09.12.03.08.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 03:08:09 -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 , 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 v3 1/9] net: napi: Make napi_defer_hard_irqs per-NAPI Date: Thu, 12 Sep 2024 10:07:09 +0000 Message-Id: <20240912100738.16567-2-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240912100738.16567-1-jdamato@fastly.com> References: <20240912100738.16567-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allow per-NAPI defer_hard_irqs setting. The existing sysfs parameter is respected; writes to sysfs will write to all NAPI structs for the device and the net_device defer_hard_irq field. Reads from sysfs will read from the net_device field. sysfs code was updated to guard against what appears to be a potential overflow as the field is an int, but the value passed in is an unsigned long. The ability to set defer_hard_irqs on specific NAPI instances will be added in a later commit, via netdev-genl. Signed-off-by: Joe Damato --- .../networking/net_cachelines/net_device.rst | 2 +- include/linux/netdevice.h | 3 +- net/core/dev.c | 10 +++--- net/core/dev.h | 36 +++++++++++++++++++ net/core/net-sysfs.c | 2 +- 5 files changed, 45 insertions(+), 8 deletions(-) diff --git a/Documentation/networking/net_cachelines/net_device.rst b/Docum= entation/networking/net_cachelines/net_device.rst index 22b07c814f4a..eeeb7c925ec5 100644 --- a/Documentation/networking/net_cachelines/net_device.rst +++ b/Documentation/networking/net_cachelines/net_device.rst @@ -99,7 +99,6 @@ unsigned_int num_rx_queues unsigned_int real_num_rx_queues - = read_mostly get_rps_cpu struct_bpf_prog* xdp_prog - = read_mostly netif_elide_gro() unsigned_long gro_flush_timeout - = read_mostly napi_complete_done -u32 napi_defer_hard_irqs - = read_mostly napi_complete_done unsigned_int gro_max_size - = read_mostly skb_gro_receive unsigned_int gro_ipv4_max_size - = read_mostly skb_gro_receive rx_handler_func_t* rx_handler read_mostly = - __netif_receive_skb_core @@ -183,3 +182,4 @@ struct_devlink_port* devlink_port struct_dpll_pin* dpll_pin = =20 struct hlist_head page_pools struct dim_irq_moder* irq_moder +u32 napi_defer_hard_irqs diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 2e40a137dc12..f28b96c95259 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -377,6 +377,7 @@ struct napi_struct { struct list_head dev_list; struct hlist_node napi_hash_node; int irq; + u32 defer_hard_irqs; }; =20 enum { @@ -2075,7 +2076,6 @@ struct net_device { unsigned int real_num_rx_queues; struct netdev_rx_queue *_rx; unsigned long gro_flush_timeout; - u32 napi_defer_hard_irqs; unsigned int gro_max_size; unsigned int gro_ipv4_max_size; rx_handler_func_t __rcu *rx_handler; @@ -2398,6 +2398,7 @@ struct net_device { =20 /** @irq_moder: dim parameters used if IS_ENABLED(CONFIG_DIMLIB). */ struct dim_irq_moder *irq_moder; + u32 napi_defer_hard_irqs; =20 u8 priv[] ____cacheline_aligned __counted_by(priv_len); diff --git a/net/core/dev.c b/net/core/dev.c index 8f4dead64284..d3d0680664b3 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6221,7 +6221,7 @@ bool napi_complete_done(struct napi_struct *n, int wo= rk_done) if (work_done) { if (n->gro_bitmask) timeout =3D READ_ONCE(n->dev->gro_flush_timeout); - n->defer_hard_irqs_count =3D READ_ONCE(n->dev->napi_defer_hard_irqs); + n->defer_hard_irqs_count =3D napi_get_defer_hard_irqs(n); } if (n->defer_hard_irqs_count > 0) { n->defer_hard_irqs_count--; @@ -6359,7 +6359,7 @@ static void busy_poll_stop(struct napi_struct *napi, = void *have_poll_lock, bpf_net_ctx =3D bpf_net_ctx_set(&__bpf_net_ctx); =20 if (flags & NAPI_F_PREFER_BUSY_POLL) { - napi->defer_hard_irqs_count =3D READ_ONCE(napi->dev->napi_defer_hard_irq= s); + napi->defer_hard_irqs_count =3D napi_get_defer_hard_irqs(napi); timeout =3D READ_ONCE(napi->dev->gro_flush_timeout); if (napi->defer_hard_irqs_count && timeout) { hrtimer_start(&napi->timer, ns_to_ktime(timeout), HRTIMER_MODE_REL_PINN= ED); @@ -6641,6 +6641,7 @@ void netif_napi_add_weight(struct net_device *dev, st= ruct napi_struct *napi, INIT_HLIST_NODE(&napi->napi_hash_node); hrtimer_init(&napi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED); napi->timer.function =3D napi_watchdog; + napi_set_defer_hard_irqs(napi, READ_ONCE(dev->napi_defer_hard_irqs)); init_gro_hash(napi); napi->skb =3D NULL; INIT_LIST_HEAD(&napi->rx_list); @@ -11023,7 +11024,7 @@ void netdev_sw_irq_coalesce_default_on(struct net_d= evice *dev) =20 if (!IS_ENABLED(CONFIG_PREEMPT_RT)) { dev->gro_flush_timeout =3D 20000; - dev->napi_defer_hard_irqs =3D 1; + netdev_set_defer_hard_irqs(dev, 1); } } EXPORT_SYMBOL_GPL(netdev_sw_irq_coalesce_default_on); @@ -11960,7 +11961,6 @@ static void __init net_dev_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, real= _num_rx_queues); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, _rx); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, gro_= flush_timeout); - CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, napi= _defer_hard_irqs); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, gro_= max_size); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, gro_= ipv4_max_size); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, rx_h= andler); @@ -11972,7 +11972,7 @@ static void __init net_dev_struct_check(void) #ifdef CONFIG_NET_XGRESS CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, tcx_= ingress); #endif - CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_rx, 104); + CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_rx, 100); } =20 /* diff --git a/net/core/dev.h b/net/core/dev.h index 5654325c5b71..f24fa38a2cac 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -138,6 +138,42 @@ static inline void netif_set_gro_ipv4_max_size(struct = net_device *dev, WRITE_ONCE(dev->gro_ipv4_max_size, size); } =20 +/** + * napi_get_defer_hard_irqs - get the NAPI's defer_hard_irqs + * @n: napi struct to get the defer_hard_irqs field from + * + * Return: the per-NAPI value of the defar_hard_irqs field. + */ +static inline u32 napi_get_defer_hard_irqs(const struct napi_struct *n) +{ + return READ_ONCE(n->defer_hard_irqs); +} + +/** + * napi_set_defer_hard_irqs - set the defer_hard_irqs for a napi + * @n: napi_struct to set the defer_hard_irqs field + * @defer: the value the field should be set to + */ +static inline void napi_set_defer_hard_irqs(struct napi_struct *n, u32 def= er) +{ + WRITE_ONCE(n->defer_hard_irqs, defer); +} + +/** + * netdev_set_defer_hard_irqs - set defer_hard_irqs for all NAPIs of a net= dev + * @netdev: the net_device for which all NAPIs will have their defer_hard_= irqs set + * @defer: the defer_hard_irqs value to set + */ +static inline void netdev_set_defer_hard_irqs(struct net_device *netdev, + u32 defer) +{ + struct napi_struct *napi; + + WRITE_ONCE(netdev->napi_defer_hard_irqs, defer); + list_for_each_entry(napi, &netdev->napi_list, dev_list) + napi_set_defer_hard_irqs(napi, defer); +} + int rps_cpumask_housekeeping(struct cpumask *mask); =20 #if defined(CONFIG_DEBUG_NET) && defined(CONFIG_BPF_SYSCALL) diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 05cf5347f25e..25125f356a15 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -429,7 +429,7 @@ static int change_napi_defer_hard_irqs(struct net_devic= e *dev, unsigned long val if (val > S32_MAX) return -ERANGE; =20 - WRITE_ONCE(dev->napi_defer_hard_irqs, val); + netdev_set_defer_hard_irqs(dev, (u32)val); return 0; } =20 --=20 2.25.1 From nobody Sat Nov 30 04:40:47 2024 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB7BA1A00C5 for ; Thu, 12 Sep 2024 10:08:14 +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=1726135696; cv=none; b=eF5Wd2lHjx4Lr8FNuws0fji4ptegz8hwybcEszdENjla+BXvvBhBi9yk69ErpD/LZa6duQDXyeWcW9lx1SgLPeSHvoRZmd5bJi/ADK9MJx81RVLU2bguW5bt/5nd5gkLtjkX5XlGtqh+Lbp5nlnwtrcqDTlHZW9yJgdm84LpVNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726135696; c=relaxed/simple; bh=bGa4PmJzGB9kewoC30T211UZN3HCaTEaFMhaE0IBKR4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ux8zV+Ds3d+N7uwribCkvt+0AyMO+BVfuaRL0Z45eiTV3hYqiMfVFFcQIwmFfnlPA4syue+jKQwFozKerwKDQCRGXSscsoxxRLD8bRd4Dpno6Fl4p3p+Ny8gZCmnjQPvzmb+Y4aKFJss7ONM/bQFzKgnokZN32oxAl+DpbtpiS8= 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=gLcnY742; 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="gLcnY742" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-20570b42f24so9058545ad.1 for ; Thu, 12 Sep 2024 03:08:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1726135694; x=1726740494; 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=N1ZQwn8/7gDdmGCiwR/rNIphJ/ao5OLIORUttbLlJdI=; b=gLcnY742FGT5T5YaEU8pnPyxGguQGytoHSi64lGn0tVv3yNQyH1sJa6b6BYOKUAgKx KhUfNlUUDlZJgkKWnQcNqxwaxkQJBL3iCIxd2K/xGYdXXx5jYJGkz5y2ep7qoVIJnmZp 7AtjL9NUQRAa21gwNHhyLbu6IzQJ8g6y2Krag= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726135694; x=1726740494; 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=N1ZQwn8/7gDdmGCiwR/rNIphJ/ao5OLIORUttbLlJdI=; b=rSvqeL5CJfqM7YDhkYuqZvaYjnl/Lm5WFP/BuduGl6Ns9Vq2uUYb4Rs1h0B74mBjaV ZbLk11OqlYLyT0nQz/othvoxIxi1BQY3JaNIedP9KcYY8zESWgGneDH8GY36dqbNg/ic AoIauUn6cSkYUp5LVAJ9lOQURRRPrB/zEHEJvP/MXXGJLZ4fxWmKc74BPq4t4Gl8YpkM qqZ3I/goPNKH0IRLaDaCiojxEmTVR+ru0mLe+upMqe/Q0WnNYwNfmqMBMr0MNOdBQ7DA wKSX7vfGyZ/O53Rws2CxCBO5CsjpeFbO6a8NJ9xiba+O631mafEEI0F4ti+cRQFTDrZW wyRg== X-Forwarded-Encrypted: i=1; AJvYcCUDEzgQzPHrq4w0Ia/mRSHm8czHEL1R7VeuyrjXs2IGZeYoLlD0Az1AylibirRF5LVNu+nvrJF3bIMoAvE=@vger.kernel.org X-Gm-Message-State: AOJu0Yzh/r5Viir1lAorKJ9lFtL2ytyoQXsGxNIUKlEpxC3xAY+waKJc WASWisEoUNtYx1V5NHgRu3jtS2xLEkM6m0D/5TZBY7MeMv9LqnCC65i4OqvLT4k= X-Google-Smtp-Source: AGHT+IGzJodF6HLtBaNWh2wOCh15vOg4b928UX54k0lGLfWvsqPi1igaQRhJqO8yUSbA4RsaQPk/wA== X-Received: by 2002:a17:902:db01:b0:205:410c:f3c2 with SMTP id d9443c01a7336-2076e3f8983mr35469005ad.41.1726135694147; Thu, 12 Sep 2024 03:08:14 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2076afe9da3sm11583795ad.239.2024.09.12.03.08.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 03:08:13 -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 , Daniel Jurgens , linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v3 2/9] netdev-genl: Dump napi_defer_hard_irqs Date: Thu, 12 Sep 2024 10:07:10 +0000 Message-Id: <20240912100738.16567-3-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240912100738.16567-1-jdamato@fastly.com> References: <20240912100738.16567-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Support dumping defer_hard_irqs for a NAPI ID. Signed-off-by: Joe Damato --- Documentation/netlink/specs/netdev.yaml | 8 ++++++++ include/uapi/linux/netdev.h | 1 + net/core/netdev-genl.c | 5 +++++ tools/include/uapi/linux/netdev.h | 1 + 4 files changed, 15 insertions(+) diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlin= k/specs/netdev.yaml index 959755be4d7f..351d93994a66 100644 --- a/Documentation/netlink/specs/netdev.yaml +++ b/Documentation/netlink/specs/netdev.yaml @@ -244,6 +244,13 @@ attribute-sets: threaded mode. If NAPI is not in threaded mode (i.e. uses nor= mal softirq context), the attribute will be absent. type: u32 + - + name: defer-hard-irqs + doc: The number of consecutive empty polls before IRQ deferral ends + and hardware IRQs are re-enabled. + type: u32 + checks: + max: s32-max - name: queue attributes: @@ -593,6 +600,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 43742ac5b00d..43bb1aad9611 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_DEFER_HARD_IRQS, =20 __NETDEV_A_NAPI_MAX, NETDEV_A_NAPI_MAX =3D (__NETDEV_A_NAPI_MAX - 1) diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c index a17d7eaeb001..e67918dd97be 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) { + u32 napi_defer_hard_irqs; void *hdr; pid_t pid; =20 @@ -188,6 +189,10 @@ netdev_nl_napi_fill_one(struct sk_buff *rsp, struct na= pi_struct *napi, goto nla_put_failure; } =20 + napi_defer_hard_irqs =3D napi_get_defer_hard_irqs(napi); + if (nla_put_s32(rsp, NETDEV_A_NAPI_DEFER_HARD_IRQS, napi_defer_hard_irqs)) + goto nla_put_failure; + genlmsg_end(rsp, hdr); =20 return 0; diff --git a/tools/include/uapi/linux/netdev.h b/tools/include/uapi/linux/n= etdev.h index 43742ac5b00d..43bb1aad9611 100644 --- a/tools/include/uapi/linux/netdev.h +++ b/tools/include/uapi/linux/netdev.h @@ -121,6 +121,7 @@ enum { NETDEV_A_NAPI_ID, NETDEV_A_NAPI_IRQ, NETDEV_A_NAPI_PID, + NETDEV_A_NAPI_DEFER_HARD_IRQS, =20 __NETDEV_A_NAPI_MAX, NETDEV_A_NAPI_MAX =3D (__NETDEV_A_NAPI_MAX - 1) --=20 2.25.1 From nobody Sat Nov 30 04:40:47 2024 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8B1A1A00C5 for ; Thu, 12 Sep 2024 10:08:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726135701; cv=none; b=PuqO0vNhwZek3c+Z0minmLcQtlX+EXGidce8WZYBH/Xi60A5rYH3Y8aLJ4nPGlRNEHpVVcB4awz5L36/YxQA2S0M83hiB1OLItAZ4o52ziVqJzowb/qp8J4Nzxb0p7eoArSu/F9KQ6OrWajc+146yCylW5W6AuTdNaE9V/5dwMo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726135701; c=relaxed/simple; bh=UYFHT5Rtrjp2TbS7AQ5vsSkVHNaJO8WMKD93eugQvpY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MSla0KXN5Rxdt1eJBtYRX/9kZLAKlnkdgp9y76lPvBl8tZ/FxXfK+waLVNj54BrdMpxirFZW8avpy9qsgJ/OhU7bhrw/XxoFByhB/3ltnFN7H5jlcPAk9eEWFn1iTHq+E27+njs9DD+fhJwA6Ot30xku/is0phsXZY6ODjEG0+Q= 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=xGuyByfZ; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="xGuyByfZ" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-205659dc63aso8808715ad.1 for ; Thu, 12 Sep 2024 03:08:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1726135699; x=1726740499; 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=YerXYBbzlInpcAAkn5hrMa1T09WgrIl+NF/PwzLH+gI=; b=xGuyByfZka6UvNEfSJ63Mxl/HRy8jWaYHiP+lZzQsTPs/nMt+OnzLSNo58/2vn8flu nyhoJ7DnXv5jzhOpqt6LwiLTucKX86Vx3UlIsnYvo1qD2r1M/Kf8HKAKtWzCfVNM3InD LZ4cPKWuQifGj1jN4nufG3qn1oaLjnboV62jQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726135699; x=1726740499; 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=YerXYBbzlInpcAAkn5hrMa1T09WgrIl+NF/PwzLH+gI=; b=KIDtttzK5o4S0WQpkKpJQVTl9nOqX1n/vbX7hxujhaHt7jGAU511f/C0OlhGEKyYcV 5EtiL6MRg1TLSCvaVf41TqoUNZ86Vus97Ontg35l8C/YqgkpR9EdpZ2IiRwGYq/KGT5A qKKRXL5o5+aa4gTDtesWGPfUvxukq3M4mzdbKql6BJu642TQHXc/LwmHXNlqTCGcEall RhderSbBxZzvGY7JIYcV/h//Dz3Dov8AIOMaY7R/iACU6xxQHWb/PZwKQk/OwYkXcoiq gM5iykAfqAd5y+3Mw5lcLDy4E5HFDx38L0GRgn8jBYKjZE8rsk3thzIQ5bp0+g1cb2F4 daXw== X-Forwarded-Encrypted: i=1; AJvYcCXTtLPptOakHRPaqXmB9w4uRvGe7G9v/DrUIGmLYreiKUTEj6cN9kE8m9cIePfc4D5S4QqfRD93okP/Tjc=@vger.kernel.org X-Gm-Message-State: AOJu0YwRKFGGejwIdS3gDAQ8dRCw0TN7TL7PKRXuisDNPYIj93tXsGnJ B1XRRUwsWVC8hSjeSSB/tpSPLqGs1Y14XVtourEXTWyyaJCuNApYhfEdqEyPhR0= X-Google-Smtp-Source: AGHT+IForQeMfGb0GCdvRNabl/PACHbWLROiaNCpFz1nTSKb8kGS4noXiMmFQIaSiz28x7rm1JGmYw== X-Received: by 2002:a17:902:c943:b0:203:a0ea:63c5 with SMTP id d9443c01a7336-2076d71ada8mr29329145ad.0.1726135698853; Thu, 12 Sep 2024 03:08:18 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2076afe9da3sm11583795ad.239.2024.09.12.03.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 03:08:18 -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 , 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 v3 3/9] net: napi: Make gro_flush_timeout per-NAPI Date: Thu, 12 Sep 2024 10:07:11 +0000 Message-Id: <20240912100738.16567-4-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240912100738.16567-1-jdamato@fastly.com> References: <20240912100738.16567-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allow per-NAPI gro_flush_timeout setting. The existing sysfs parameter is respected; writes to sysfs will write to all NAPI structs for the device and the net_device gro_flush_timeout field. Reads from sysfs will read from the net_device field. The ability to set gro_flush_timeout on specific NAPI instances will be added in a later commit, via netdev-genl. Signed-off-by: Joe Damato --- .../networking/net_cachelines/net_device.rst | 2 +- include/linux/netdevice.h | 3 +- net/core/dev.c | 12 +++--- net/core/dev.h | 39 +++++++++++++++++++ net/core/net-sysfs.c | 2 +- 5 files changed, 49 insertions(+), 9 deletions(-) diff --git a/Documentation/networking/net_cachelines/net_device.rst b/Docum= entation/networking/net_cachelines/net_device.rst index eeeb7c925ec5..3d02ae79c850 100644 --- a/Documentation/networking/net_cachelines/net_device.rst +++ b/Documentation/networking/net_cachelines/net_device.rst @@ -98,7 +98,6 @@ struct_netdev_queue* _rx = read_mostly unsigned_int num_rx_queues = =20 unsigned_int real_num_rx_queues - = read_mostly get_rps_cpu struct_bpf_prog* xdp_prog - = read_mostly netif_elide_gro() -unsigned_long gro_flush_timeout - = read_mostly napi_complete_done unsigned_int gro_max_size - = read_mostly skb_gro_receive unsigned_int gro_ipv4_max_size - = read_mostly skb_gro_receive rx_handler_func_t* rx_handler read_mostly = - __netif_receive_skb_core @@ -182,4 +181,5 @@ struct_devlink_port* devlink_port struct_dpll_pin* dpll_pin = =20 struct hlist_head page_pools struct dim_irq_moder* irq_moder +unsigned_long gro_flush_timeout u32 napi_defer_hard_irqs diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index f28b96c95259..3e07ab8e0295 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -377,6 +377,7 @@ struct napi_struct { struct list_head dev_list; struct hlist_node napi_hash_node; int irq; + unsigned long gro_flush_timeout; u32 defer_hard_irqs; }; =20 @@ -2075,7 +2076,6 @@ struct net_device { int ifindex; unsigned int real_num_rx_queues; struct netdev_rx_queue *_rx; - unsigned long gro_flush_timeout; unsigned int gro_max_size; unsigned int gro_ipv4_max_size; rx_handler_func_t __rcu *rx_handler; @@ -2398,6 +2398,7 @@ struct net_device { =20 /** @irq_moder: dim parameters used if IS_ENABLED(CONFIG_DIMLIB). */ struct dim_irq_moder *irq_moder; + unsigned long gro_flush_timeout; u32 napi_defer_hard_irqs; =20 u8 priv[] ____cacheline_aligned diff --git a/net/core/dev.c b/net/core/dev.c index d3d0680664b3..f2fd503516de 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6220,12 +6220,12 @@ bool napi_complete_done(struct napi_struct *n, int = work_done) =20 if (work_done) { if (n->gro_bitmask) - timeout =3D READ_ONCE(n->dev->gro_flush_timeout); + timeout =3D napi_get_gro_flush_timeout(n); n->defer_hard_irqs_count =3D napi_get_defer_hard_irqs(n); } if (n->defer_hard_irqs_count > 0) { n->defer_hard_irqs_count--; - timeout =3D READ_ONCE(n->dev->gro_flush_timeout); + timeout =3D napi_get_gro_flush_timeout(n); if (timeout) ret =3D false; } @@ -6360,7 +6360,7 @@ static void busy_poll_stop(struct napi_struct *napi, = void *have_poll_lock, =20 if (flags & NAPI_F_PREFER_BUSY_POLL) { napi->defer_hard_irqs_count =3D napi_get_defer_hard_irqs(napi); - timeout =3D READ_ONCE(napi->dev->gro_flush_timeout); + timeout =3D napi_get_gro_flush_timeout(napi); if (napi->defer_hard_irqs_count && timeout) { hrtimer_start(&napi->timer, ns_to_ktime(timeout), HRTIMER_MODE_REL_PINN= ED); skip_schedule =3D true; @@ -6642,6 +6642,7 @@ void netif_napi_add_weight(struct net_device *dev, st= ruct napi_struct *napi, hrtimer_init(&napi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED); napi->timer.function =3D napi_watchdog; napi_set_defer_hard_irqs(napi, READ_ONCE(dev->napi_defer_hard_irqs)); + napi_set_gro_flush_timeout(napi, READ_ONCE(dev->gro_flush_timeout)); init_gro_hash(napi); napi->skb =3D NULL; INIT_LIST_HEAD(&napi->rx_list); @@ -11023,7 +11024,7 @@ void netdev_sw_irq_coalesce_default_on(struct net_d= evice *dev) WARN_ON(dev->reg_state =3D=3D NETREG_REGISTERED); =20 if (!IS_ENABLED(CONFIG_PREEMPT_RT)) { - dev->gro_flush_timeout =3D 20000; + netdev_set_gro_flush_timeout(dev, 20000); netdev_set_defer_hard_irqs(dev, 1); } } @@ -11960,7 +11961,6 @@ static void __init net_dev_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, ifin= dex); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, real= _num_rx_queues); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, _rx); - CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, gro_= flush_timeout); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, gro_= max_size); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, gro_= ipv4_max_size); CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, rx_h= andler); @@ -11972,7 +11972,7 @@ static void __init net_dev_struct_check(void) #ifdef CONFIG_NET_XGRESS CACHELINE_ASSERT_GROUP_MEMBER(struct net_device, net_device_read_rx, tcx_= ingress); #endif - CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_rx, 100); + CACHELINE_ASSERT_GROUP_SIZE(struct net_device, net_device_read_rx, 92); } =20 /* diff --git a/net/core/dev.h b/net/core/dev.h index f24fa38a2cac..a9d5f678564a 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -174,6 +174,45 @@ static inline void netdev_set_defer_hard_irqs(struct n= et_device *netdev, napi_set_defer_hard_irqs(napi, defer); } =20 +/** + * napi_get_gro_flush_timeout - get the gro_flush_timeout + * @n: napi struct to get the gro_flush_timeout from + * + * Return: the per-NAPI value of the gro_flush_timeout field. + */ +static inline unsigned long napi_get_gro_flush_timeout(const struct napi_s= truct *n) +{ + 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 for all NAPIs of a= netdev + * @netdev: the net_device for which all NAPIs will have their gro_flush_t= imeout set + * @timeout: the timeout value to set + */ +static inline void netdev_set_gro_flush_timeout(struct net_device *netdev, + unsigned long timeout) +{ + struct napi_struct *napi; + + WRITE_ONCE(netdev->gro_flush_timeout, timeout); + list_for_each_entry(napi, &netdev->napi_list, dev_list) + napi_set_gro_flush_timeout(napi, timeout); +} + int rps_cpumask_housekeeping(struct cpumask *mask); =20 #if defined(CONFIG_DEBUG_NET) && defined(CONFIG_BPF_SYSCALL) diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 25125f356a15..2d9afc6e2161 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -409,7 +409,7 @@ NETDEVICE_SHOW_RW(tx_queue_len, fmt_dec); =20 static int change_gro_flush_timeout(struct net_device *dev, unsigned long = val) { - WRITE_ONCE(dev->gro_flush_timeout, val); + netdev_set_gro_flush_timeout(dev, val); return 0; } =20 --=20 2.25.1 From nobody Sat Nov 30 04:40:47 2024 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 712401A2638 for ; Thu, 12 Sep 2024 10:08:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726135705; cv=none; b=d7W0RLdt1eYkoxv/fiC+DWC34hqhE+Gqhop0d1G5/37T8IDQlo6/1uomYxHCxrqh3roGhpuVKn2ZnRfA4+Dq+ehDLnFZmiheVkC7K7WV5/itzwLWAL4TBpJ251o8X+hRpmQUT60jhACqWKREEV0CYCXQItMP+5iiQCII11X/57I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726135705; c=relaxed/simple; bh=7X1uADLZjCrWywAb/T3yUw6fZRd1yFFwvpgWf8s8fGc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Pws9gw4AdVO6hFBHUB191cbzvIwGgiv9XaUuHWWkecKLEXkP0SLMr4YzyN37snowsarJjfmjfhOYT+fO3DBKs5+5Gzp4wjQ6GO0hbI9t9LdLhXmhvg/4+KN/Nm2oKBpexODzeiKkrdfPanGrc8fYRhJLq+OETF3JvoRm22IbXAA= 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=L2JOs6KX; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="L2JOs6KX" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-206f9b872b2so8435685ad.3 for ; Thu, 12 Sep 2024 03:08:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1726135704; x=1726740504; 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=BVBE7Pm7Q5s8a6rlCB82bDuJ6/NcBLKBqVzG1T0Sd1Q=; b=L2JOs6KXQbMcwd+3KU8DSQ8IXiDnR+rAznRALbxZLFOXTM9DJoFj0/5wyYf2Yio0uQ 5NUyO4HoBHiau8g84seNfzTVQi7kXno6HcJX2hooNi4Sr8ztKpZDYvRSRqk3GmSwR5oY uUBCebYUw0J8gKqh8lwpj2zvVo+EAAP96E4P0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726135704; x=1726740504; 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=BVBE7Pm7Q5s8a6rlCB82bDuJ6/NcBLKBqVzG1T0Sd1Q=; b=MwZuDudYjT28qre5Qpsqu8zJXPqCL5OeAgK52bKpa3SPVRjQ3SHBbRM9I7NPdf+5yz WnlSXC99Qxe00fhZPxmrtz2ZUV0fNvKnsugUHNaor9VPTMd9GltwM167Yf3H8/b34OQN NZC3ttP2rxWnDnJBjL5zoQEeXHAMlEX5yBPgdgw4G0CHiMmm2SccbuC9riUPNao4XSmb YC3lHYOGeO0Ok1x1Z0tjNIyJdgxyJNagGbxWBelodOlnWLOn6cRVNh5VteiucEbSpmKF zNRedH4uiXbIow+sCnvuBo+6F68CZdZrRe66fVX+VU51E+4RLw5ZGiXKmVrMfMzIeLug aj8Q== X-Forwarded-Encrypted: i=1; AJvYcCVBn7It0DBv2QU6umQizNeSEfpbD0h14eoVpqf+ARtQFXKKQP1hydMFd/E0nE2bcaKHdePe79n9NwM8FDg=@vger.kernel.org X-Gm-Message-State: AOJu0YzBOXyMepXSWfY4HP2WHbE/hM8MAZqyfnyIMBUhKcH5TDVdajo9 WPuxGzHRRrK9MpskisyjsxzrTd1FS1GGd1d3EYJpdImnof7zk1Nj9BWlN1mddBQ= X-Google-Smtp-Source: AGHT+IEVKBtDLy6qE1gRasnURzcTt8OTaL/9OrC0QY5wEcDhluu8jE5lROOeLxmdOJQ4ZTZ/UCI/vw== X-Received: by 2002:a17:902:e94e:b0:1fd:aac9:a72e with SMTP id d9443c01a7336-2076e461637mr31643635ad.43.1726135703805; Thu, 12 Sep 2024 03:08:23 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2076afe9da3sm11583795ad.239.2024.09.12.03.08.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 03:08:22 -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 v3 4/9] netdev-genl: Dump gro_flush_timeout Date: Thu, 12 Sep 2024 10:07:12 +0000 Message-Id: <20240912100738.16567-5-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240912100738.16567-1-jdamato@fastly.com> References: <20240912100738.16567-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Support dumping gro_flush_timeout for a NAPI ID. Signed-off-by: Joe Damato --- Documentation/netlink/specs/netdev.yaml | 6 ++++++ include/uapi/linux/netdev.h | 1 + net/core/netdev-genl.c | 5 +++++ tools/include/uapi/linux/netdev.h | 1 + 4 files changed, 13 insertions(+) diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlin= k/specs/netdev.yaml index 351d93994a66..906091c3059a 100644 --- a/Documentation/netlink/specs/netdev.yaml +++ b/Documentation/netlink/specs/netdev.yaml @@ -251,6 +251,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: @@ -601,6 +606,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 43bb1aad9611..b088a34e9254 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_DEFER_HARD_IRQS, + NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT, =20 __NETDEV_A_NAPI_MAX, NETDEV_A_NAPI_MAX =3D (__NETDEV_A_NAPI_MAX - 1) diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c index e67918dd97be..4698034b5a49 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) { + unsigned long gro_flush_timeout; u32 napi_defer_hard_irqs; void *hdr; pid_t pid; @@ -193,6 +194,10 @@ netdev_nl_napi_fill_one(struct sk_buff *rsp, struct na= pi_struct *napi, if (nla_put_s32(rsp, NETDEV_A_NAPI_DEFER_HARD_IRQS, napi_defer_hard_irqs)) goto nla_put_failure; =20 + gro_flush_timeout =3D napi_get_gro_flush_timeout(napi); + if (nla_put_uint(rsp, NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT, gro_flush_timeout)) + goto nla_put_failure; + genlmsg_end(rsp, hdr); =20 return 0; diff --git a/tools/include/uapi/linux/netdev.h b/tools/include/uapi/linux/n= etdev.h index 43bb1aad9611..b088a34e9254 100644 --- a/tools/include/uapi/linux/netdev.h +++ b/tools/include/uapi/linux/netdev.h @@ -122,6 +122,7 @@ enum { NETDEV_A_NAPI_IRQ, NETDEV_A_NAPI_PID, NETDEV_A_NAPI_DEFER_HARD_IRQS, + NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT, =20 __NETDEV_A_NAPI_MAX, NETDEV_A_NAPI_MAX =3D (__NETDEV_A_NAPI_MAX - 1) --=20 2.25.1 From nobody Sat Nov 30 04:40:47 2024 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 935551A2876 for ; Thu, 12 Sep 2024 10:08:28 +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=1726135710; cv=none; b=B4OcpC+aR/tnlnp/NfdGMjwr86EGKrFJi6ZyTgAuu2fERGYIYXYmLvK/Qmzyx2IY9tqOGqWW5kqLAGGy9V7XP5k2KrVW9QtlShIB9B7pnDc1rDGW8Le9Zp3aVpGgWTZ7GpN9qRgbNlUas6osNUyjIaFsMRgz5q7jQwLwZ7p2S74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726135710; c=relaxed/simple; bh=5139h/vAdKZH/+hDF4LGpoq5rzZ4VB7cmq7cSonzbF4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sLkd0bgOEFaRYNA+HQ9lo2mxfGD2cpir7Jd6EBOzJYQ+hFa0ukXAy78G6R+Y2CaGd6oc7FFU+Py/eqC86kX5rraOh/1lH2a/Geu1SbukEElidLm6a4kjEpGoExuWt8tw66xAZfoSGMil1z1NNcOWLo3Kw86jXMTpumY+eu9wqu4= 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=v31dPbir; 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="v31dPbir" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-20551e2f1f8so8236305ad.2 for ; Thu, 12 Sep 2024 03:08:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1726135708; x=1726740508; 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=fuCU47ydUGB46V/ndRRnE6AYBHpF+SD0efezkXvrbTk=; b=v31dPbirvwABJYZzxag5gCjSrdRjmXQfLVRpqxQ0akMq/Su+Ia2zxOFJjCXLqOTxI6 zZNujkb+p3xSl6Cu0VYDR0nqTeC4THK/uXueH8GVKWR0y6ohNHeyS/5X+mIV3toiLSU7 X1y40IbSD2TR+fiPe5cnF8qpmRiacLvxRQhWw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726135708; x=1726740508; 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=fuCU47ydUGB46V/ndRRnE6AYBHpF+SD0efezkXvrbTk=; b=Dw6q51W+omFVzX93zE8m+cGKO1muk0iwg39WrszUqBeyIzpKZNVqKvnahd96q/X4s7 v6ZwpwX+JBd8/aTJIg1HeWTe9x0y03XMD2Duk89sdph7ZWxW/4NnUkTuOYBY+hKbVI9t HazWQ+nU4lJTytVQ1eedeitGdDW90Pu31uUwk1KsUY7IPqMM4zTxszdAANLQP37A+/F3 t25QlWpZ+KN300He078BEIL2cnLr7GJ3LyRnha948oeFB+ChKq/L3wI/ej9qDhjd5aoN 42Zpqv0Ls+XF4CzOTBptk9GiM4nUPq1MHRWRoKNPUl5cUBBupu1ZBp/NKooJBgvO2lo/ ge6g== X-Forwarded-Encrypted: i=1; AJvYcCUDi5jqs8MYqNJTgAe8KflJj6PtNS9H9e0oRCY9W09qcmVAOF8yu6oqh0GNyC3Qf1fWuhPJ79Uty3h9KQM=@vger.kernel.org X-Gm-Message-State: AOJu0Yxh5CB+GJPNiQoWSB4Lt/rKm/Nov9oMukiSQqAM9tqDRdG3lfIJ ZRE4LYKWdzBt5Wh2VwxIV7rOdQjPqdCXkZAf486OncXSH1SwWHAjdkFKtkqc4YxDEPzsliy9xG6 Nwiw= X-Google-Smtp-Source: AGHT+IFcb8zMj6HbZ7uiJi9b+LJKIWJQoRMly1GMxYKLr2MRNBXzWLfzWLRfmYBY2BPTmecCsd3Row== X-Received: by 2002:a17:903:2302:b0:207:20c5:42c with SMTP id d9443c01a7336-2076e40be2dmr38709985ad.45.1726135707779; Thu, 12 Sep 2024 03:08:27 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2076afe9da3sm11583795ad.239.2024.09.12.03.08.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 03:08:27 -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 , linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v3 5/9] net: napi: Add napi_config Date: Thu, 12 Sep 2024 10:07:13 +0000 Message-Id: <20240912100738.16567-6-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240912100738.16567-1-jdamato@fastly.com> References: <20240912100738.16567-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a persistent NAPI config area for NAPI configuration to the core. Drivers opt-in to setting the storage for a NAPI by passing an index when calling netif_napi_add_storage. napi_config is allocated in alloc_netdev_mqs, freed in free_netdev (after the NAPIs are deleted), and set to 0 when napi_enable is called. Drivers which implement call netif_napi_add_storage will have persistent NAPI IDs. Signed-off-by: Joe Damato --- .../networking/net_cachelines/net_device.rst | 1 + include/linux/netdevice.h | 34 +++++++++ net/core/dev.c | 74 +++++++++++++++++-- net/core/dev.h | 12 +++ 4 files changed, 113 insertions(+), 8 deletions(-) diff --git a/Documentation/networking/net_cachelines/net_device.rst b/Docum= entation/networking/net_cachelines/net_device.rst index 3d02ae79c850..11d659051f5e 100644 --- a/Documentation/networking/net_cachelines/net_device.rst +++ b/Documentation/networking/net_cachelines/net_device.rst @@ -183,3 +183,4 @@ struct hlist_head page_pools struct dim_irq_moder* irq_moder unsigned_long gro_flush_timeout u32 napi_defer_hard_irqs +struct napi_config* napi_config diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 3e07ab8e0295..08afc96179f9 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -342,6 +342,15 @@ struct gro_list { */ #define GRO_HASH_BUCKETS 8 =20 +/* + * Structure for per-NAPI storage + */ +struct napi_config { + u64 gro_flush_timeout; + u32 defer_hard_irqs; + unsigned int napi_id; +}; + /* * Structure for NAPI scheduling similar to tasklet but with weighting */ @@ -379,6 +388,8 @@ struct napi_struct { int irq; unsigned long gro_flush_timeout; u32 defer_hard_irqs; + int index; + struct napi_config *config; }; =20 enum { @@ -2011,6 +2022,9 @@ enum netdev_reg_state { * @dpll_pin: Pointer to the SyncE source pin of a DPLL subsystem, * where the clock is recovered. * + * @napi_config: An array of napi_config structures containing per-NAPI + * settings. + * * FIXME: cleanup struct net_device such that network protocol info * moves out. */ @@ -2400,6 +2414,7 @@ struct net_device { struct dim_irq_moder *irq_moder; unsigned long gro_flush_timeout; u32 napi_defer_hard_irqs; + struct napi_config *napi_config; =20 u8 priv[] ____cacheline_aligned __counted_by(priv_len); @@ -2650,6 +2665,23 @@ netif_napi_add_tx_weight(struct net_device *dev, netif_napi_add_weight(dev, napi, poll, weight); } =20 +/** + * netif_napi_add_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 index) +{ + napi->index =3D index; + napi->config =3D &dev->napi_config[index]; + netif_napi_add_weight(dev, napi, poll, NAPI_POLL_WEIGHT); +} + /** * netif_napi_add_tx() - initialize a NAPI context to be used for Tx only * @dev: network device @@ -2685,6 +2717,8 @@ void __netif_napi_del(struct napi_struct *napi); */ static inline void netif_napi_del(struct napi_struct *napi) { + napi->config =3D NULL; + napi->index =3D -1; __netif_napi_del(napi); synchronize_net(); } diff --git a/net/core/dev.c b/net/core/dev.c index f2fd503516de..ca2227d0b8ed 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6493,6 +6493,18 @@ EXPORT_SYMBOL(napi_busy_loop); =20 #endif /* CONFIG_NET_RX_BUSY_POLL */ =20 +static void napi_hash_add_with_id(struct napi_struct *napi, unsigned int n= api_id) +{ + spin_lock(&napi_hash_lock); + + napi->napi_id =3D napi_id; + + hlist_add_head_rcu(&napi->napi_hash_node, + &napi_hash[napi->napi_id % HASH_SIZE(napi_hash)]); + + spin_unlock(&napi_hash_lock); +} + static void napi_hash_add(struct napi_struct *napi) { if (test_bit(NAPI_STATE_NO_BUSY_POLL, &napi->state)) @@ -6505,12 +6517,13 @@ static void napi_hash_add(struct napi_struct *napi) if (unlikely(++napi_gen_id < MIN_NAPI_ID)) napi_gen_id =3D MIN_NAPI_ID; } while (napi_by_id(napi_gen_id)); - napi->napi_id =3D napi_gen_id; - - hlist_add_head_rcu(&napi->napi_hash_node, - &napi_hash[napi->napi_id % HASH_SIZE(napi_hash)]); =20 spin_unlock(&napi_hash_lock); + + napi_hash_add_with_id(napi, napi_gen_id); + + if (napi->config) + napi->config->napi_id =3D napi_gen_id; } =20 /* Warning : caller is responsible to make sure rcu grace period @@ -6631,6 +6644,21 @@ void netif_queue_set_napi(struct net_device *dev, un= signed int queue_index, } EXPORT_SYMBOL(netif_queue_set_napi); =20 +static void napi_restore_config(struct napi_struct *n) +{ + n->defer_hard_irqs =3D n->config->defer_hard_irqs; + n->gro_flush_timeout =3D n->config->gro_flush_timeout; + napi_hash_add_with_id(n, n->config->napi_id); +} + +static void napi_save_config(struct napi_struct *n) +{ + n->config->defer_hard_irqs =3D n->defer_hard_irqs; + n->config->gro_flush_timeout =3D n->gro_flush_timeout; + n->config->napi_id =3D n->napi_id; + napi_hash_del(n); +} + void netif_napi_add_weight(struct net_device *dev, struct napi_struct *nap= i, int (*poll)(struct napi_struct *, int), int weight) { @@ -6641,8 +6669,6 @@ void netif_napi_add_weight(struct net_device *dev, st= ruct napi_struct *napi, INIT_HLIST_NODE(&napi->napi_hash_node); hrtimer_init(&napi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED); napi->timer.function =3D napi_watchdog; - napi_set_defer_hard_irqs(napi, READ_ONCE(dev->napi_defer_hard_irqs)); - napi_set_gro_flush_timeout(napi, READ_ONCE(dev->gro_flush_timeout)); init_gro_hash(napi); napi->skb =3D NULL; INIT_LIST_HEAD(&napi->rx_list); @@ -6660,7 +6686,15 @@ void netif_napi_add_weight(struct net_device *dev, s= truct napi_struct *napi, set_bit(NAPI_STATE_SCHED, &napi->state); set_bit(NAPI_STATE_NPSVC, &napi->state); list_add_rcu(&napi->dev_list, &dev->napi_list); - napi_hash_add(napi); + /* if there is no config associated with this NAPI, generate a fresh + * NAPI ID and hash it. Otherwise, settings will be restored in napi_enab= le. + */ + if (!napi->config || (napi->config && !napi->config->napi_id)) { + napi_hash_add(napi); + 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 @@ -6692,6 +6726,9 @@ void napi_disable(struct napi_struct *n) =20 hrtimer_cancel(&n->timer); =20 + if (n->config) + napi_save_config(n); + clear_bit(NAPI_STATE_DISABLE, &n->state); } EXPORT_SYMBOL(napi_disable); @@ -6714,6 +6751,9 @@ void napi_enable(struct napi_struct *n) if (n->dev->threaded && n->thread) new |=3D NAPIF_STATE_THREADED; } while (!try_cmpxchg(&n->state, &val, new)); + + if (n->config) + napi_restore_config(n); } EXPORT_SYMBOL(napi_enable); =20 @@ -6736,7 +6776,13 @@ void __netif_napi_del(struct napi_struct *napi) if (!test_and_clear_bit(NAPI_STATE_LISTED, &napi->state)) return; =20 - napi_hash_del(napi); + if (!napi->config) { + napi_hash_del(napi); + } else { + napi->index =3D -1; + napi->config =3D NULL; + } + list_del_rcu(&napi->dev_list); napi_free_frags(napi); =20 @@ -11049,6 +11095,8 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv= , const char *name, unsigned int txqs, unsigned int rxqs) { struct net_device *dev; + size_t napi_config_sz; + unsigned int maxqs; =20 BUG_ON(strlen(name) >=3D sizeof(dev->name)); =20 @@ -11062,6 +11110,9 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv= , const char *name, return NULL; } =20 + WARN_ON_ONCE(txqs !=3D rxqs); + maxqs =3D max(txqs, rxqs); + dev =3D kvzalloc(struct_size(dev, priv, sizeof_priv), GFP_KERNEL_ACCOUNT | __GFP_RETRY_MAYFAIL); if (!dev) @@ -11136,6 +11187,11 @@ struct net_device *alloc_netdev_mqs(int sizeof_pri= v, const char *name, if (!dev->ethtool) goto free_all; =20 + napi_config_sz =3D array_size(maxqs, sizeof(*dev->napi_config)); + dev->napi_config =3D kvzalloc(napi_config_sz, GFP_KERNEL_ACCOUNT); + if (!dev->napi_config) + goto free_all; + strscpy(dev->name, name); dev->name_assign_type =3D name_assign_type; dev->group =3D INIT_NETDEV_GROUP; @@ -11197,6 +11253,8 @@ void free_netdev(struct net_device *dev) list_for_each_entry_safe(p, n, &dev->napi_list, dev_list) netif_napi_del(p); =20 + kvfree(dev->napi_config); + ref_tracker_dir_exit(&dev->refcnt_tracker); #ifdef CONFIG_PCPU_DEV_REFCNT free_percpu(dev->pcpu_refcnt); diff --git a/net/core/dev.h b/net/core/dev.h index a9d5f678564a..9eb3f559275c 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -167,11 +167,17 @@ static inline void napi_set_defer_hard_irqs(struct na= pi_struct *n, u32 defer) static inline void netdev_set_defer_hard_irqs(struct net_device *netdev, u32 defer) { + unsigned int count =3D max(netdev->num_rx_queues, + netdev->num_tx_queues); struct napi_struct *napi; + int i; =20 WRITE_ONCE(netdev->napi_defer_hard_irqs, defer); list_for_each_entry(napi, &netdev->napi_list, dev_list) napi_set_defer_hard_irqs(napi, defer); + + for (i =3D 0; i < count; i++) + netdev->napi_config[i].defer_hard_irqs =3D defer; } =20 /** @@ -206,11 +212,17 @@ static inline void napi_set_gro_flush_timeout(struct = napi_struct *n, static inline void netdev_set_gro_flush_timeout(struct net_device *netdev, unsigned long timeout) { + unsigned int count =3D max(netdev->num_rx_queues, + netdev->num_tx_queues); struct napi_struct *napi; + int i; =20 WRITE_ONCE(netdev->gro_flush_timeout, timeout); list_for_each_entry(napi, &netdev->napi_list, dev_list) napi_set_gro_flush_timeout(napi, timeout); + + for (i =3D 0; i < count; i++) + netdev->napi_config[i].gro_flush_timeout =3D timeout; } =20 int rps_cpumask_housekeeping(struct cpumask *mask); --=20 2.25.1 From nobody Sat Nov 30 04:40:48 2024 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 098A01A3021 for ; Thu, 12 Sep 2024 10:08:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726135715; cv=none; b=oHBxCVgwgZeyRJhiPOeVA6WUs4Y/nIqvuxL+T8A+RftGbZ/1nwrFeYbbBPuJpvTVObrVBRBGBlmN62UIeLo0Dr9m1tm70oXlrEMElCx96FmF/CY7/6cd1eMAq2q63nyztGp7ClMcokEj1AKyzg8x5Jjb5U6ngsATGniFtOxABvc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726135715; c=relaxed/simple; bh=uwnB7KIAOhvADNb1putg/UdBDY1XsRIOpiKip54wq4s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=h/9pj1rEumFRApm2e831zMwuFb8Ub1+ipqH26e+crMYJp76koIrLGAZMUClgpUtiLCQ+q28PdSPV4RvIhj81LtmAIfS3da9Lxw6T3vLrprUnMSOHghfxvqamTd3CRMwrJFxfakwxzrYYjURCUN/zcqsYXOJi6Rf8jKKXIWpw/jE= 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=Vv81Zeca; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="Vv81Zeca" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2057835395aso9046735ad.3 for ; Thu, 12 Sep 2024 03:08:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1726135713; x=1726740513; 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=OYUHDiaPMMueqbiDNw78EX5OSuDZL3PEhOrFAUYYTvk=; b=Vv81Zecah+X4a4ehPRUutxZvwA3EWjkRoxd5L/4ivKScrDQSs/ICSo2T9d3LAVH0WU MfGMgIILYnAP+sUa0ZAEwzuiQZzHp39pKPsgmd9NeQJ/ct8BzGi7ZcJgPAT+bKqa2oek IbUFKmYnLu/mkSkV7mdNNu+SmDgo6s4CyQyQE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726135713; x=1726740513; 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=OYUHDiaPMMueqbiDNw78EX5OSuDZL3PEhOrFAUYYTvk=; b=rLTR2NnZZpk4pBGFxVrR7+BuCSRNv60OybNy2X3+QdLraW3ZlOW4MuyDbasqzPyGg4 wICeIV5jsc3eAZlzALaEBDvmytXMkq9ogCKEXNEtQ2OesvjHQflXdrdEfoMZv1t98FZI jIsn9+6z5FsLxXl5417L2xsa2NhCnWjyNRroee4Vs2ZIgXvF2SnsttzOSh+Wx6G/lu5L XTAmE8bNoSHQQ3weKoLEiLCkkLAmGYQnZ1RFa9EntlcYMkKprKQ2lDsSb5985sBUnXn7 w+nKsEW17CFTRIH13lTauaLFdal1zzgEKG5IVrhSfpXSlYbFE2XGD/FCrIr6UYlg4o3w HBEw== X-Forwarded-Encrypted: i=1; AJvYcCWFY7j/51Ys+HN9phudoOYfp4kb59yAE+K2+VH9UdeXrilCw20OrzVmKB4g/VpymxtiioaNh4ho7U7qkvg=@vger.kernel.org X-Gm-Message-State: AOJu0Yx4GY46gs6BBTYuCuTEvwuPIEOewP93gPj5BTjLZm3cT6SLFzrc mLXx8Rd5VkU6eoHpih5uJhatHno3NS1HyYfPA16BETDVUdQ4aWWb4UJM4r5Boss= X-Google-Smtp-Source: AGHT+IGIaPbmPm+BmWH0g8XO++iPi7QJxTG3L1tFpxkKNLL01SFf+ArX2Trm3DSSXgpP3VdPThCIoA== X-Received: by 2002:a17:902:da8d:b0:205:3525:81bd with SMTP id d9443c01a7336-2076e36a660mr39610215ad.29.1726135713211; Thu, 12 Sep 2024 03:08:33 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2076afe9da3sm11583795ad.239.2024.09.12.03.08.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 03:08:32 -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 , Larysa Zaremba , linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v3 6/9] netdev-genl: Support setting per-NAPI config values Date: Thu, 12 Sep 2024 10:07:14 +0000 Message-Id: <20240912100738.16567-7-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240912100738.16567-1-jdamato@fastly.com> References: <20240912100738.16567-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support to set per-NAPI defer_hard_irqs and gro_flush_timeout. Signed-off-by: Joe Damato --- Documentation/netlink/specs/netdev.yaml | 11 ++++++ include/uapi/linux/netdev.h | 1 + net/core/netdev-genl-gen.c | 14 ++++++++ net/core/netdev-genl-gen.h | 1 + net/core/netdev-genl.c | 45 +++++++++++++++++++++++++ tools/include/uapi/linux/netdev.h | 1 + 6 files changed, 73 insertions(+) diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlin= k/specs/netdev.yaml index 906091c3059a..319c1e179b08 100644 --- a/Documentation/netlink/specs/netdev.yaml +++ b/Documentation/netlink/specs/netdev.yaml @@ -633,6 +633,17 @@ 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: + - napi-id + - defer-hard-irqs + - gro-flush-timeout =20 mcast-groups: list: diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h index b088a34e9254..4c5bfbc85504 100644 --- a/include/uapi/linux/netdev.h +++ b/include/uapi/linux/netdev.h @@ -188,6 +188,7 @@ enum { NETDEV_CMD_QUEUE_GET, NETDEV_CMD_NAPI_GET, NETDEV_CMD_QSTATS_GET, + NETDEV_CMD_NAPI_SET, =20 __NETDEV_CMD_MAX, NETDEV_CMD_MAX =3D (__NETDEV_CMD_MAX - 1) diff --git a/net/core/netdev-genl-gen.c b/net/core/netdev-genl-gen.c index 8350a0afa9ec..ead570c6ff7d 100644 --- a/net/core/netdev-genl-gen.c +++ b/net/core/netdev-genl-gen.c @@ -74,6 +74,13 @@ static const struct nla_policy netdev_qstats_get_nl_poli= cy[NETDEV_A_QSTATS_SCOPE [NETDEV_A_QSTATS_SCOPE] =3D NLA_POLICY_MASK(NLA_UINT, 0x1), }; =20 +/* NETDEV_CMD_NAPI_SET - set */ +static const struct nla_policy netdev_napi_set_nl_policy[NETDEV_A_NAPI_GRO= _FLUSH_TIMEOUT + 1] =3D { + [NETDEV_A_NAPI_ID] =3D { .type =3D NLA_U32, }, + [NETDEV_A_NAPI_DEFER_HARD_IRQS] =3D { .type =3D NLA_S32 }, + [NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT] =3D { .type =3D NLA_UINT }, +}; + /* Ops table for netdev */ static const struct genl_split_ops netdev_nl_ops[] =3D { { @@ -151,6 +158,13 @@ static const struct genl_split_ops netdev_nl_ops[] =3D= { .maxattr =3D NETDEV_A_QSTATS_SCOPE, .flags =3D GENL_CMD_CAP_DUMP, }, + { + .cmd =3D NETDEV_CMD_NAPI_SET, + .doit =3D netdev_nl_napi_set_doit, + .policy =3D netdev_napi_set_nl_policy, + .maxattr =3D NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT, + .flags =3D GENL_ADMIN_PERM | GENL_CMD_CAP_DO, + }, }; =20 static const struct genl_multicast_group netdev_nl_mcgrps[] =3D { diff --git a/net/core/netdev-genl-gen.h b/net/core/netdev-genl-gen.h index 4db40fd5b4a9..b70cb0f20acb 100644 --- a/net/core/netdev-genl-gen.h +++ b/net/core/netdev-genl-gen.h @@ -28,6 +28,7 @@ int netdev_nl_queue_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb); int netdev_nl_napi_get_doit(struct sk_buff *skb, struct genl_info *info); int netdev_nl_napi_get_dumpit(struct sk_buff *skb, struct netlink_callback= *cb); +int netdev_nl_napi_set_doit(struct sk_buff *skb, struct genl_info *info); int netdev_nl_qstats_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb); =20 diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c index 4698034b5a49..3c90a2fd005a 100644 --- a/net/core/netdev-genl.c +++ b/net/core/netdev-genl.c @@ -300,6 +300,51 @@ int netdev_nl_napi_get_dumpit(struct sk_buff *skb, str= uct netlink_callback *cb) return err; } =20 +static int +netdev_nl_napi_set_config(struct napi_struct *napi, struct genl_info *info) +{ + u64 gro_flush_timeout =3D 0; + u32 defer =3D 0; + + if (info->attrs[NETDEV_A_NAPI_DEFER_HARD_IRQS]) { + defer =3D nla_get_u32(info->attrs[NETDEV_A_NAPI_DEFER_HARD_IRQS]); + napi_set_defer_hard_irqs(napi, defer); + } + + if (info->attrs[NETDEV_A_NAPI_GRO_FLUSH_TIMEOUT]) { + gro_flush_timeout =3D nla_get_uint(info->attrs[NETDEV_A_NAPI_GRO_FLUSH_T= IMEOUT]); + napi_set_gro_flush_timeout(napi, gro_flush_timeout); + } + + return 0; +} + +int netdev_nl_napi_set_doit(struct sk_buff *skb, struct genl_info *info) +{ + struct napi_struct *napi; + unsigned int napi_id; + int err; + + if (GENL_REQ_ATTR_CHECK(info, NETDEV_A_NAPI_ID)) + return -EINVAL; + + napi_id =3D nla_get_u32(info->attrs[NETDEV_A_NAPI_ID]); + + rtnl_lock(); + + napi =3D napi_by_id(napi_id); + if (napi) { + err =3D netdev_nl_napi_set_config(napi, info); + } else { + NL_SET_BAD_ATTR(info->extack, info->attrs[NETDEV_A_NAPI_ID]); + err =3D -ENOENT; + } + + rtnl_unlock(); + + return err; +} + static int netdev_nl_queue_fill_one(struct sk_buff *rsp, struct net_device *netdev, u32 q_idx, u32 q_type, const struct genl_info *info) diff --git a/tools/include/uapi/linux/netdev.h b/tools/include/uapi/linux/n= etdev.h index b088a34e9254..4c5bfbc85504 100644 --- a/tools/include/uapi/linux/netdev.h +++ b/tools/include/uapi/linux/netdev.h @@ -188,6 +188,7 @@ enum { NETDEV_CMD_QUEUE_GET, NETDEV_CMD_NAPI_GET, NETDEV_CMD_QSTATS_GET, + NETDEV_CMD_NAPI_SET, =20 __NETDEV_CMD_MAX, NETDEV_CMD_MAX =3D (__NETDEV_CMD_MAX - 1) --=20 2.25.1 From nobody Sat Nov 30 04:40:48 2024 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CEA61A0716 for ; Thu, 12 Sep 2024 10:08:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726135716; cv=none; b=STN+9FOG4limIF/It6LyY0DPBbEe6tEhTdatiyYCWc5sKx9qbPTxIqD27zdHHr1lSiGvE6L2UQBbvVI6SVD75uwOa9YoXzcey+9sJaxolkf18sCv70YDmvqVBGVrzBl61bDaREPgjARYx2DwiO5FubGbJrTTg1C1py8x/BwdUGA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726135716; c=relaxed/simple; bh=5OCb+7uKyLbZrs1Mj/coxUQ/9iBoUAlSrVa6LuBsIZs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bYXLal3A6ClQWX55UermKh4MwMhFw3J5URSYtlRv/pPusc5KcXSdPBHgDN+L/4o5LdTvBntlmzYCsrpk1wpf8zNkqM2hGbM5sZSP5uGTPSt2HMHben5FFG1G7MYOWGBTlJrFFx2yia+I5naqrgm8m/8wNSqHTh9UPXUWH2xfqH4= 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=xNsm4s59; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="xNsm4s59" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2053a0bd0a6so8462525ad.3 for ; Thu, 12 Sep 2024 03:08:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1726135715; x=1726740515; 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=5vZGBy03W9oJlJ/9i6GWdkzO4slhCr2TSdIbx3y7tGw=; b=xNsm4s5992Mg0YPU/I3voTMDELYF9IitwiYLBnMLFUfGYUNvbCT27GE+6oH0lsA6of 4SV58yYVZ92XxAyu10iv/ahaWlJwkjoj1Sb0G+nLFs3slnA1YG/2izfsqcTD++W7lGVB bLf9mfjWljRkv46sCaMZU8jq3IWMbl0aZRM6I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726135715; x=1726740515; 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=5vZGBy03W9oJlJ/9i6GWdkzO4slhCr2TSdIbx3y7tGw=; b=AqLw9bBY1sqQIku9VUDRUiZVx+YRHC7jK9Hf5muUE0S/dKXtOlC3HHXYABMQhA2H2K o/z92huEeDogqDwJP1ygh02B8WEbcrWl+eqifawOCjCJeT8UTuQfqdElxZk/eec3wvev YbIzfQrvBh85qHyzTdUJBwNaJaBjon2buIMOZ9ydqWI64Di49aRVnIUvJugQT3mH2uCs gfcaOw9/D7wWqG0QA+fRTpHtsTgr+cr1NVUQuJHU0Oy9ssFZ55F1BAdX/3Cu0vwtyWnM lmgqWRWmTYCIDb9mqKjEn1gXS5Fe5aJbHoiNaUMuQJMWcxuz7Zs9RqPPaQQ9F7azIbuo qNmA== X-Forwarded-Encrypted: i=1; AJvYcCWHVYmHLAVKbj0FEnYcFNF37IN+pVuTpA5NYvXmA8AVVwI4gFIMZWc6W5C6LECNkJmZIRzOMaijn/qfcaY=@vger.kernel.org X-Gm-Message-State: AOJu0YwqUmmvVtt9+9aKPG/EZywaVVu7+w91lRZSsZfux84BG61ZFFMB JY/i2dpMNF93/V19BiGOSy93gb3el514o9ps0dfiArCqHrzeij3wHBNBCOo1OV0= X-Google-Smtp-Source: AGHT+IGLql27bdRi5FlHr3ibf1RMiPqxAUiDsI9pQMEbvnCn7/LufTMCuEPbZL7jU6f3P6G3MlmXDw== X-Received: by 2002:a17:902:f684:b0:207:1828:82fd with SMTP id d9443c01a7336-2076e37abf5mr30678565ad.28.1726135714688; Thu, 12 Sep 2024 03:08:34 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2076afe9da3sm11583795ad.239.2024.09.12.03.08.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 03: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 , Michael Chan , "David S. Miller" , Eric Dumazet , Paolo Abeni , linux-kernel@vger.kernel.org (open list) Subject: [RFC net-next v3 7/9] bnxt: Add support for napi storage Date: Thu, 12 Sep 2024 10:07:15 +0000 Message-Id: <20240912100738.16567-8-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240912100738.16567-1-jdamato@fastly.com> References: <20240912100738.16567-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use netif_napi_add_storage to assign per-NAPI storage when initializing NAPIs. Signed-off-by: Joe Damato --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethern= et/broadcom/bnxt/bnxt.c index 6e422e24750a..44fc38efff33 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10986,7 +10986,8 @@ static void bnxt_init_napi(struct bnxt *bp) cp_nr_rings--; for (i =3D 0; i < cp_nr_rings; i++) { bnapi =3D bp->bnapi[i]; - netif_napi_add(bp->dev, &bnapi->napi, poll_fn); + netif_napi_add_storage(bp->dev, &bnapi->napi, poll_fn, + bnapi->index); } if (BNXT_CHIP_TYPE_NITRO_A0(bp)) { bnapi =3D bp->bnapi[cp_nr_rings]; --=20 2.25.1 From nobody Sat Nov 30 04:40:48 2024 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB91B1A38DB for ; Thu, 12 Sep 2024 10:08:36 +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=1726135718; cv=none; b=S546zTM8Zv691flRhM1klkSaa67WTz/5wdx1c9Uact7VV953+IdFyLNro/EjQeloYCgbBMOSMJ6MlMZGBAyKqHd9Zbu1ZFAwnpENKwijhANm57/dmyPSzCsOC4jKUnu0puPiGuqbuI1LGykEpksEWgsYKU0iN+nWrxqKhjuepVs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726135718; c=relaxed/simple; bh=sn8806idNkiCfLnCjpNboyqChe8YstlzP6sfPsdBmnU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kY54MP8XJwpXlnl0LefCjuTlMbkN9KmNqA+RIWsxpEHiNT2YBcvZ1Aotfc6IXJwjttlbyVwq1aqY+4+phRytdkV1rl1mIrT7p6u3n9WsFj3+R0SdgUlHaGgeaacehj1Qe3noR12An3VSbX67mC1/8zle7EEUcrYACDS+O4sIXpc= 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=HkGjOiT5; 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="HkGjOiT5" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-206aee40676so7045595ad.0 for ; Thu, 12 Sep 2024 03:08:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1726135716; x=1726740516; 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=shiwJ5PPTq2a8209E6NrREgDdzwSnjuXLWsyRANhAjY=; b=HkGjOiT5H/1czyPuNcKBzWamFZ9NaeVw5NhYDYDa2VhCbqOaGvmzeiRVM8FFHMJzft /vlbWjfWPGN0TvlSRkHU/2KypT35iVP/dXPZv1pXvMoRomoo0msu4obUPhZ+sFCnTEdE QZDlIpbCOT19CQsFx1fhTE1AwXLcZ2qMJopXY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726135716; x=1726740516; 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=shiwJ5PPTq2a8209E6NrREgDdzwSnjuXLWsyRANhAjY=; b=ww9KetB2FIzusfLn7z9wARdbPHIHbwgDM/vdinMBjwX0ChhqVuZ69f50Nngvepuzd6 C7IeUEa5fk3JO7y943WWv2xDK6wovWcANCznvXk6GV0wU1DY07jMmMGqt4Zwey50tpsu CvXpCTok+2OMd0KiT9KSfXaHnRQSkf6bWiHq+6Ic1v3e66mPw6e5X/DDFWATlEqeK6Tl rYbLIo8zFhzD0Go7AMylcpANPcD+ZCUNBjAlEWLc+Y0qGHfUKS8UG2QnkIYnK0l1ho02 +mL4YJBI1XQyKpWhmnAKmlB2+b5jGRmi1rvrEwdmsrdOa0hBqIwHtBTLjss/PQIiezua jpBA== X-Forwarded-Encrypted: i=1; AJvYcCVDcahdXIUtE4TjeRQElLIw+oib6LLblj8ejThAGcCkn3FeQ3SHS7a5ueYfUhV9yBeuNuCdrIYMtKqDJWM=@vger.kernel.org X-Gm-Message-State: AOJu0YwzV2eEe5AHiXDCYQ6Sv+6U6TVigOwpU5iYqldKORv7YPhWT2ud tNk+5yM7B3moGPTe8Cb38zrJDaOHxUaZ9vUrtTEs9wwAseKFugvrPUWzlNqdtPs= X-Google-Smtp-Source: AGHT+IGmpYd2G5DIIhmYMBuEmM8z3a2VkK0t/McqxC49pS7a6J7N1o/T83xP6FKlEDXPLrwY4pJ2bA== X-Received: by 2002:a17:902:ce09:b0:206:c8dc:e334 with SMTP id d9443c01a7336-2076e4069c6mr37192565ad.39.1726135716263; Thu, 12 Sep 2024 03:08:36 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2076afe9da3sm11583795ad.239.2024.09.12.03.08.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 03:08:35 -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 v3 8/9] mlx5: Add support for napi storage Date: Thu, 12 Sep 2024 10:07:16 +0000 Message-Id: <20240912100738.16567-9-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240912100738.16567-1-jdamato@fastly.com> References: <20240912100738.16567-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use netif_napi_add_storage to assign per-NAPI storage when initializing NAPIs. Signed-off-by: Joe Damato --- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/ne= t/ethernet/mellanox/mlx5/core/en_main.c index 47e7a80d221b..aa4eb5677b8a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -2696,7 +2696,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv= , int ix, c->aff_mask =3D irq_get_effective_affinity_mask(irq); c->lag_port =3D mlx5e_enumerate_lag_port(mdev, ix); =20 - netif_napi_add(netdev, &c->napi, mlx5e_napi_poll); + netif_napi_add_storage(netdev, &c->napi, mlx5e_napi_poll, ix); netif_napi_set_irq(&c->napi, irq); =20 err =3D mlx5e_open_queues(c, params, cparam); --=20 2.25.1 From nobody Sat Nov 30 04:40:48 2024 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 718EB1A3AB4 for ; Thu, 12 Sep 2024 10:08:38 +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=1726135719; cv=none; b=kaLzEFnuHZVUitPCvqB01ANxRGn9j53ojLgsy6qIW9Uw+N/TRm4I5kNqx4wJvx7si7pULbmNXwFEC5nUY9A2eQcl/bn/SKSvPJYLflLBj8mXR6hsS55EwoQv58QYjCybtD1UZItRmREWkXEUcaUEn6n1kp94yXjmwIjSmA6Wyw8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726135719; c=relaxed/simple; bh=s/eB0UYTC1AYEEH3VudRQLi/msdkh7jY0S2zgb5pk80=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q9sXN/CrqPaZCOSXH98Xv/P65wOF+2n6OmmCqefCgTCvWeK6CEQmPtMEkf+sjz4BH1PbTftRz8Rfk4I3biyc4IGuqCNgGTRRGAMCWkZkICLSPZ8chY4qWOJGhrWljYf6K9Q6Nb7YqUiypFoiaWW5O8qvhBzDNKWdEwNrhZou+G4= 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=ESZemDJh; 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="ESZemDJh" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-20696938f86so6371505ad.3 for ; Thu, 12 Sep 2024 03:08:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1726135718; x=1726740518; 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=6mXBwSKozkxlqlprwr3kG9JlKq4geePGoujrr2DPc0I=; b=ESZemDJh6wcHZ24cPeu6kffi6G91KixdQD9FFfPtRLjr4n2lZYtJWO1/jb5y6q1XeR aCIPD1RWZ0OmqDGfP1UO8nOvrK/pKUpqj4QAzrmquTF8/ckZP2pSsqVjWxOQZ2jUSdsN 9sXRbxrVwnOTUuEeD8xdET4hxh10fkAD8hnWw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726135718; x=1726740518; 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=6mXBwSKozkxlqlprwr3kG9JlKq4geePGoujrr2DPc0I=; b=vdVafzgfqu7H4STqccBpys8ON/GGu76YqRMaM5sSYZki1qzF5hlw54AK3Oc6A2Bnc7 HeDpGD+PXzcZcL6OQLF9XiZTCzqPr5i1TpjVfL32I4dSTmIi7UARQM2+7D5UYwqTLl9w 26Yit5bzVO1nYj+D6tAaJbIzgOr2o5RNOOz7wWOApIxuhOZSvM3I1glc1GOJZOtV2Pf4 u9w39nDsEqxOoC8g6JmZa9Mt06zpHCjCTGA25RIdJLsEth9ykj/fouCurr1TDd4oaiqR 6tkpCZElaVc1vpsk8S9x3xsW88aZ3fNysAzhuB62QBTLaE2uIcpPoRDwmRiH3OnHEgoT C6uw== X-Forwarded-Encrypted: i=1; AJvYcCVXb6S8D+Y8o/2Y78JNFNV4GULqIc+rkmsMi9JdAiklhnn0YeYGBnwfcDrdyVCQ7mN5nuJC7v5omC6cJ5o=@vger.kernel.org X-Gm-Message-State: AOJu0YwkUEWULSec0rKse6fT4WTFy/RUwi0RXOKwTPm3u1EPkYiIHgVA L3i9zSMgf0arUmLlMfw73gbFCfp+KDjAzPB7iXmuHx73J7BQFZTJ7x0saH8AhyI= X-Google-Smtp-Source: AGHT+IFSoMMNdhMqFLlbog9Rk12cky6TPNTKRafsz+QCYUczoZ8xRY18wAqCAs4kv3WrpdOHoCl8Fg== X-Received: by 2002:a17:903:4484:b0:202:5af:47fc with SMTP id d9443c01a7336-2076e347ef2mr23829015ad.13.1726135717792; Thu, 12 Sep 2024 03:08:37 -0700 (PDT) Received: from localhost.localdomain ([2620:11a:c019:0:65e:3115:2f58:c5fd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2076afe9da3sm11583795ad.239.2024.09.12.03.08.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 03:08:37 -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 v3 9/9] mlx4: Add support for napi storage to RX CQs Date: Thu, 12 Sep 2024 10:07:17 +0000 Message-Id: <20240912100738.16567-10-jdamato@fastly.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240912100738.16567-1-jdamato@fastly.com> References: <20240912100738.16567-1-jdamato@fastly.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use netif_napi_add_storage to assign per-NAPI storage when initializing RX CQ NAPIs. Presently, struct napi_storage only has support for two fields used for RX, so there is no need to support them with TX CQs, yet. Signed-off-by: Joe Damato --- drivers/net/ethernet/mellanox/mlx4/en_cq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_cq.c b/drivers/net/ether= net/mellanox/mlx4/en_cq.c index 461cc2c79c71..6943268e8256 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_cq.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_cq.c @@ -156,7 +156,8 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, stru= ct mlx4_en_cq *cq, break; case RX: cq->mcq.comp =3D mlx4_en_rx_irq; - netif_napi_add(cq->dev, &cq->napi, mlx4_en_poll_rx_cq); + netif_napi_add_storage(cq->dev, &cq->napi, mlx4_en_poll_rx_cq, + cq_idx); netif_napi_set_irq(&cq->napi, irq); napi_enable(&cq->napi); netif_queue_set_napi(cq->dev, cq_idx, NETDEV_QUEUE_TYPE_RX, &cq->napi); --=20 2.25.1