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.

Thanks,
Peng.

-- 
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/DU0PR04MB9417606E9DA7F4D450E98990880A9%40DU0PR04MB9417.eurprd04.prod.outlook.com.

Reply via email to