Re: [PATCH] misc/pvpanic: share the shutdown handler across devices
From: Zhu GuangLei
Date: Wed Nov 25 2026 - 04:15:37 EST
On Wed, Nov 25, 2026 at 09:34:22AM +0100, Greg Kroah-Hartman wrote:
> > Register a single handler for the driver and keep it as long as at
> > least one device has the shutdown event enabled. Serialize updates of
> > the events mask and of the handler registration with a mutex. The
> > panic and power-off paths still take only the list spinlock, so access
> > the events mask with READ_ONCE()/WRITE_ONCE().
>
> If a spinlock is used, why is the read/write once stuff needed?
Because the writer did not take that spinlock: v1 updated the mask
under the new mutex only, while pvpanic_send_event() reads it under
pvpanic_lock. That is not a good reason, though. v2 updates the mask
under pvpanic_lock as well and drops READ_ONCE()/WRITE_ONCE().
> > + mutex_lock(&pvpanic_sys_off_lock);
>
> guard()?
Yes, will do in v2.
> > + WRITE_ONCE(pi->events, events);
>
> As you have a global lock here, again, why is WRITE_ONCE() needed?
Same reason as above, it is gone in v2.
thanks,
Zhu GuangLei