diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/printk.c | 100 | ||||
-rw-r--r-- | kernel/sysctl.c | 3 |
2 files changed, 56 insertions, 47 deletions
diff --git a/kernel/printk.c b/kernel/printk.c index 53d9a9ec88e6..2ddbdc73aade 100644 --- a/kernel/printk.c +++ b/kernel/printk.c | |||
@@ -97,7 +97,7 @@ static int console_locked, console_suspended; | |||
97 | /* | 97 | /* |
98 | * logbuf_lock protects log_buf, log_start, log_end, con_start and logged_chars | 98 | * logbuf_lock protects log_buf, log_start, log_end, con_start and logged_chars |
99 | * It is also used in interesting ways to provide interlocking in | 99 | * It is also used in interesting ways to provide interlocking in |
100 | * release_console_sem(). | 100 | * console_unlock();. |
101 | */ | 101 | */ |
102 | static DEFINE_SPINLOCK(logbuf_lock); | 102 | static DEFINE_SPINLOCK(logbuf_lock); |
103 | 103 | ||
@@ -501,7 +501,7 @@ static void _call_console_drivers(unsigned start, | |||
501 | /* | 501 | /* |
502 | * Call the console drivers, asking them to write out | 502 | * Call the console drivers, asking them to write out |
503 | * log_buf[start] to log_buf[end - 1]. | 503 | * log_buf[start] to log_buf[end - 1]. |
504 | * The console_sem must be held. | 504 | * The console_lock must be held. |
505 | */ | 505 | */ |
506 | static void call_console_drivers(unsigned start, unsigned end) | 506 | static void call_console_drivers(unsigned start, unsigned end) |
507 | { | 507 | { |
@@ -604,11 +604,11 @@ static int have_callable_console(void) | |||
604 | * | 604 | * |
605 | * This is printk(). It can be called from any context. We want it to work. | 605 | * This is printk(). It can be called from any context. We want it to work. |
606 | * | 606 | * |
607 | * We try to grab the console_sem. If we succeed, it's easy - we log the output and | 607 | * We try to grab the console_lock. If we succeed, it's easy - we log the output and |
608 | * call the console drivers. If we fail to get the semaphore we place the output | 608 | * call the console drivers. If we fail to get the semaphore we place the output |
609 | * into the log buffer and return. The current holder of the console_sem will | 609 | * into the log buffer and return. The current holder of the console_sem will |
610 | * notice the new output in release_console_sem() and will send it to the | 610 | * notice the new output in console_unlock(); and will send it to the |
611 | * consoles before releasing the semaphore. | 611 | * consoles before releasing the lock. |
612 | * | 612 | * |
613 | * One effect of this deferred printing is that code which calls printk() and | 613 | * One effect of this deferred printing is that code which calls printk() and |
614 | * then changes console_loglevel may break. This is because console_loglevel | 614 | * then changes console_loglevel may break. This is because console_loglevel |
@@ -659,19 +659,19 @@ static inline int can_use_console(unsigned int cpu) | |||
659 | /* | 659 | /* |
660 | * Try to get console ownership to actually show the kernel | 660 | * Try to get console ownership to actually show the kernel |
661 | * messages from a 'printk'. Return true (and with the | 661 | * messages from a 'printk'. Return true (and with the |
662 | * console_semaphore held, and 'console_locked' set) if it | 662 | * console_lock held, and 'console_locked' set) if it |
663 | * is successful, false otherwise. | 663 | * is successful, false otherwise. |
664 | * | 664 | * |
665 | * This gets called with the 'logbuf_lock' spinlock held and | 665 | * This gets called with the 'logbuf_lock' spinlock held and |
666 | * interrupts disabled. It should return with 'lockbuf_lock' | 666 | * interrupts disabled. It should return with 'lockbuf_lock' |
667 | * released but interrupts still disabled. | 667 | * released but interrupts still disabled. |
668 | */ | 668 | */ |
669 | static int acquire_console_semaphore_for_printk(unsigned int cpu) | 669 | static int console_trylock_for_printk(unsigned int cpu) |
670 | __releases(&logbuf_lock) | 670 | __releases(&logbuf_lock) |
671 | { | 671 | { |
672 | int retval = 0; | 672 | int retval = 0; |
673 | 673 | ||
674 | if (!try_acquire_console_sem()) { | 674 | if (console_trylock()) { |
675 | retval = 1; | 675 | retval = 1; |
676 | 676 | ||
677 | /* | 677 | /* |
@@ -827,12 +827,12 @@ asmlinkage int vprintk(const char *fmt, va_list args) | |||
827 | * actual magic (print out buffers, wake up klogd, | 827 | * actual magic (print out buffers, wake up klogd, |
828 | * etc). | 828 | * etc). |
829 | * | 829 | * |
830 | * The acquire_console_semaphore_for_printk() function | 830 | * The console_trylock_for_printk() function |
831 | * will release 'logbuf_lock' regardless of whether it | 831 | * will release 'logbuf_lock' regardless of whether it |
832 | * actually gets the semaphore or not. | 832 | * actually gets the semaphore or not. |
833 | */ | 833 | */ |
834 | if (acquire_console_semaphore_for_printk(this_cpu)) | 834 | if (console_trylock_for_printk(this_cpu)) |
835 | release_console_sem(); | 835 | console_unlock(); |
836 | 836 | ||
837 | lockdep_on(); | 837 | lockdep_on(); |
838 | out_restore_irqs: | 838 | out_restore_irqs: |
@@ -993,7 +993,7 @@ void suspend_console(void) | |||
993 | if (!console_suspend_enabled) | 993 | if (!console_suspend_enabled) |
994 | return; | 994 | return; |
995 | printk("Suspending console(s) (use no_console_suspend to debug)\n"); | 995 | printk("Suspending console(s) (use no_console_suspend to debug)\n"); |
996 | acquire_console_sem(); | 996 | console_lock(); |
997 | console_suspended = 1; | 997 | console_suspended = 1; |
998 | up(&console_sem); | 998 | up(&console_sem); |
999 | } | 999 | } |
@@ -1004,7 +1004,7 @@ void resume_console(void) | |||
1004 | return; | 1004 | return; |
1005 | down(&console_sem); | 1005 | down(&console_sem); |
1006 | console_suspended = 0; | 1006 | console_suspended = 0; |
1007 | release_console_sem(); | 1007 | console_unlock(); |
1008 | } | 1008 | } |
1009 | 1009 | ||
1010 | /** | 1010 | /** |
@@ -1027,21 +1027,21 @@ static int __cpuinit console_cpu_notify(struct notifier_block *self, | |||
1027 | case CPU_DYING: | 1027 | case CPU_DYING: |
1028 | case CPU_DOWN_FAILED: | 1028 | case CPU_DOWN_FAILED: |
1029 | case CPU_UP_CANCELED: | 1029 | case CPU_UP_CANCELED: |
1030 | acquire_console_sem(); | 1030 | console_lock(); |
1031 | release_console_sem(); | 1031 | console_unlock(); |
1032 | } | 1032 | } |
1033 | return NOTIFY_OK; | 1033 | return NOTIFY_OK; |
1034 | } | 1034 | } |
1035 | 1035 | ||
1036 | /** | 1036 | /** |
1037 | * acquire_console_sem - lock the console system for exclusive use. | 1037 | * console_lock - lock the console system for exclusive use. |
1038 | * | 1038 | * |
1039 | * Acquires a semaphore which guarantees that the caller has | 1039 | * Acquires a lock which guarantees that the caller has |
1040 | * exclusive access to the console system and the console_drivers list. | 1040 | * exclusive access to the console system and the console_drivers list. |
1041 | * | 1041 | * |
1042 | * Can sleep, returns nothing. | 1042 | * Can sleep, returns nothing. |
1043 | */ | 1043 | */ |
1044 | void acquire_console_sem(void) | 1044 | void console_lock(void) |
1045 | { | 1045 | { |
1046 | BUG_ON(in_interrupt()); | 1046 | BUG_ON(in_interrupt()); |
1047 | down(&console_sem); | 1047 | down(&console_sem); |
@@ -1050,21 +1050,29 @@ void acquire_console_sem(void) | |||
1050 | console_locked = 1; | 1050 | console_locked = 1; |
1051 | console_may_schedule = 1; | 1051 | console_may_schedule = 1; |
1052 | } | 1052 | } |
1053 | EXPORT_SYMBOL(acquire_console_sem); | 1053 | EXPORT_SYMBOL(console_lock); |
1054 | 1054 | ||
1055 | int try_acquire_console_sem(void) | 1055 | /** |
1056 | * console_trylock - try to lock the console system for exclusive use. | ||
1057 | * | ||
1058 | * Tried to acquire a lock which guarantees that the caller has | ||
1059 | * exclusive access to the console system and the console_drivers list. | ||
1060 | * | ||
1061 | * returns 1 on success, and 0 on failure to acquire the lock. | ||
1062 | */ | ||
1063 | int console_trylock(void) | ||
1056 | { | 1064 | { |
1057 | if (down_trylock(&console_sem)) | 1065 | if (down_trylock(&console_sem)) |
1058 | return -1; | 1066 | return 0; |
1059 | if (console_suspended) { | 1067 | if (console_suspended) { |
1060 | up(&console_sem); | 1068 | up(&console_sem); |
1061 | return -1; | 1069 | return 0; |
1062 | } | 1070 | } |
1063 | console_locked = 1; | 1071 | console_locked = 1; |
1064 | console_may_schedule = 0; | 1072 | console_may_schedule = 0; |
1065 | return 0; | 1073 | return 1; |
1066 | } | 1074 | } |
1067 | EXPORT_SYMBOL(try_acquire_console_sem); | 1075 | EXPORT_SYMBOL(console_trylock); |
1068 | 1076 | ||
1069 | int is_console_locked(void) | 1077 | int is_console_locked(void) |
1070 | { | 1078 | { |
@@ -1095,20 +1103,20 @@ void wake_up_klogd(void) | |||
1095 | } | 1103 | } |
1096 | 1104 | ||
1097 | /** | 1105 | /** |
1098 | * release_console_sem - unlock the console system | 1106 | * console_unlock - unlock the console system |
1099 | * | 1107 | * |
1100 | * Releases the semaphore which the caller holds on the console system | 1108 | * Releases the console_lock which the caller holds on the console system |
1101 | * and the console driver list. | 1109 | * and the console driver list. |
1102 | * | 1110 | * |
1103 | * While the semaphore was held, console output may have been buffered | 1111 | * While the console_lock was held, console output may have been buffered |
1104 | * by printk(). If this is the case, release_console_sem() emits | 1112 | * by printk(). If this is the case, console_unlock(); emits |
1105 | * the output prior to releasing the semaphore. | 1113 | * the output prior to releasing the lock. |
1106 | * | 1114 | * |
1107 | * If there is output waiting for klogd, we wake it up. | 1115 | * If there is output waiting for klogd, we wake it up. |
1108 | * | 1116 | * |
1109 | * release_console_sem() may be called from any context. | 1117 | * console_unlock(); may be called from any context. |
1110 | */ | 1118 | */ |
1111 | void release_console_sem(void) | 1119 | void console_unlock(void) |
1112 | { | 1120 | { |
1113 | unsigned long flags; | 1121 | unsigned long flags; |
1114 | unsigned _con_start, _log_end; | 1122 | unsigned _con_start, _log_end; |
@@ -1141,7 +1149,7 @@ void release_console_sem(void) | |||
1141 | if (wake_klogd) | 1149 | if (wake_klogd) |
1142 | wake_up_klogd(); | 1150 | wake_up_klogd(); |
1143 | } | 1151 | } |
1144 | EXPORT_SYMBOL(release_console_sem); | 1152 | EXPORT_SYMBOL(console_unlock); |
1145 | 1153 | ||
1146 | /** | 1154 | /** |
1147 | * console_conditional_schedule - yield the CPU if required | 1155 | * console_conditional_schedule - yield the CPU if required |
@@ -1150,7 +1158,7 @@ EXPORT_SYMBOL(release_console_sem); | |||
1150 | * if this CPU should yield the CPU to another task, do | 1158 | * if this CPU should yield the CPU to another task, do |
1151 | * so here. | 1159 | * so here. |
1152 | * | 1160 | * |
1153 | * Must be called within acquire_console_sem(). | 1161 | * Must be called within console_lock();. |
1154 | */ | 1162 | */ |
1155 | void __sched console_conditional_schedule(void) | 1163 | void __sched console_conditional_schedule(void) |
1156 | { | 1164 | { |
@@ -1171,14 +1179,14 @@ void console_unblank(void) | |||
1171 | if (down_trylock(&console_sem) != 0) | 1179 | if (down_trylock(&console_sem) != 0) |
1172 | return; | 1180 | return; |
1173 | } else | 1181 | } else |
1174 | acquire_console_sem(); | 1182 | console_lock(); |
1175 | 1183 | ||
1176 | console_locked = 1; | 1184 | console_locked = 1; |
1177 | console_may_schedule = 0; | 1185 | console_may_schedule = 0; |
1178 | for_each_console(c) | 1186 | for_each_console(c) |
1179 | if ((c->flags & CON_ENABLED) && c->unblank) | 1187 | if ((c->flags & CON_ENABLED) && c->unblank) |
1180 | c->unblank(); | 1188 | c->unblank(); |
1181 | release_console_sem(); | 1189 | console_unlock(); |
1182 | } | 1190 | } |
1183 | 1191 | ||
1184 | /* | 1192 | /* |
@@ -1189,7 +1197,7 @@ struct tty_driver *console_device(int *index) | |||
1189 | struct console *c; | 1197 | struct console *c; |
1190 | struct tty_driver *driver = NULL; | 1198 | struct tty_driver *driver = NULL; |
1191 | 1199 | ||
1192 | acquire_console_sem(); | 1200 | console_lock(); |
1193 | for_each_console(c) { | 1201 | for_each_console(c) { |
1194 | if (!c->device) | 1202 | if (!c->device) |
1195 | continue; | 1203 | continue; |
@@ -1197,7 +1205,7 @@ struct tty_driver *console_device(int *index) | |||
1197 | if (driver) | 1205 | if (driver) |
1198 | break; | 1206 | break; |
1199 | } | 1207 | } |
1200 | release_console_sem(); | 1208 | console_unlock(); |
1201 | return driver; | 1209 | return driver; |
1202 | } | 1210 | } |
1203 | 1211 | ||
@@ -1208,17 +1216,17 @@ struct tty_driver *console_device(int *index) | |||
1208 | */ | 1216 | */ |
1209 | void console_stop(struct console *console) | 1217 | void console_stop(struct console *console) |
1210 | { | 1218 | { |
1211 | acquire_console_sem(); | 1219 | console_lock(); |
1212 | console->flags &= ~CON_ENABLED; | 1220 | console->flags &= ~CON_ENABLED; |
1213 | release_console_sem(); | 1221 | console_unlock(); |
1214 | } | 1222 | } |
1215 | EXPORT_SYMBOL(console_stop); | 1223 | EXPORT_SYMBOL(console_stop); |
1216 | 1224 | ||
1217 | void console_start(struct console *console) | 1225 | void console_start(struct console *console) |
1218 | { | 1226 | { |
1219 | acquire_console_sem(); | 1227 | console_lock(); |
1220 | console->flags |= CON_ENABLED; | 1228 | console->flags |= CON_ENABLED; |
1221 | release_console_sem(); | 1229 | console_unlock(); |
1222 | } | 1230 | } |
1223 | EXPORT_SYMBOL(console_start); | 1231 | EXPORT_SYMBOL(console_start); |
1224 | 1232 | ||
@@ -1340,7 +1348,7 @@ void register_console(struct console *newcon) | |||
1340 | * Put this console in the list - keep the | 1348 | * Put this console in the list - keep the |
1341 | * preferred driver at the head of the list. | 1349 | * preferred driver at the head of the list. |
1342 | */ | 1350 | */ |
1343 | acquire_console_sem(); | 1351 | console_lock(); |
1344 | if ((newcon->flags & CON_CONSDEV) || console_drivers == NULL) { | 1352 | if ((newcon->flags & CON_CONSDEV) || console_drivers == NULL) { |
1345 | newcon->next = console_drivers; | 1353 | newcon->next = console_drivers; |
1346 | console_drivers = newcon; | 1354 | console_drivers = newcon; |
@@ -1352,14 +1360,14 @@ void register_console(struct console *newcon) | |||
1352 | } | 1360 | } |
1353 | if (newcon->flags & CON_PRINTBUFFER) { | 1361 | if (newcon->flags & CON_PRINTBUFFER) { |
1354 | /* | 1362 | /* |
1355 | * release_console_sem() will print out the buffered messages | 1363 | * console_unlock(); will print out the buffered messages |
1356 | * for us. | 1364 | * for us. |
1357 | */ | 1365 | */ |
1358 | spin_lock_irqsave(&logbuf_lock, flags); | 1366 | spin_lock_irqsave(&logbuf_lock, flags); |
1359 | con_start = log_start; | 1367 | con_start = log_start; |
1360 | spin_unlock_irqrestore(&logbuf_lock, flags); | 1368 | spin_unlock_irqrestore(&logbuf_lock, flags); |
1361 | } | 1369 | } |
1362 | release_console_sem(); | 1370 | console_unlock(); |
1363 | console_sysfs_notify(); | 1371 | console_sysfs_notify(); |
1364 | 1372 | ||
1365 | /* | 1373 | /* |
@@ -1396,7 +1404,7 @@ int unregister_console(struct console *console) | |||
1396 | return braille_unregister_console(console); | 1404 | return braille_unregister_console(console); |
1397 | #endif | 1405 | #endif |
1398 | 1406 | ||
1399 | acquire_console_sem(); | 1407 | console_lock(); |
1400 | if (console_drivers == console) { | 1408 | if (console_drivers == console) { |
1401 | console_drivers=console->next; | 1409 | console_drivers=console->next; |
1402 | res = 0; | 1410 | res = 0; |
@@ -1418,7 +1426,7 @@ int unregister_console(struct console *console) | |||
1418 | if (console_drivers != NULL && console->flags & CON_CONSDEV) | 1426 | if (console_drivers != NULL && console->flags & CON_CONSDEV) |
1419 | console_drivers->flags |= CON_CONSDEV; | 1427 | console_drivers->flags |= CON_CONSDEV; |
1420 | 1428 | ||
1421 | release_console_sem(); | 1429 | console_unlock(); |
1422 | console_sysfs_notify(); | 1430 | console_sysfs_notify(); |
1423 | return res; | 1431 | return res; |
1424 | } | 1432 | } |
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index bc86bb32e126..0f1bd83db985 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -170,7 +170,8 @@ static int proc_taint(struct ctl_table *table, int write, | |||
170 | #endif | 170 | #endif |
171 | 171 | ||
172 | #ifdef CONFIG_MAGIC_SYSRQ | 172 | #ifdef CONFIG_MAGIC_SYSRQ |
173 | static int __sysrq_enabled; /* Note: sysrq code ises it's own private copy */ | 173 | /* Note: sysrq code uses it's own private copy */ |
174 | static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE; | ||
174 | 175 | ||
175 | static int sysrq_sysctl_handler(ctl_table *table, int write, | 176 | static int sysrq_sysctl_handler(ctl_table *table, int write, |
176 | void __user *buffer, size_t *lenp, | 177 | void __user *buffer, size_t *lenp, |