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, 10 Jun 2009 14:42:16 -0500
From:	"Langsdorf, Mark" <mark.langsdorf@....com>
To:	"Rusty Russell" <rusty@...tcorp.com.au>,
	"Linus Torvalds" <torvalds@...ux-foundation.org>
CC:	"Yinghai Lu" <yinghai@...nel.org>, "Avi Kivity" <avi@...hat.com>,
	"Ingo Molnar" <mingo@...e.hu>,
	"Andrew Morton" <akpm@...ux-foundation.org>,
	"Thomas Gleixner" <tglx@...utronix.de>,
	"H. Peter Anvin" <hpa@...or.com>, <linux-kernel@...r.kernel.org>,
	"Dave Jones" <davej@...hat.com>, <cpufreq@...r.kernel.org>
Subject: RE: [PATCH 4/6] x86/cpufreq: use cpumask_copy instead of =

> powernow_k8_target is problematic: it grabs a mutex.  cpufreq 
> people, is this called often?
 
Yes.  It's the function that makes a frequency change
happen, so 5+ times per second per core isn't
unreasonable.

-Mark Langsdorf
Operating System Research Center
AMD


> Subject: cpumask: avoid playing with cpus_allowed in powernow-k8.c
> From: Rusty Russell <rusty@...tcorp.com.au>
> 
> It's generally a very bad idea to mug some process's cpumask: it could
> legitimately and reasonably be changed by root, which could break us
> (if done before our code) or them (if we restore the wrong value).
> 
> I use work_on_cpu, which is slightly less efficient than the old code,
> but the code is complex enough that using smp_call_function_single()
> is not trivial.


> -/* Driver entry point to switch to the target frequency */
> -static int powernowk8_target(struct cpufreq_policy *pol,
> -		unsigned targfreq, unsigned relation)
> +struct target_data {
> +	struct cpufreq_policy *pol;
> +	unsigned targfreq;
> +	unsigned relation;
> +};
> +
> +static long powernowk8_target_on_cpu(void *_tdata)
>  {
> -	cpumask_t oldmask;
> +	struct target_data *tdata = _tdata;
> +	struct cpufreq_policy *pol = tdata->pol;
>  	struct powernow_k8_data *data = per_cpu(powernow_data, 
> pol->cpu);
>  	u32 checkfid;
>  	u32 checkvid;
> @@ -1158,22 +1152,13 @@ static int powernowk8_target(struct cpuf
>  	checkfid = data->currfid;
>  	checkvid = data->currvid;
>  
> -	/* only run on specific CPU from here on */
> -	oldmask = current->cpus_allowed;
> -	set_cpus_allowed_ptr(current, &cpumask_of_cpu(pol->cpu));
> -
> -	if (smp_processor_id() != pol->cpu) {
> -		printk(KERN_ERR PFX "limiting to cpu %u 
> failed\n", pol->cpu);
> -		goto err_out;
> -	}
> -
>  	if (pending_bit_stuck()) {
>  		printk(KERN_ERR PFX "failing targ, change 
> pending bit set\n");
>  		goto err_out;
>  	}
>  
>  	dprintk("targ: cpu %d, %d kHz, min %d, max %d, relation %d\n",
> -		pol->cpu, targfreq, pol->min, pol->max, relation);
> +		pol->cpu, tdata->targfreq, pol->min, pol->max, 
> tdata->relation);
>  
>  	if (query_current_values_with_pending_wait(data))
>  		goto err_out;
> @@ -1193,7 +1178,8 @@ static int powernowk8_target(struct cpuf
>  	}
>  
>  	if (cpufreq_frequency_table_target(pol, data->powernow_table,
> -				targfreq, relation, &newstate))
> +					   tdata->targfreq, 
> tdata->relation,
> +					   &newstate))
>  		goto err_out;
>  
>  	mutex_lock(&fidvid_mutex);
> @@ -1220,10 +1206,19 @@ static int powernowk8_target(struct cpuf
>  	ret = 0;
>  
>  err_out:
> -	set_cpus_allowed_ptr(current, &oldmask);
>  	return ret;
>  }
>  
> +/* Driver entry point to switch to the target frequency */
> +static int powernowk8_target(struct cpufreq_policy *pol,
> +			     unsigned targfreq, unsigned relation)
> +{
> +	struct target_data tdata = { .pol = pol,
> +				     .targfreq = targfreq,
> +				     .relation = relation };
> +	return work_on_cpu(pol->cpu, powernowk8_target_on_cpu, &tdata);
> +}
> +
>  /* Driver entry point to verify the policy and range of 
> frequencies */
>  static int powernowk8_verify(struct cpufreq_policy *pol)
>  {

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ