2004-09-16 11:19:27

by Nigel Cunningham

[permalink] [raw]
Subject: [PATCH] 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

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
--- linux-2.6.9-rc1/drivers/acpi/hardware/hwsleep.c 2004-09-07 21:58:30.000000000 +1000
+++ software-suspend-linux-2.6.9-rc1-rev3/drivers/acpi/hardware/hwsleep.c 2004-09-09 19:36:24.000000000 +1000
@@ -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);
diff -ruN linux-2.6.9-rc1/drivers/char/keyboard.c software-suspend-linux-2.6.9-rc1-rev3/drivers/char/keyboard.c
--- linux-2.6.9-rc1/drivers/char/keyboard.c 2004-09-07 21:58:31.000000000 +1000
+++ software-suspend-linux-2.6.9-rc1-rev3/drivers/char/keyboard.c 2004-09-09 19:36:24.000000000 +1000
@@ -258,6 +265,7 @@
} else
kd_nosound(0);
}
+EXPORT_SYMBOL(kd_mksound);

/*
* Setting the keyboard rate.
diff -ruN linux-2.6.9-rc1/fs/bio.c software-suspend-linux-2.6.9-rc1-rev3/fs/bio.c
--- linux-2.6.9-rc1/fs/bio.c 2004-09-07 21:58:52.000000000 +1000
+++ software-suspend-linux-2.6.9-rc1-rev3/fs/bio.c 2004-09-09 19:36:24.000000000 +1000
@@ -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);
diff -ruN linux-2.6.9-rc1/fs/buffer.c software-suspend-linux-2.6.9-rc1-rev3/fs/buffer.c
--- linux-2.6.9-rc1/fs/buffer.c 2004-09-07 21:58:52.000000000 +1000
+++ software-suspend-linux-2.6.9-rc1-rev3/fs/buffer.c 2004-09-09 19:36:24.000000000 +1000
@@ -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)));
diff -ruN linux-2.6.9-rc1/fs/ioctl.c software-suspend-linux-2.6.9-rc1-rev3/fs/ioctl.c
--- linux-2.6.9-rc1/fs/ioctl.c 2004-09-07 21:58:53.000000000 +1000
+++ software-suspend-linux-2.6.9-rc1-rev3/fs/ioctl.c 2004-09-09 19:36:24.000000000 +1000
@@ -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
diff -ruN linux-2.6.9-rc1/fs/namei.c software-suspend-linux-2.6.9-rc1-rev3/fs/namei.c
--- linux-2.6.9-rc1/fs/namei.c 2004-09-07 21:58:53.000000000 +1000
+++ software-suspend-linux-2.6.9-rc1-rev3/fs/namei.c 2004-09-09 19:36:24.000000000 +1000
@@ -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
diff -ruN linux-2.6.9-rc1/fs/namespace.c software-suspend-linux-2.6.9-rc1-rev3/fs/namespace.c
--- linux-2.6.9-rc1/fs/namespace.c 2004-09-07 21:58:53.000000000 +1000
+++ software-suspend-linux-2.6.9-rc1-rev3/fs/namespace.c 2004-09-09 19:36:24.000000000 +1000
@@ -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.
diff -ruN linux-2.6.9-rc1/fs/proc/generic.c software-suspend-linux-2.6.9-rc1-rev3/fs/proc/generic.c
--- linux-2.6.9-rc1/fs/proc/generic.c 2004-09-07 21:58:54.000000000 +1000
+++ software-suspend-linux-2.6.9-rc1-rev3/fs/proc/generic.c 2004-09-09 19:36:24.000000000 +1000
@@ -698,3 +698,5 @@
out:
return;
}
+
+EXPORT_SYMBOL(proc_match);
diff -ruN linux-2.6.9-rc1/fs/read_write.c software-suspend-linux-2.6.9-rc1-rev3/fs/read_write.c
--- linux-2.6.9-rc1/fs/read_write.c 2004-09-07 21:58:54.000000000 +1000
+++ software-suspend-linux-2.6.9-rc1-rev3/fs/read_write.c 2004-09-09 19:36:24.000000000 +1000
@@ -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)
diff -ruN linux-2.6.9-rc1/kernel/panic.c software-suspend-linux-2.6.9-rc1-rev3/kernel/panic.c
--- linux-2.6.9-rc1/kernel/panic.c 2004-09-07 21:59:00.000000000 +1000
+++ software-suspend-linux-2.6.9-rc1-rev3/kernel/panic.c 2004-09-09 19:36:24.000000000 +1000
@@ -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;
diff -ruN linux-2.6.9-rc1/kernel/power/main.c software-suspend-linux-2.6.9-rc1-rev3/kernel/power/main.c
--- linux-2.6.9-rc1/kernel/power/main.c 2004-05-27 23:16:45.000000000 +1000
+++ software-suspend-linux-2.6.9-rc1-rev3/kernel/power/main.c 2004-09-09 19:36:24.000000000 +1000
@@ -257,3 +259,7 @@
}

core_initcall(pm_init);
+
+/* For Suspend2 ACPI support */
+EXPORT_SYMBOL(pm_ops);
+EXPORT_SYMBOL(pm_disk_mode);
diff -ruN linux-2.6.9-rc1/kernel/sched.c software-suspend-linux-2.6.9-rc1-rev3/kernel/sched.c
--- linux-2.6.9-rc1/kernel/sched.c 2004-09-07 21:59:01.000000000 +1000
+++ software-suspend-linux-2.6.9-rc1-rev3/kernel/sched.c 2004-09-09 19:36:24.000000000 +1000
@@ -3265,6 +3264,7 @@

read_unlock(&tasklist_lock);
}
+EXPORT_SYMBOL(show_state);

void __devinit init_idle(task_t *idle, int cpu)
{
diff -ruN linux-2.6.9-rc1/kernel/sys.c software-suspend-linux-2.6.9-rc1-rev3/kernel/sys.c
--- linux-2.6.9-rc1/kernel/sys.c 2004-06-18 12:44:22.000000000 +1000
+++ software-suspend-linux-2.6.9-rc1-rev3/kernel/sys.c 2004-09-09 19:36:24.000000000 +1000
@@ -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);
diff -ruN linux-2.6.9-rc1/kernel/timer.c software-suspend-linux-2.6.9-rc1-rev3/kernel/timer.c
--- linux-2.6.9-rc1/kernel/timer.c 2004-09-07 21:59:01.000000000 +1000
+++ software-suspend-linux-2.6.9-rc1-rev3/kernel/timer.c 2004-09-09 19:36:24.000000000 +1000
@@ -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.
diff -ruN linux-2.6.9-rc1/mm/page_alloc.c software-suspend-linux-2.6.9-rc1-rev3/mm/page_alloc.c
--- linux-2.6.9-rc1/mm/page_alloc.c 2004-09-07 21:59:01.000000000 +1000
+++ software-suspend-linux-2.6.9-rc1-rev3/mm/page_alloc.c 2004-09-09 19:36:24.000000000 +1000
@@ -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);
diff -ruN linux-2.6.9-rc1/mm/page-writeback.c software-suspend-linux-2.6.9-rc1-rev3/mm/page-writeback.c
--- linux-2.6.9-rc1/mm/page-writeback.c 2004-09-07 21:59:01.000000000 +1000
+++ software-suspend-linux-2.6.9-rc1-rev3/mm/page-writeback.c 2004-09-09 19:36:24.000000000 +1000
@@ -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);
diff -ruN linux-2.6.9-rc1/mm/swapfile.c software-suspend-linux-2.6.9-rc1-rev3/mm/swapfile.c
--- linux-2.6.9-rc1/mm/swapfile.c 2004-09-07 21:59:01.000000000 +1000
+++ software-suspend-linux-2.6.9-rc1-rev3/mm/swapfile.c 2004-09-09 19:36:24.000000000 +1000
@@ -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);
diff -ruN linux-2.6.9-rc1/mm/vmscan.c software-suspend-linux-2.6.9-rc1-rev3/mm/vmscan.c
--- linux-2.6.9-rc1/mm/vmscan.c 2004-09-07 21:59:01.000000000 +1000
+++ software-suspend-linux-2.6.9-rc1-rev3/mm/vmscan.c 2004-09-09 19:36:24.000000000 +1000
@@ -1237,3 +1237,6 @@
}

module_init(kswapd_init)
+
+/* For Suspend2 */
+EXPORT_SYMBOL(shrink_all_memory);

--
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.


2004-09-16 11:42:41

by Arjan van de Ven

[permalink] [raw]
Subject: Re: [PATCH] Suspend2 merge: New exports.

On Thu, 2004-09-16 at 13:20, Nigel Cunningham wrote:

>
> +EXPORT_SYMBOL(tainted);

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

most of these exports look REALLY fishy to me.


Attachments:
signature.asc (189.00 B)
This is a digitally signed message part

2004-09-16 11:55:57

by Nigel Cunningham

[permalink] [raw]
Subject: Re: [PATCH] Suspend2 merge: New exports.

Hi.

On Thu, 2004-09-16 at 21:40, Arjan van de Ven wrote:
> On Thu, 2004-09-16 at 13:20, Nigel Cunningham wrote:
>
> >
> > +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
--
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.

2004-09-16 14:40:04

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] Suspend2 merge: New exports.

On Thu, Sep 16, 2004 at 09:20:19PM +1000, Nigel Cunningham wrote:
>
> 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.

> diff -ruN linux-2.6.9-rc1/fs/buffer.c software-suspend-linux-2.6.9-rc1-rev3/fs/buffer.c
> --- linux-2.6.9-rc1/fs/buffer.c 2004-09-07 21:58:52.000000000 +1000
> +++ software-suspend-linux-2.6.9-rc1-rev3/fs/buffer.c 2004-09-09 19:36:24.000000000 +1000
> @@ -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.

> diff -ruN linux-2.6.9-rc1/fs/ioctl.c software-suspend-linux-2.6.9-rc1-rev3/fs/ioctl.c
> --- linux-2.6.9-rc1/fs/ioctl.c 2004-09-07 21:58:53.000000000 +1000
> +++ software-suspend-linux-2.6.9-rc1-rev3/fs/ioctl.c 2004-09-09 19:36:24.000000000 +1000
> @@ -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.

> diff -ruN linux-2.6.9-rc1/kernel/panic.c software-suspend-linux-2.6.9-rc1-rev3/kernel/panic.c
> --- linux-2.6.9-rc1/kernel/panic.c 2004-09-07 21:59:00.000000000 +1000
> +++ software-suspend-linux-2.6.9-rc1-rev3/kernel/panic.c 2004-09-09 19:36:24.000000000 +1000
> @@ -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;

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

2004-09-16 22:02:38

by Nigel Cunningham

[permalink] [raw]
Subject: Re: [PATCH] Suspend2 merge: New exports.

Hi.

On Fri, 2004-09-17 at 00:33, Greg KH wrote:
> On Thu, Sep 16, 2004 at 09:20:19PM +1000, Nigel Cunningham wrote:
> >
> > 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.

[...]

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

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

> > -#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!)

> 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

--
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.

2004-09-17 07:32:03

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH] Suspend2 merge: New exports.

> +EXPORT_SYMBOL(kd_mksound);

nope.

> +inline int buffer_busy(struct buffer_head *bh)

huh?

> -#ifdef CONFIG_COMPAT
> EXPORT_SYMBOL(sys_ioctl);
> -#endif

No way, sorry.

> +EXPORT_SYMBOL(sys_mkdir);

Dito. WTF are you trying to do?

> +EXPORT_SYMBOL(sys_umount);

Dito.

> +EXPORT_SYMBOL(sys_mount);

Dito.

> +EXPORT_SYMBOL(proc_match);

Gad.

> +EXPORT_SYMBOL(sys_write);

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

> +EXPORT_SYMBOL(tainted);

Umm, no way again.