lkml.org 
[lkml]   [2024]   [May]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 3/6] driver core: cpu: optimize print_cpus_isolated()
Date
On Mon, May 13 2024 at 15:01, Yury Norov wrote:
> The function may be called with housekeeping_cpumask == cpu_possible_mask,

How so? There is no cpumask argument in the function signature. Can you
please be precise?

> and in such case the 'isolated' cpumask would be just empty.
>
> We can call cpumask_clear() in that case, and save CPU cycles.
>
> @@ -282,8 +282,10 @@ static ssize_t print_cpus_isolated(struct device *dev,
> if (!alloc_cpumask_var(&isolated, GFP_KERNEL))
> return -ENOMEM;
>
> - cpumask_andnot(isolated, cpu_possible_mask,
> - housekeeping_cpumask(HK_TYPE_DOMAIN));
> + if (cpu_possible_mask != housekeeping_cpumask(HK_TYPE_DOMAIN))
> + cpumask_andnot(isolated, cpu_possible_mask, housekeeping_cpumask(HK_TYPE_DOMAIN));
> + else
> + cpumask_clear(isolated);
> len = sysfs_emit(buf, "%*pbl\n", cpumask_pr_args(isolated));
>
> free_cpumask_var(isolated);

Seriously? You need clear() to emit an empty string via %*pbl?

if (cpu_possible_mask != housekeeping_cpumask(HK_TYPE_DOMAIN)) {
if (!alloc_cpumask_var(&isolated, GFP_KERNEL))
return -ENOMEM;
cpumask_andnot(isolated, cpu_possible_mask, housekeeping_cpumask(HK_TYPE_DOMAIN));
len = sysfs_emit(buf, "%*pbl\n", cpumask_pr_args(isolated));
free_cpumask_var(isolated);
} else {
len = sysfs_emit(buf, "\n");
}

That actually would make sense and spare way more CPU cycles, no?

Is it actually worth the larger text size? Not really convinced about that.

Thanks,

tglx

\
 
 \ /
  Last update: 2024-05-27 18:26    [W:0.148 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site