On 21.11.22 07:47, Peng Fan wrote:
> Hi,
> 
> I have a question regarding ivshmem-net, not sure whether we need to use 
> local_bh_disable/enable to guard napi_schedule.
> 
> See below patch:
> https://patches.linaro.org/project/linux-usb/patch/[email protected]/
> "
> The driver invokes napi_schedule() in several places from task
> context. napi_schedule() raises the NET_RX softirq bit and relies on the
> calling context to ensure that the softirq is handled. That's usually on
> return from interrupt or on the outermost local_bh_enable().
> 
> But that's not the case here which causes the soft interrupt handling to be
> delayed to the next interrupt or local_bh_enable(). If the task in which
> context this is invoked is the last runnable task on a CPU and the CPU goes
> idle before an interrupt arrives or a local_bh_disable/enable() pair
> handles the pending soft interrupt then the NOHZ idle code emits the
> following warning.
> 
>   NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!!
> 
> Prevent this by wrapping the napi_schedule() invocation from task context
> into a local_bh_disable/enable() pair.
> "
> https://lore.kernel.org/all/87y28b9nyn.ffs@tglx/t/
> 
> I draft one:
> diff --git a/drivers/net/ivshmem-net.c b/drivers/net/ivshmem-net.c
> index 3bcd39b91176e..81e19d80bd0a7 100644
> --- a/drivers/net/ivshmem-net.c
> +++ b/drivers/net/ivshmem-net.c
> @@ -558,7 +558,9 @@ static void ivshm_net_run(struct net_device *ndev)
> 
>         netif_start_queue(ndev);
>         napi_enable(&in->napi);
> +       local_bh_disable();
>         napi_schedule(&in->napi);
> +       local_bh_enable();
>         ivshm_net_set_state(in, IVSHM_NET_STATE_RUN);
>  }
> 
> There are other places calling napi_schedule, but seems no need 
> local_bh_disable/enable to protect.
> 
> Not sure the upper change is valid or not, please help check.
> 

Looks suspicious, indeed. I wonder why there are not runtime checks in
napi_schedule to detect its needs and report a wrong bh state.

Does this issue only trigger with NOHZ enabled?

Jan

-- 
Siemens AG, Technology
Competence Center Embedded Linux

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jailhouse-dev/b8ff927b-a86e-9c92-e834-a8cdd790a679%40siemens.com.

Reply via email to