Re: [REGRESSION] 774ac8b7eff6 ("Thermal: initialize thermal zone device correctly") causes performance drop

From: Pandruvada, Srinivas
Date: Fri Mar 18 2016 - 19:36:15 EST


On Fri, 2016-03-18 at 15:28 -0700, Laura Abbott wrote:
> (bringing this back to the main thread)
>
> On 03/16/2016 05:20 PM, Pandruvada, Srinivas wrote:
> > On Wed, 2016-03-16 at 17:00 -0700, Laura Abbott wrote:
> > > On 03/16/2016 03:46 PM, Greg Kroah-Hartman wrote:
> > > > On Wed, Mar 16, 2016 at 03:27:57PM -0700, Laura Abbott wrote:
> > > > > Hi,
> > > > >
> > > > > Fedora received a bug report (https://bugzilla.redhat.com/sho
> > > > > w_bu
> > > > > g.cgi?id=1317190)
> > > > > of a major performance drop on various bench marks and
> > > > > general
> > > > > system
> > > > > sluggishness with the 4.4.4 kernel update. The benchmarks
> > > > > were
> > > > > showing
> > > > > a reduction to about 18% performance (not minor).
> > > > >
> > > > > Bisection showed the first bad commit was
> > > > >
> > > > > commit 774ac8b7eff69e0786970157de2157e68b22f456
> > > > > Author: Zhang Rui <rui.zhang@xxxxxxxxx>
> > > > > Date:ÂÂÂFri Oct 30 16:31:47 2015 +0800
> > > > >
> > > > > ÂÂÂÂÂÂThermal: initialize thermal zone device correctly
> > > > > ÂÂÂÂÂÂcommit bb431ba26c5cd0a17c941ca6c3a195a3a6d5d461
> > > > > upstream.
> > > > > ÂÂÂÂÂÂAfter thermal zone device registered, as we have not
> > > > > read
> > > > > any
> > > > > ÂÂÂÂÂÂtemperature before, thus tz->temperature should not be
> > > > > 0,
> > > > > ÂÂÂÂÂÂwhich actually means 0C, and thermal trend is not
> > > > > available.
> > > > > ÂÂÂÂÂÂIn this case, we need specially handling for the first
> > > > > ÂÂÂÂÂÂthermal_zone_device_update().
> > > > > ÂÂÂÂÂÂBoth thermal core framework and step_wise governor is
> > > > > ÂÂÂÂÂÂenhanced to handle this. And since the step_wise
> > > > > governor
> > > > > ÂÂÂÂÂÂis the only one that uses trends, so it's the only
> > > > > thermal
> > > > > ÂÂÂÂÂÂgovernor that needs to be updated.
> > > > > ÂÂÂÂÂÂTested-by: Manuel Krause <manuelkrause@xxxxxxxxxxxx>
> > > > > ÂÂÂÂÂÂTested-by: szegad <szegadlo@xxxxxxxxxxxxxx>
> > > > > ÂÂÂÂÂÂTested-by: prash <prash.n.rao@xxxxxxxxx>
> > > > > ÂÂÂÂÂÂTested-by: amish <ammdispose-arch@xxxxxxxxx>
> > > > > ÂÂÂÂÂÂTested-by: Matthias <morpheusxyz123@xxxxxxxx>
> > > > > ÂÂÂÂÂÂReviewed-by: Javi Merino <javi.merino@xxxxxxx>
> > > > > ÂÂÂÂÂÂSigned-off-by: Zhang Rui <rui.zhang@xxxxxxxxx>
> > > > > ÂÂÂÂÂÂSigned-off-by: Chen Yu <yu.c.chen@xxxxxxxxx>
> > > > > ÂÂÂÂÂÂSigned-off-by: Greg Kroah-Hartman <gregkh@linuxfoundati
> > > > > on.or
> > > > > g>
> > > > >
> > > > >
> > > > >
> > > > > Reverting this plus to other commits in the series
> > > > > (a67208e94d94
> > > > > "Thermal: handle thermal zone device properly during system
> > > > > sleep"
> > > > > and 27f356149d59 "Thermal: do thermal zone update after a
> > > > > cooling
> > > > > device registered") confirmed the performance was back to
> > > > > normal.
> > > > >
> > > > > Bugzilla has the full discussion but this comment from one of
> > > > > the
> > > > > reporters sums it up:
> > > > >
> > > > > "In 4.4.3 and prior, my 2.40 MHz processor would fluctuate
> > > > > between
> > > > > 1000 and 3400 MHz.ÂÂIn 4.4.4, the processor would fluctuate
> > > > > between
> > > > > 400 and 700 MHz, according to /proc/cpuinfo.
> > > > >
> > > > > Setting
> > > > > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
> > > > > to
> > > > > performance, instead of the default "powersave" forces the
> > > > > CPU to
> > > > > 2400 MHz, and improves performance greatly, but still not to
> > > > > the
> > > > > same level as in 4.4.3."
> > > > >
> > > > > Any ideas?
> > > >
> > > > Is this same "slowdown" also seen in 4.5?
> > > >
> > > > thanks,
> > > >
> > > > greg k-h
> > > >
> > >
> > > Yes, the same issue is seen on 4.5 according to the reporter.
> > What does it show here when performance drops?
> > grep . /sys/devices/system/cpu/intel_pstate/*
> >
> > Is the problem still occurs if you set
> > /sys/class/thermal/thermal_zone*/mode to "disabled"
> >
> > Thanks,
> > Srinivas
> >
>
> A separate thread was started which gave this insight:
>
> "I think
> the problem is your device has a passive trip temp of 0
> /sys/class/thermal/thermal_zone0/trip_point_2_temp:0
> /sys/class/thermal/thermal_zone0/trip_point_2_type:passive
>
> Which triggers a false throttle = true. I think we should this trip
> as
> invalid in the case of
> if (tz->temperature >= trip_temp) {} check
> in thermal_zone_trip_update()."
>
> So would something like the following work?
>
> diff --git a/drivers/thermal/step_wise.c
> b/drivers/thermal/step_wise.c
> index ea9366a..1228797 100644
> --- a/drivers/thermal/step_wise.c
> +++ b/drivers/thermal/step_wise.c
> @@ -143,7 +143,7 @@ static void thermal_zone_trip_update(struct
> thermal_zone_device *tz, int trip)
> ÂÂ
> ÂÂÂÂÂÂÂÂÂtrend = get_tz_trend(tz, trip);
> ÂÂ
> -ÂÂÂÂÂÂÂif (tz->temperature >= trip_temp) {
> +ÂÂÂÂÂÂÂif (trip_type != THERMAL_TRIPS_NONE && tz->temperature >=
> trip_temp) {
if (trip_tempÂ&& tz->temperature >= trip_temp) {
        Âthrottle = true;
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂtrace_thermal_zone_trip(tz, trip, trip_type);
> ÂÂÂÂÂÂÂÂÂ}
>
I think Rui is working on some change.

Thanks,
Srinivas

> (completely untested, no idea if I'm even close)
>
> Thanks,
> Laura