Skip to content

Commit 5620933

Browse files
jlelliPeter Zijlstra
authored andcommitted
sched/topology: Wrappers for sched_domains_mutex
Create wrappers for sched_domains_mutex so that it can transparently be used on both CONFIG_SMP and !CONFIG_SMP, as some function will need to do. Fixes: 53916d5 ("sched/deadline: Check bandwidth overflow earlier for hotplug") Reported-by: Jon Hunter <[email protected]> Signed-off-by: Juri Lelli <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Valentin Schneider <[email protected]> Reviewed-by: Dietmar Eggemann <[email protected]> Tested-by: Waiman Long <[email protected]> Tested-by: Jon Hunter <[email protected]> Tested-by: Dietmar Eggemann <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent f6147af commit 5620933

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

include/linux/sched.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,11 @@ enum uclamp_id {
382382
#ifdef CONFIG_SMP
383383
extern struct root_domain def_root_domain;
384384
extern struct mutex sched_domains_mutex;
385+
extern void sched_domains_mutex_lock(void);
386+
extern void sched_domains_mutex_unlock(void);
387+
#else
388+
static inline void sched_domains_mutex_lock(void) { }
389+
static inline void sched_domains_mutex_unlock(void) { }
385390
#endif
386391

387392
struct sched_param {

kernel/cgroup/cpuset.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -994,10 +994,10 @@ static void
994994
partition_and_rebuild_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
995995
struct sched_domain_attr *dattr_new)
996996
{
997-
mutex_lock(&sched_domains_mutex);
997+
sched_domains_mutex_lock();
998998
partition_sched_domains_locked(ndoms_new, doms_new, dattr_new);
999999
dl_rebuild_rd_accounting();
1000-
mutex_unlock(&sched_domains_mutex);
1000+
sched_domains_mutex_unlock();
10011001
}
10021002

10031003
/*

kernel/sched/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8470,9 +8470,9 @@ void __init sched_init_smp(void)
84708470
* CPU masks are stable and all blatant races in the below code cannot
84718471
* happen.
84728472
*/
8473-
mutex_lock(&sched_domains_mutex);
8473+
sched_domains_mutex_lock();
84748474
sched_init_domains(cpu_active_mask);
8475-
mutex_unlock(&sched_domains_mutex);
8475+
sched_domains_mutex_unlock();
84768476

84778477
/* Move init over to a non-isolated CPU */
84788478
if (set_cpus_allowed_ptr(current, housekeeping_cpumask(HK_TYPE_DOMAIN)) < 0)

kernel/sched/debug.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ static ssize_t sched_verbose_write(struct file *filp, const char __user *ubuf,
294294
bool orig;
295295

296296
cpus_read_lock();
297-
mutex_lock(&sched_domains_mutex);
297+
sched_domains_mutex_lock();
298298

299299
orig = sched_debug_verbose;
300300
result = debugfs_write_file_bool(filp, ubuf, cnt, ppos);
@@ -306,7 +306,7 @@ static ssize_t sched_verbose_write(struct file *filp, const char __user *ubuf,
306306
sd_dentry = NULL;
307307
}
308308

309-
mutex_unlock(&sched_domains_mutex);
309+
sched_domains_mutex_unlock();
310310
cpus_read_unlock();
311311

312312
return result;
@@ -517,9 +517,9 @@ static __init int sched_init_debug(void)
517517
debugfs_create_u32("migration_cost_ns", 0644, debugfs_sched, &sysctl_sched_migration_cost);
518518
debugfs_create_u32("nr_migrate", 0644, debugfs_sched, &sysctl_sched_nr_migrate);
519519

520-
mutex_lock(&sched_domains_mutex);
520+
sched_domains_mutex_lock();
521521
update_sched_domain_debugfs();
522-
mutex_unlock(&sched_domains_mutex);
522+
sched_domains_mutex_unlock();
523523
#endif
524524

525525
#ifdef CONFIG_NUMA_BALANCING

kernel/sched/topology.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
#include <linux/bsearch.h>
77

88
DEFINE_MUTEX(sched_domains_mutex);
9+
void sched_domains_mutex_lock(void)
10+
{
11+
mutex_lock(&sched_domains_mutex);
12+
}
13+
void sched_domains_mutex_unlock(void)
14+
{
15+
mutex_unlock(&sched_domains_mutex);
16+
}
917

1018
/* Protected by sched_domains_mutex: */
1119
static cpumask_var_t sched_domains_tmpmask;
@@ -2791,7 +2799,7 @@ void partition_sched_domains_locked(int ndoms_new, cpumask_var_t doms_new[],
27912799
void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
27922800
struct sched_domain_attr *dattr_new)
27932801
{
2794-
mutex_lock(&sched_domains_mutex);
2802+
sched_domains_mutex_lock();
27952803
partition_sched_domains_locked(ndoms_new, doms_new, dattr_new);
2796-
mutex_unlock(&sched_domains_mutex);
2804+
sched_domains_mutex_unlock();
27972805
}

0 commit comments

Comments
 (0)