lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 24 Apr 2019 18:45:19 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Thara Gopinath <thara.gopinath@...aro.org>
Cc:     mingo@...hat.com, rui.zhang@...el.com,
        linux-kernel@...r.kernel.org, amit.kachhap@...il.com,
        viresh.kumar@...aro.org, javi.merino@...nel.org,
        edubezval@...il.com, daniel.lezcano@...aro.org,
        vincent.guittot@...aro.org, nicolas.dechesne@...aro.org,
        bjorn.andersson@...aro.org, dietmar.eggemann@....com
Subject: Re: [PATCH V2 1/3] Calculate Thermal Pressure

On Tue, Apr 16, 2019 at 03:38:39PM -0400, Thara Gopinath wrote:
> +static void __init init_thermal_pressure(void)
> +{
> +	struct thermal_pressure *cpu_thermal;
> +	unsigned long scale;
> +	int cpu;
> +
> +	pr_debug("Init thermal pressure\n");
> +	for_each_possible_cpu(cpu) {
> +		cpu_thermal = per_cpu(thermal_pressure_cpu, cpu);
> +		if (cpu_thermal)
> +			continue;
> +
> +		cpu_thermal = kzalloc(sizeof(*cpu_thermal), GFP_KERNEL);
> +		if (!cpu_thermal)
> +			continue;

So if you unconditinoally allocate this memory, why not just have:

DEFINE_PER_CPU(struct thermal_pressure, cpu_thermal_pressure); ?

Or stick it in struct rq or whatever.

> +		scale = SCHED_CAPACITY_SCALE;
> +		cpu_thermal->scale = scale;
> +		cpu_thermal->old_scale = scale;
> +		cpu_thermal->raw_scale = scale;
> +		cpu_thermal->age_stamp = sched_clock_cpu(cpu);
> +		cpu_thermal->last_update = sched_clock_cpu(cpu);
> +		cpu_thermal->cpu = cpu;
> +		spin_lock_init(&cpu_thermal->lock);
> +		timer_setup(&cpu_thermal->timer, thermal_pressure_timeout,
> +			    TIMER_DEFERRABLE);
> +		per_cpu(thermal_pressure_cpu, cpu) = cpu_thermal;
> +		pr_debug("cpu %d thermal scale = %ld\n", cpu, cpu_thermal->scale);
> +	}
> +
> +	for_each_possible_cpu(cpu) {

You just done that, what gives?

> +		cpu_thermal = per_cpu(thermal_pressure_cpu, cpu);
> +		if (!cpu_thermal)
> +			continue;
> +		cpu_thermal->timer.expires = jiffies +
> +						usecs_to_jiffies(TICK_USEC);

That's like a very copmlicated way of writing: '1', right?

> +		add_timer(&cpu_thermal->timer);
> +	}
> +}

So really what you want is a hook into the tick?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ