aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/kernel
diff options
context:
space:
mode:
authorHeiko Carstens <heiko.carstens@de.ibm.com>2008-04-30 07:38:36 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2008-04-30 07:38:44 -0400
commit0b18d318b80a7f350648ca8f7cc00a2f688104cb (patch)
tree7a5346faefb67b24f05c00691ca170a6805b0921 /arch/s390/kernel
parentf291e17227cf30432ca7c402220f62e6924dd97d (diff)
[S390] smp: Fix locking order.
On some smp sysfs store attributes get_online_cpus() may block on cpu_hotplug.lock, but we hold already smp_cpu_state_mutex. Since the locking order on cpu hotplug via arch_update_cpu_topology is inverse this might lead to deadlocks. So make sure locking order is always the same. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/kernel')
-rw-r--r--arch/s390/kernel/smp.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 0dfa988c1b26..6bb5c050640f 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -890,8 +890,8 @@ static ssize_t cpu_configure_store(struct sys_device *dev, const char *buf,
890 if (val != 0 && val != 1) 890 if (val != 0 && val != 1)
891 return -EINVAL; 891 return -EINVAL;
892 892
893 mutex_lock(&smp_cpu_state_mutex);
894 get_online_cpus(); 893 get_online_cpus();
894 mutex_lock(&smp_cpu_state_mutex);
895 rc = -EBUSY; 895 rc = -EBUSY;
896 if (cpu_online(cpu)) 896 if (cpu_online(cpu))
897 goto out; 897 goto out;
@@ -919,8 +919,8 @@ static ssize_t cpu_configure_store(struct sys_device *dev, const char *buf,
919 break; 919 break;
920 } 920 }
921out: 921out:
922 put_online_cpus();
923 mutex_unlock(&smp_cpu_state_mutex); 922 mutex_unlock(&smp_cpu_state_mutex);
923 put_online_cpus();
924 return rc ? rc : count; 924 return rc ? rc : count;
925} 925}
926static SYSDEV_ATTR(configure, 0644, cpu_configure_show, cpu_configure_store); 926static SYSDEV_ATTR(configure, 0644, cpu_configure_show, cpu_configure_store);
@@ -1095,8 +1095,8 @@ static ssize_t __ref rescan_store(struct sys_device *dev,
1095 int cpu; 1095 int cpu;
1096 int rc; 1096 int rc;
1097 1097
1098 mutex_lock(&smp_cpu_state_mutex);
1099 get_online_cpus(); 1098 get_online_cpus();
1099 mutex_lock(&smp_cpu_state_mutex);
1100 newcpus = cpu_present_map; 1100 newcpus = cpu_present_map;
1101 rc = smp_rescan_cpus(); 1101 rc = smp_rescan_cpus();
1102 if (rc) 1102 if (rc)
@@ -1109,8 +1109,8 @@ static ssize_t __ref rescan_store(struct sys_device *dev,
1109 } 1109 }
1110 rc = 0; 1110 rc = 0;
1111out: 1111out:
1112 put_online_cpus();
1113 mutex_unlock(&smp_cpu_state_mutex); 1112 mutex_unlock(&smp_cpu_state_mutex);
1113 put_online_cpus();
1114 if (!cpus_empty(newcpus)) 1114 if (!cpus_empty(newcpus))
1115 topology_schedule_update(); 1115 topology_schedule_update();
1116 return rc ? rc : count; 1116 return rc ? rc : count;
@@ -1139,16 +1139,16 @@ static ssize_t dispatching_store(struct sys_device *dev, const char *buf,
1139 if (val != 0 && val != 1) 1139 if (val != 0 && val != 1)
1140 return -EINVAL; 1140 return -EINVAL;
1141 rc = 0; 1141 rc = 0;
1142 mutex_lock(&smp_cpu_state_mutex);
1143 get_online_cpus(); 1142 get_online_cpus();
1143 mutex_lock(&smp_cpu_state_mutex);
1144 if (cpu_management == val) 1144 if (cpu_management == val)
1145 goto out; 1145 goto out;
1146 rc = topology_set_cpu_management(val); 1146 rc = topology_set_cpu_management(val);
1147 if (!rc) 1147 if (!rc)
1148 cpu_management = val; 1148 cpu_management = val;
1149out: 1149out:
1150 put_online_cpus();
1151 mutex_unlock(&smp_cpu_state_mutex); 1150 mutex_unlock(&smp_cpu_state_mutex);
1151 put_online_cpus();
1152 return rc ? rc : count; 1152 return rc ? rc : count;
1153} 1153}
1154static SYSDEV_ATTR(dispatching, 0644, dispatching_show, dispatching_store); 1154static SYSDEV_ATTR(dispatching, 0644, dispatching_show, dispatching_store);