Skip to contentSkip to conversation

kexec jump: clean up #ifdef and comments

PATCH In review Huang Ying 3 participants 4 messages Aug 12, 2008 – Aug 13, 2008

Subsystems (3)
lore
Share & tools
lore

Huang Ying

author
#0 lore raw

PATCH 1/7 kexec jump: clean up #ifdef and comments

Move if (kexec_image->preserve_context) { ... } into #ifdef CONFIG_KEXEC_JUMP to make code looks cleaner.

Fix no longer correct comments of kernel_kexec().

---
 kernel/kexec.c |   17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
kernel/kexec.c +8 -9
@@ -1426,11 +1426,9 @@ static int __init crash_save_vmcoreinfo_
 
 module_init(crash_save_vmcoreinfo_init)
 
-/**
- *	kernel_kexec - reboot the system
- *
- *	Move into place and start executing a preloaded standalone
- *	executable.  If nothing was preloaded return an error.
+/*
+ * Move into place and start executing a preloaded standalone
+ * executable.  If nothing was preloaded return an error.
  */
 int kernel_kexec(void)
 {
@@ -1443,8 +1441,8 @@ int kernel_kexec(void)
 		goto Unlock;
 	}
 
-	if (kexec_image->preserve_context) {
 #ifdef CONFIG_KEXEC_JUMP
+	if (kexec_image->preserve_context) {
 		mutex_lock(&pm_mutex);
 		pm_prepare_console();
 		error = freeze_processes();
@@ -1471,8 +1469,9 @@ int kernel_kexec(void)
 		if (error)
 			goto Enable_irqs;
 		save_processor_state();
+	} else
 #endif
-	} else {
+	{
 		blocking_notifier_call_chain(&reboot_notifier_list,
 					     SYS_RESTART, NULL);
 		system_state = SYSTEM_RESTART;
@@ -1484,8 +1483,8 @@ int kernel_kexec(void)
 
 	machine_kexec(kexec_image);
 
-	if (kexec_image->preserve_context) {
 #ifdef CONFIG_KEXEC_JUMP
+	if (kexec_image->preserve_context) {
 		restore_processor_state();
 		device_power_up(PMSG_RESTORE);
  Enable_irqs:
@@ -1499,8 +1498,8 @@ int kernel_kexec(void)
  Restore_console:
 		pm_restore_console();
 		mutex_unlock(&pm_mutex);
-#endif
 	}
+#endif
 
  Unlock:
 	xchg(&kexec_lock, 0);

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

maintainer
#1 lore raw
Quoted 1 line · On Tue, 12 Aug 2008 11:14:21 +0800 Huang Ying <[email protected]> wrote:

xchg(&kexec_lock, 0);

kernel/kexec.c: In function 'kernel_kexec':
kernel/kexec.c:1501: warning: value computed is not used

Is there any reason why we cannot use the more conventional test_and_set_bit() etc, rather than this peculiarity?

Or perhaps spin_trylock?

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

author
#2 lore raw
Quoted 11 lines · Andrew Morton
Quoted 1 line · On Tue, 12 Aug 2008 11:14:21 +0800 Huang Ying <[email protected]> wrote:

xchg(&kexec_lock, 0);

kernel/kexec.c: In function 'kernel_kexec':
kernel/kexec.c:1501: warning: value computed is not used

Is there any reason why we cannot use the more conventional test_and_set_bit() etc, rather than this peculiarity?

Or perhaps spin_trylock?

Hi, Andrew,

I think it is of no problem to replace xchg() with test_and_set_bit() or spin_trylock().

Hi, Eric,

Do you have some reason to use xchg() instead of others?

Best Regards,
Huang Ying

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#3 lore raw
In reply to Andrew Morton
Quoted 6 lines · Andrew Morton
Quoted 1 line · On Tue, 12 Aug 2008 11:14:21 +0800 Huang Ying <[email protected]> wrote:

xchg(&kexec_lock, 0);

kernel/kexec.c: In function 'kernel_kexec':
kernel/kexec.c:1501: warning: value computed is not used

A good question is why we are warned.

Quoted 4 lines

Is there any reason why we cannot use the more conventional test_and_set_bit() etc, rather than this peculiarity?

Or perhaps spin_trylock?

Totally odd.

Let me stop and take a look and see what has been changed. The original code used a xchg based read copy update scheme, which was extremely compatible with a lot of goals. The primary one being no blocking paths in a successful kexec, and minimal dependence on library functions.

We need that minimal dependence to handle the kexec on panic case.

That doesn't rule out something like test_and_set_bit.

Eric

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec