Re: [PATCH net-next v4 2/6] net: napi: add internal ARFS rmap management

From
Simon Horman <horms@kernel.org>
Date
2025-01-10 11:55:53
Also in
intel-wired-lan
Reply to
Ahmed Zaki, 2025-01-09
On Thu, Jan 09, 2025 at 04:31:03PM -0700, Ahmed Zaki wrote:
For drivers using the netif_enable_cpu_rmap(), move the IRQ rmap notifier
inside the napi_struct.

Signed-off-by: Ahmed Zaki <redacted>
...
quoted hunk ↗ jump to hunk
diff --git a/net/core/dev.c b/net/core/dev.c
...
quoted hunk ↗ jump to hunk
+static int napi_irq_cpu_rmap_add(struct napi_struct *napi, int irq)
+{
+	struct cpu_rmap *rmap = napi->dev->rx_cpu_rmap;
+	int rc;
+
+	if (!napi || !rmap)
+		return -EINVAL;
Hi Ahmed,

Here it is assumed that napi may be NULL.  But it is dereferenced
unconditionally on the first like of this function.

Flagged by Smatch.
quoted hunk ↗ jump to hunk
+	napi->notify.notify = netif_irq_cpu_rmap_notify;
+	napi->notify.release = netif_napi_affinity_release;
+	cpu_rmap_get(rmap);
+	rc = cpu_rmap_add(rmap, napi);
+	if (rc < 0)
+		goto err_add;
+
+	napi->napi_rmap_idx = rc;
+	rc = irq_set_affinity_notifier(irq, &napi->notify);
+	if (rc)
+		goto err_set;
+
+	return 0;
+
+err_set:
+	rmap->obj[napi->napi_rmap_idx] = NULL;
+err_add:
+	cpu_rmap_put(rmap);
+	return rc;
+}
 #endif
 
 void netif_napi_set_irq(struct napi_struct *napi, int irq)
...

-- 
pw-bot: changes-requested
Thread (13 messages) 13 messages, 3 authors, last reply 2025-01-10
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help