Skip to contentSkip to conversation

Suspend2 merge: New exports.

PATCH In review Nigel Cunningham 4 participants 6 messages Sep 16, 2004 – Sep 17, 2004

Subsystems (13)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Suspend2 merge: New exports.

Hi.

This patch adds exports for functions used by suspend2. Needed, of course, when suspend is compiled as modules.

Regards,

Nigel

drivers/acpi/hardware/hwsleep.c +4 -0
diff -ruN linux-2.6.9-rc1/drivers/acpi/hardware/hwsleep.c software-suspend-linux-2.6.9-rc1-rev3/drivers/acpi/hardware/hwsleep.c
@@ -43,6 +43,7 @@
  */
 
 #include <acpi/acpi.h>
+#include <linux/module.h>
 
 #define _COMPONENT          ACPI_HARDWARE
 	 ACPI_MODULE_NAME    ("hwsleep")
@@ -591,3 +592,6 @@
 
 	return_ACPI_STATUS (status);
 }
+
+/* For suspend2 */
+EXPORT_SYMBOL(acpi_leave_sleep_state);
drivers/char/keyboard.c +1 -0
diff -ruN linux-2.6.9-rc1/drivers/char/keyboard.c software-suspend-linux-2.6.9-rc1-rev3/drivers/char/keyboard.c
@@ -258,6 +265,7 @@
 	} else
 		kd_nosound(0);
 }
+EXPORT_SYMBOL(kd_mksound);
 
 /*
  * Setting the keyboard rate.
fs/bio.c +1 -0
diff -ruN linux-2.6.9-rc1/fs/bio.c software-suspend-linux-2.6.9-rc1-rev3/fs/bio.c
@@ -977,3 +977,4 @@
 EXPORT_SYMBOL(bio_split_pool);
 EXPORT_SYMBOL(bio_copy_user);
 EXPORT_SYMBOL(bio_uncopy_user);
+EXPORT_SYMBOL(bio_set_pages_dirty);
fs/buffer.c +1 -1
diff -ruN linux-2.6.9-rc1/fs/buffer.c software-suspend-linux-2.6.9-rc1-rev3/fs/buffer.c
@@ -2916,7 +2975,7 @@
  *
  * try_to_free_buffers() is non-blocking.
  */
-static inline int buffer_busy(struct buffer_head *bh)
+inline int buffer_busy(struct buffer_head *bh)
 {
 	return atomic_read(&bh->b_count) |
 		(bh->b_state & ((1 << BH_Dirty) | (1 << BH_Lock)));
fs/ioctl.c +2 -3
diff -ruN linux-2.6.9-rc1/fs/ioctl.c software-suspend-linux-2.6.9-rc1-rev3/fs/ioctl.c
@@ -138,8 +138,7 @@
 
 /*
  * Platforms implementing 32 bit compatibility ioctl handlers in
- * modules need this exported
+ * modules need this exported. So does Suspend2 (when made as
+ * modules), so the export_symbol is now unconditional.
  */
-#ifdef CONFIG_COMPAT
 EXPORT_SYMBOL(sys_ioctl);
-#endif
fs/namei.c +2 -0
diff -ruN linux-2.6.9-rc1/fs/namei.c software-suspend-linux-2.6.9-rc1-rev3/fs/namei.c
@@ -1644,6 +1644,8 @@
 	return error;
 }
 
+EXPORT_SYMBOL(sys_mkdir);
+
 /*
  * We try to drop the dentry early: we should have
  * a usage count of 2 if we're the only user of this
fs/namespace.c +4 -0
diff -ruN linux-2.6.9-rc1/fs/namespace.c software-suspend-linux-2.6.9-rc1-rev3/fs/namespace.c
@@ -490,6 +490,8 @@
 	return retval;
 }
 
+EXPORT_SYMBOL(sys_umount);
+
 #ifdef __ARCH_WANT_SYS_OLDUMOUNT
 
 /*
@@ -1159,6 +1161,8 @@
 	return retval;
 }
 
+EXPORT_SYMBOL(sys_mount);
+
 /*
  * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
  * It can block. Requires the big lock held.
fs/proc/generic.c +2 -0
diff -ruN linux-2.6.9-rc1/fs/proc/generic.c software-suspend-linux-2.6.9-rc1-rev3/fs/proc/generic.c
@@ -698,3 +698,5 @@
 out:
 	return;
 }
+
+EXPORT_SYMBOL(proc_match);
fs/read_write.c +1 -0
diff -ruN linux-2.6.9-rc1/fs/read_write.c software-suspend-linux-2.6.9-rc1-rev3/fs/read_write.c
@@ -314,6 +314,7 @@
 
 	return ret;
 }
+EXPORT_SYMBOL(sys_write);
 
 asmlinkage ssize_t sys_pread64(unsigned int fd, char __user *buf,
 			     size_t count, loff_t pos)
kernel/panic.c +2 -0
diff -ruN linux-2.6.9-rc1/kernel/panic.c software-suspend-linux-2.6.9-rc1-rev3/kernel/panic.c
@@ -18,12 +18,14 @@
 #include <linux/sysrq.h>
 #include <linux/syscalls.h>
 #include <linux/interrupt.h>
+#include <linux/suspend.h>
 #include <linux/nmi.h>
 
 int panic_timeout;
 int panic_on_oops;
 int tainted;
 
+EXPORT_SYMBOL(tainted);
 EXPORT_SYMBOL(panic_timeout);
 
 struct notifier_block *panic_notifier_list;
kernel/power/main.c +4 -0
diff -ruN linux-2.6.9-rc1/kernel/power/main.c software-suspend-linux-2.6.9-rc1-rev3/kernel/power/main.c
@@ -257,3 +259,7 @@
 }
 
 core_initcall(pm_init);
+
+/* For Suspend2 ACPI support */
+EXPORT_SYMBOL(pm_ops);
+EXPORT_SYMBOL(pm_disk_mode);
kernel/sched.c +1 -0
diff -ruN linux-2.6.9-rc1/kernel/sched.c software-suspend-linux-2.6.9-rc1-rev3/kernel/sched.c
@@ -3265,6 +3264,7 @@
 
 	read_unlock(&tasklist_lock);
 }
+EXPORT_SYMBOL(show_state);
 
 void __devinit init_idle(task_t *idle, int cpu)
 {
kernel/sys.c +4 -0
diff -ruN linux-2.6.9-rc1/kernel/sys.c software-suspend-linux-2.6.9-rc1-rev3/kernel/sys.c
@@ -520,6 +524,8 @@
 	return 0;
 }
 
+EXPORT_SYMBOL(sys_reboot);
+
 static void deferred_cad(void *dummy)
 {
 	notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL);
@@ -1666,3 +1672,5 @@
 	}
 	return error;
 }
+
+EXPORT_SYMBOL(C_A_D);
kernel/timer.c +1 -0
diff -ruN linux-2.6.9-rc1/kernel/timer.c software-suspend-linux-2.6.9-rc1-rev3/kernel/timer.c
@@ -868,6 +868,7 @@
  * Requires xtime_lock to access.
  */
 unsigned long avenrun[3];
+EXPORT_SYMBOL(avenrun);
 
 /*
  * calc_load - given tick count, update the avenrun load estimates.
mm/page_alloc.c +7 -1
diff -ruN linux-2.6.9-rc1/mm/page_alloc.c software-suspend-linux-2.6.9-rc1-rev3/mm/page_alloc.c
@@ -72,7 +72,7 @@
 	return 0;
 }
 
-static void bad_page(const char *function, struct page *page)
+void bad_page(const char *function, struct page *page)
 {
 	printk(KERN_EMERG "Bad page state at %s (in process '%s', page %p)\n",
 		function, current->comm, page);
@@ -96,6 +96,8 @@
 	page->mapcount = 0;
 }
 
+EXPORT_SYMBOL(bad_page);
+
 #ifndef CONFIG_HUGETLB_PAGE
 #define prep_compound_page(page, order) do { } while (0)
 #define destroy_compound_page(page, order) do { } while (0)
@@ -2050,3 +2086,7 @@
 
 	return table;
 }
+
+/* Exported for Software Suspend 2 */
+EXPORT_SYMBOL(nr_free_highpages);
+EXPORT_SYMBOL(pgdat_list);
mm/page-writeback.c +1 -0
diff -ruN linux-2.6.9-rc1/mm/page-writeback.c software-suspend-linux-2.6.9-rc1-rev3/mm/page-writeback.c
@@ -329,6 +330,7 @@
 	}
 	return pdflush_operation(background_writeout, nr_pages);
 }
+EXPORT_SYMBOL(wakeup_bdflush);
 
 static void wb_timer_fn(unsigned long unused);
 static void laptop_timer_fn(unsigned long unused);
mm/swapfile.c +10 -0
diff -ruN linux-2.6.9-rc1/mm/swapfile.c software-suspend-linux-2.6.9-rc1-rev3/mm/swapfile.c
@@ -1679,3 +1681,13 @@
 	swap_device_unlock(swapdev);
 	return ret;
 }
+
+/* Functions exported for Software Suspend's swapwriter */
+EXPORT_SYMBOL(swap_free);
+EXPORT_SYMBOL(swap_info);
+EXPORT_SYMBOL(sys_swapoff);
+EXPORT_SYMBOL(sys_swapon);
+EXPORT_SYMBOL(si_swapinfo);
+EXPORT_SYMBOL(map_swap_page);
+EXPORT_SYMBOL(get_swap_page);
+EXPORT_SYMBOL(get_swap_info_struct);
mm/vmscan.c +3 -0
diff -ruN linux-2.6.9-rc1/mm/vmscan.c software-suspend-linux-2.6.9-rc1-rev3/mm/vmscan.c
@@ -1237,3 +1237,6 @@
 }
 
 module_init(kswapd_init)
+
+/* For Suspend2 */	
+EXPORT_SYMBOL(shrink_all_memory);
Signature · 7 lines
Nigel Cunningham
Pastoral Worker
Christian Reformed Church of Tuggeranong
PO Box 1004, Tuggeranong, ACT 2901

Many today claim to be tolerant. True tolerance, however, can cope with others
being intolerant.
#1 lore raw
Quoted 2 lines · Nigel Cunningham

+EXPORT_SYMBOL(tainted);

uhhhhh why do you need this in a module ?????

most of these exports look REALLY fishy to me.

#2 lore raw

Hi.

Quoted 8 lines · Arjan van de Ven
Quoted 2 lines · Nigel Cunningham

+EXPORT_SYMBOL(tainted);

uhhhhh why do you need this in a module ?????

most of these exports look REALLY fishy to me.

I'm marking the kernel as tainted when we've suspended. It could probably be dropped but I was erring on the side of paranoia.

As to the others, I'll be happy to explain how they're used and drop them if necessary/possible. I agree about a couple. The keyboard sound one, for example, slipped past my purge of some report-progress-while-beeping code I inherited.

Regards,

Nigel

Signature · 7 lines
Nigel Cunningham
Pastoral Worker
Christian Reformed Church of Tuggeranong
PO Box 1004, Tuggeranong, ACT 2901

Many today claim to be tolerant. True tolerance, however, can cope with others
being intolerant.
#3 lore raw
In reply to Nigel Cunningham
Quoted 3 lines · Nigel Cunningham

This patch adds exports for functions used by suspend2. Needed, of course, when suspend is compiled as modules.

Why even allow suspend as a module? It seems like a pretty core chunk of code that should be present all the time.

fs/buffer.c line 2981

Quoted 12 lines

diff -ruN linux-2.6.9-rc1/fs/buffer.c software-suspend-linux-2.6.9-rc1-rev3/fs/buffer.c

fs/buffer.c +1 -1
@@ -2916,7 +2975,7 @@
  *
  * try_to_free_buffers() is non-blocking.
  */
-static inline int buffer_busy(struct buffer_head *bh)
+inline int buffer_busy(struct buffer_head *bh)
 {
 	return atomic_read(&bh->b_count) |
 		(bh->b_state & ((1 << BH_Dirty) | (1 << BH_Lock)));

Why this change? buffer_busy() is not exported now.

Quoted 4 lines

diff -ruN linux-2.6.9-rc1/fs/ioctl.c software-suspend-linux-2.6.9-rc1-rev3/fs/ioctl.c

fs/ioctl.c line 145

Quoted 10 lines
fs/ioctl.c +2 -3
@@ -138,8 +138,7 @@
 
 /*
  * Platforms implementing 32 bit compatibility ioctl handlers in
- * modules need this exported
+ * modules need this exported. So does Suspend2 (when made as
+ * modules), so the export_symbol is now unconditional.
  */
-#ifdef CONFIG_COMPAT
 EXPORT_SYMBOL(sys_ioctl);
-#endif

What ioctls does suspend2 call? That seems very strange.

Quoted 8 lines

diff -ruN linux-2.6.9-rc1/kernel/panic.c software-suspend-linux-2.6.9-rc1-rev3/kernel/panic.c

kernel/panic.c +1 -0
@@ -18,12 +18,14 @@
 #include <linux/sysrq.h>
 #include <linux/syscalls.h>
 #include <linux/interrupt.h>
+#include <linux/suspend.h>

kernel/panic.c line 31

Quoted 10 lines
kernel/panic.c +1 -0
 #include <linux/nmi.h>
 
 int panic_timeout;
 int panic_on_oops;
 int tainted;
 
+EXPORT_SYMBOL(tainted);
 EXPORT_SYMBOL(panic_timeout);
 
 struct notifier_block *panic_notifier_list;

Why is the include needed here just to export a symbol (nevermind the fact that we should never export tainted in the first place.)

thanks,

greg k-h

#4 lore raw

Hi.

Quoted 7 lines · Greg KH
Quoted 3 lines · Nigel Cunningham

This patch adds exports for functions used by suspend2. Needed, of course, when suspend is compiled as modules.

Why even allow suspend as a module? It seems like a pretty core chunk of code that should be present all the time.

It only needs to be loaded when you're suspending/resuming, so it's not really core. Building it as modules also allows upgrading (at least sometimes) without rebooting. Finally, my version of suspend is a lot bigger than the implementation in the kernel at the moment because it includes many more features.

[...]

Quoted 1 line

Why this change? buffer_busy() is not exported now.

You're right. It's a holdover from 2.4 that I missed cleaning.

Quoted 5 lines

fs/ioctl.c line 145

Quoted 3 lines
fs/ioctl.c +0 -2
-#ifdef CONFIG_COMPAT
 EXPORT_SYMBOL(sys_ioctl);
-#endif

What ioctls does suspend2 call? That seems very strange.

The console driver. People objected to direct usage of console functions and suggested I use /dev/console for doing output. That's what I'm doing now, although I do still have some direct usage to seek to get rid of. (I'm not claiming my code is finished and perfect!)

Quoted 2 lines

Why is the include needed here just to export a symbol (nevermind the fact that we should never export tainted in the first place.)

They're unrelated, actually. There used to be a couple of lines in here that stopped us syncing if we oops part way through suspending. With recent changes, it's no longer necessary. The fact that the include isn't needed anymore wasn't noticed.

As to exporting tainted, I thought about this on the way to bed last night, after another email. As I said previously, I was exporting it so I could set a tainted flag when we've suspended, to save driver authors headaches. It never occurred to me - as it has now - that this also allows unscrupulous people to turn off flags. I don't think tainting is necessary any more, so I'll happily drop this.

Regards,

Nigel

Signature · 7 lines
Nigel Cunningham
Pastoral Worker
Christian Reformed Church of Tuggeranong
PO Box 1004, Tuggeranong, ACT 2901

Many today claim to be tolerant. True tolerance, however, can cope with others
being intolerant.
#5 lore raw
In reply to Nigel Cunningham
Quoted 1 line

+EXPORT_SYMBOL(kd_mksound);

nope.

Quoted 1 line

+inline int buffer_busy(struct buffer_head *bh)

huh?

fs/ioctl.c line 145

Quoted 3 lines
fs/ioctl.c +0 -2
-#ifdef CONFIG_COMPAT
 EXPORT_SYMBOL(sys_ioctl);
-#endif

No way, sorry.

Quoted 1 line

+EXPORT_SYMBOL(sys_mkdir);

Dito. WTF are you trying to do?

Quoted 1 line

+EXPORT_SYMBOL(sys_umount);

Dito.

Quoted 1 line

+EXPORT_SYMBOL(sys_mount);

Dito.

Quoted 1 line

+EXPORT_SYMBOL(proc_match);

Gad.

Quoted 1 line

+EXPORT_SYMBOL(sys_write);

nope. This really looks like you want to put a userland program into the kernel.

Quoted 1 line

+EXPORT_SYMBOL(tainted);

Umm, no way again.