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:	Thu, 2 Jun 2016 09:47:54 +0200 (CEST)
From:	Thomas Gleixner <tglx@...utronix.de>
To:	Borislav Petkov <bp@...en8.de>
cc:	Guenter Roeck <linux@...ck-us.net>, Ingo Molnar <mingo@...nel.org>,
	linux-hwmon@...r.kernel.org, X86 ML <x86@...nel.org>,
	LKML <linux-kernel@...r.kernel.org>,
	Rui Huang <ray.huang@....com>,
	Sherry Hurwitz <sherry.hurwitz@....com>
Subject: Re: [PATCH] hwmon: (fam15h_power) Disable preemption when reading
 registers

On Thu, 2 Jun 2016, Borislav Petkov wrote:
>  static int read_registers(struct fam15h_power_data *data)
>  {
> -	int this_cpu, ret, cpu;
>  	int core, this_core;
>  	cpumask_var_t mask;
> +	int ret, cpu;
>  
>  	ret = zalloc_cpumask_var(&mask, GFP_KERNEL);
>  	if (!ret)
> @@ -183,7 +183,6 @@ static int read_registers(struct fam15h_power_data *data)
>  	memset(data->cu_on, 0, sizeof(int) * MAX_CUS);
>  
>  	get_online_cpus();
> -	this_cpu = smp_processor_id();
>  
>  	/*
>  	 * Choose the first online core of each compute unit, and then
> @@ -205,10 +204,13 @@ static int read_registers(struct fam15h_power_data *data)
>  		cpumask_set_cpu(cpumask_any(topology_sibling_cpumask(cpu)), mask);
>  	}
>  
> -	if (cpumask_test_cpu(this_cpu, mask))
> +	preempt_disable();
> +	smp_call_function_many(mask, do_read_registers_on_cu, data, true);
> +
> +	if (cpumask_test_cpu(smp_processor_id(), mask))
>  		do_read_registers_on_cu(data);
>  
> -	smp_call_function_many(mask, do_read_registers_on_cu, data, true);
> +	preempt_enable();
>  	put_online_cpus();

What's wrong with using:

       on_each_cpu_mask()

Which does all that magic for you?

Thanks,

	tglx

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ