Skip to content

Commit

Permalink
s390/smp: consolidate locking for smp_rescan()
Browse files Browse the repository at this point in the history
Move locking to __smp_rescan() instead of duplicating it to all call sites.

Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
  • Loading branch information
Heiko Carstens authored and Vasily Gorbik committed Feb 23, 2021
1 parent 4c86d2f commit 588a079
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions arch/s390/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,8 @@ static int __smp_rescan_cpus(struct sclp_core_info *info, bool early)
u16 core_id;
int nr, i;

get_online_cpus();
mutex_lock(&smp_cpu_state_mutex);
nr = 0;
cpumask_xor(&avail, cpu_possible_mask, cpu_present_mask);
/*
Expand All @@ -800,6 +802,8 @@ static int __smp_rescan_cpus(struct sclp_core_info *info, bool early)
configured = i < info->configured;
nr += smp_add_core(&info->core[i], &avail, configured, early);
}
mutex_unlock(&smp_cpu_state_mutex);
put_online_cpus();
return nr;
}

Expand Down Expand Up @@ -847,9 +851,7 @@ void __init smp_detect_cpus(void)
pr_info("%d configured CPUs, %d standby CPUs\n", c_cpus, s_cpus);

/* Add CPUs present at boot */
get_online_cpus();
__smp_rescan_cpus(info, true);
put_online_cpus();
memblock_free_early((unsigned long)info, sizeof(*info));
}

Expand Down Expand Up @@ -1178,11 +1180,7 @@ int __ref smp_rescan_cpus(void)
if (!info)
return -ENOMEM;
smp_get_core_info(info, 0);
get_online_cpus();
mutex_lock(&smp_cpu_state_mutex);
nr = __smp_rescan_cpus(info, false);
mutex_unlock(&smp_cpu_state_mutex);
put_online_cpus();
kfree(info);
if (nr)
topology_schedule_update();
Expand Down

0 comments on commit 588a079

Please sign in to comment.