On Tue, Aug 29, 2017 at 07:40:44PM +0200, Thomas Gleixner wrote:

> One solution I'm looking into right now is to reverse the lock order and
> actually make the hotplug code do:
> 
>        watchdog_lock();
>        cpu_write_lock();
> 
>        ....
>        cpu_write_unlock();
>        watchdog_unlock();
>        
> and get rid of cpu_read_(un)lock() in the sysctl interface completely. I
> know it's ugly, but we have other locks we take in the hotplug path as
> well.

This is to serialize the sysctl against hotplug? I'm not immediately
seeing why watchdog_lock needs to be the outer most lock, is that
because of vfs locks or something?

> That solves that part of the issue, but it does not solve the
> release_ds_buffers() problem. Though with the watchdog_lock() mechanism, it
> allows me to do:
> 
>        ->park() := watchdog_disable()
>           perf_event_disable(percpuevt);
>         cleanup_event = percpuevt;
>         percpuevt = NULL;
> and then
> 
>        watchdog_unlock()
>           if (cleanup_event) {
>               perf_event_release_ebent(cleanup_event);
>               cleanup_event = NULL;
>         }
>         mutex_unlock(&watchdog_mutex);
> 
> That should do the trick nicely for both user space functions and the cpu
> hotplug machinery.
> 
> Though it's quite a rewrite of that mess, which is particularly non trivial
> because that extra non perf implementation in arch/powerpc which has its
> own NMI watchdog thingy wants its calls preserved. But AFAICT so far it
> should just work. Famous last words....
> 
> Thoughts?

So I have a patch _somewhere_ that preserves the event<->cpu relation
across hotplug and disable/enable would be sufficient. If you want I can
try and dig that out and make it work again.

That would avoid having to do the destroy/create cycle of the watchdog
events.

Reply via email to