Changes vs. V1: Fix the package removal wreckage reported by Srinivas
We solely intended to convert that driver to the hotplug state machine and
stumbled over a large pile of insanities, which are all interwoven with the
package management:
- The work cancelation code, the thermal zone unregistering, the work code
and the interrupt notification function are racy against each other and
against cpu hotplug and module exit. The random locking sprinkeled all
over the place does not help anything and probably exists to make people
feel good. The resulting issues (mainly use after free) are probably
hard to trigger, but they clearly exist
- Work cancelation in the cpu hotplug code can leave the work marked
scheduled and the package interrupts disabled forever.
- Storage for a boolean information whether work is scheduled for a
package is kept in separate allocated storage, which is resized when the
number of detected packages grows.
- Delayed work structs are held in a static percpu storage, which makes no
sense at all because work is strictly per package.
- Packages are kept in a list, which must be searched over and over.
Fixing the whole pile of races with a few duct tape fixes was pretty much
impossible, so I decided to do a major rewrite to fix all of the
above. Here are the major changes:
- Rewrite the offline code with proper locking against interrupts and work
function and make sure that canceled work is rescheduled if there is
another online cpu in the package.
- Use the cpu offline callback on module exit to fix the work cancelation
race.
- Move the bool which denotes scheduled work into the package struct
where it belongs.
- Move the delayed work struct into the package struct, which is the only
sensible place to have it and schedule the work on the cpu which is the
target for the sysfs files as this makes the cancellation and
rescheduling in the cpu offline path simple.
- Add a large pile of comments documenting the cpu teardown mechanism
- Code sanitizing, revamp the horrible name choices plus a general coding
style cleanup.
Note, that I did the namespace and code cleanup in the middle of the
series, because staring at that mess just made my eyes bleeding.
- Store the package pointers in an array which is allocated at init
time. Sizing of the array is determined from the topology
information. That makes the package lookup a simple array lookup.
As a last step the driver is converted to the hotplug state machine.
Thanks,
tglx
---
x86_pkg_temp_thermal.c | 593 ++++++++++++++++++++-----------------------------
1 file changed, 249 insertions(+), 344 deletions(-)
On Tue, 2016-11-22 at 17:57 +0000, Thomas Gleixner wrote:
> Changes vs. V1: Fix the package removal wreckage reported by Srinivas
>
I haven't looked at individual patch but tested the series as a whole.
So Rui, you can add
Tested-by: Srinivas Pandruvada <[email protected]>
Thanks,
Srinivas
Rui,
On Tue, Nov 22, 2016 at 05:57:04PM -0000, Thomas Gleixner wrote:
<cut>
> ---
> x86_pkg_temp_thermal.c | 593 ++++++++++++++++++++-----------------------------
> 1 file changed, 249 insertions(+), 344 deletions(-)
I am assuming you are handling this one in your tree directly. In any
case, you can add my:
Acked-by: Eduardo Valentin <edubezval@gmail>
for the series.
BR,
Eduardo
On Tue, 2016-11-22 at 12:51 -0700, Pandruvada, Srinivas wrote:
> On Tue, 2016-11-22 at 17:57 +0000, Thomas Gleixner wrote:
> >
> > Changes vs. V1: Fix the package removal wreckage reported by
> > Srinivas
> >
> I haven't looked at individual patch but tested the series as a
> whole.
>
> So Rui, you can add
>
> Tested-by: Srinivas Pandruvada <[email protected]>
>
applied.
thanks,
rui