[PATCH 3/3] cpufreq: CPPC: Eliminate the impact of cpc_read() latency error

Zeng Heng zengheng4 at huawei.com
Wed Oct 25 18:55:39 PDT 2023


在 2023/10/25 19:01, Mark Rutland 写道:
> On Wed, Oct 25, 2023 at 05:38:47PM +0800, Zeng Heng wrote:
>
> The previous patch added this function, and calls it with smp_call_on_cpu(),
> where it'll run in IRQ context with IRQs disabled...

smp_call_on_cpu() puts the work to the bind-cpu worker.

And this function will be called in task context, and IRQs is certainly enabled.


Zeng Heng

>>   	struct fb_ctr_pair *fb_ctrs = val;
>>   	int cpu = fb_ctrs->cpu;
>>   	int ret;
>> +	unsigned long timeout;
>>   
>>   	ret = cppc_get_perf_ctrs(cpu, &fb_ctrs->fb_ctrs_t0);
>>   	if (ret)
>>   		return ret;
>>   
>> -	udelay(2); /* 2usec delay between sampling */
>> +	if (likely(!irqs_disabled())) {
>> +		/*
>> +		 * Set 1ms as sampling interval, but never schedule
>> +		 * to the idle task to prevent the AMU counters from
>> +		 * stopping working.
>> +		 */
>> +		timeout = jiffies + msecs_to_jiffies(1);
>> +		while (!time_after(jiffies, timeout))
>> +			cond_resched();
>> +
>> +	} else {
> ... so we'll enter this branch of the if-else ...
>
>> +		pr_warn_once("CPU%d: Get rate in atomic context", cpu);
> ... and pr_warn_once() for something that's apparently normal and outside of
> the user's control?
>
> That doesn't make much sense to me.
>
> Mark.
>
>> +		udelay(2); /* 2usec delay between sampling */
>> +	}
>>   
>>   	return cppc_get_perf_ctrs(cpu, &fb_ctrs->fb_ctrs_t1);
>>   }
>> -- 
>> 2.25.1
>>



More information about the linux-arm-kernel mailing list