perf/arm_cspmu: Avoid placing cpumask on the stack
In general it's preferable to avoid placing cpumasks on the stack, as for large values of NR_CPUS these can consume significant amounts of stack space and make stack overflows more likely. Use cpumask_any_and_but() to avoid the need for a temporary cpumask on the stack. Suggested-by: Mark Rutland <mark.rutland@arm.com> Reviewed-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Dawei Li <dawei.li@shingroup.cn> Link: https://lore.kernel.org/r/20240403155950.2068109-5-dawei.li@shingroup.cn Signed-off-by: Will Deacon <will@kernel.org>
This commit is contained in:
@@ -1322,8 +1322,7 @@ static int arm_cspmu_cpu_online(unsigned int cpu, struct hlist_node *node)
|
|||||||
|
|
||||||
static int arm_cspmu_cpu_teardown(unsigned int cpu, struct hlist_node *node)
|
static int arm_cspmu_cpu_teardown(unsigned int cpu, struct hlist_node *node)
|
||||||
{
|
{
|
||||||
int dst;
|
unsigned int dst;
|
||||||
struct cpumask online_supported;
|
|
||||||
|
|
||||||
struct arm_cspmu *cspmu =
|
struct arm_cspmu *cspmu =
|
||||||
hlist_entry_safe(node, struct arm_cspmu, cpuhp_node);
|
hlist_entry_safe(node, struct arm_cspmu, cpuhp_node);
|
||||||
@@ -1333,9 +1332,8 @@ static int arm_cspmu_cpu_teardown(unsigned int cpu, struct hlist_node *node)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Choose a new CPU to migrate ownership of the PMU to */
|
/* Choose a new CPU to migrate ownership of the PMU to */
|
||||||
cpumask_and(&online_supported, &cspmu->associated_cpus,
|
dst = cpumask_any_and_but(&cspmu->associated_cpus,
|
||||||
cpu_online_mask);
|
cpu_online_mask, cpu);
|
||||||
dst = cpumask_any_but(&online_supported, cpu);
|
|
||||||
if (dst >= nr_cpu_ids)
|
if (dst >= nr_cpu_ids)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user