Subject: Re: [PATCH RFC net-next 1/2] net: napi: add CPU affinity to napi->config

From: Jakub Kicinski <[email-masked]>
Date: Sat, 7 Dec 2024 18:24:13 -0800

On Thu,  5 Dec 2024 17:12:08 -0700 Ahmed Zaki wrote:
> +static inline void
> +netif_napi_affinity_notify(struct irq_affinity_notify *notify,
> +			   const cpumask_t *mask)
> +{
> +	struct napi_struct *napi =
> +		container_of(notify, struct napi_struct, affinity_notify);
> +
> +	if (napi->config)
> +		cpumask_copy(&napi->config->affinity_mask, mask);
> +}
> +
> +static inline void
> +netif_napi_affinity_release(struct kref __always_unused *ref) {}
>  
>  static inline void netif_napi_set_irq(struct napi_struct *napi, int irq)
>  {
>  	napi->irq = irq;
> +
> +	if (irq > 0 && napi->config) {
> +		napi->affinity_notify.notify = netif_napi_affinity_notify;
> +		napi->affinity_notify.release = netif_napi_affinity_release;
> +		irq_set_affinity_notifier(irq, &napi->affinity_notify);
> +		irq_set_affinity(irq, &napi->config->affinity_mask);
> +	}
>  }

Nice, thanks for following up!

Let's move this code to net/core/dev.c or a new file, it's getting
complex for a static inline since there's no perf implication.