Suspend 2 merge: 4/51: Get module list.

Nigel Cunningham
2004-11-24T13:07:46Z

This provides access to the list of loaded modules for suspend's
debugging output. When a cycle finishes, suspend outputs something the
following:

> Please include the following information in bug reports:
> - SUSPEND core : 2.1.5.7
> - Kernel Version : 2.6.9
> - Compiler vers. : 3.3
> - Modules loaded : tuner bttv videodev snd_seq_oss snd_seq_midi_event
> snd_seq snd_pcm_oss snd_mixer_oss snd_intel8x0 snd_ac97_codec snd_pcm
> snd_timer snd_page_alloc snd_mpu401_uart snd_rawmidi snd_seq_device
> snd soundcore visor usbserial usblp joydev evdev usbmouse usbhid
> uhci_hcd usbcore ppp_deflate zlib_deflate zlib_inflate bsd_comp
> ipt_LOG ipt_state ipt_MASQUERADE iptable_nat ip_conntrack
> ipt_multiport ipt_REJECT iptable_filter ip_tables ppp_async
> ppp_generic slhc crc_ccitt video_buf v4l2_common btcx_risc Win4Lin
> mki_adapter radeon agpgart parport_pc lp parport sg ide_cd sr_mod
> cdrom floppy af_packet e1000 loop dm_mod tsdev suspend_bootsplash
> suspend_text suspend_swap suspend_block_io suspend_lzf suspend_core
> - Attempt number : 9
> - Parameters : 0 2304 32768 1 0 4096 5
> - Limits : 261680 pages RAM. Initial boot: 252677.
> - Overall expected compression percentage: 0.
> - LZF Compressor enabled.
> Compressed 922112000 bytes into 437892038 (52 percent compression).
> - Swapwriter active.
> Swap available for image: 294868 pages.
> - Debugging compiled in.
> - Preemptive kernel.
> - SMP kernel.
> - Highmem Support.
> - I/O speed: Write 72 MB/s, Read 119 MB/s.

Including the modules loaded is very helpful for debugging problems.

diff -ruN 209-get-module-list-old/kernel/module.c 209-get-module-list-new/kernel/module.c
--- 209-get-module-list-old/kernel/module.c 2004-11-24 17:21:28.892423312 +1100
+++ 209-get-module-list-new/kernel/module.c 2004-11-24 17:21:20.619680960 +1100
@@ -2105,6 +2105,18 @@
}
EXPORT_SYMBOL(module_remove_driver);

+int print_module_list_to_buffer(char * buffer, int size)
+{
+ struct module *mod;
+ int pos = 0;
+
+ list_for_each_entry(mod, &modules, list)
+ if (mod->name)
+ pos += snprintf(buffer+pos, size-pos-1,
+ "%s ", mod->name);
+ return pos;
+}
+
#ifdef CONFIG_MODVERSIONS
/* Generate the signature for struct module here, too, for modversions. */
void struct_module(struct module *mod) { return; }
@@ -2115,3 +2127,5 @@
struct list_head *kdb_modules = &modules; /* kdb needs the list of modules */
#endif /* CONFIG_KDB */

+/* For Suspend2 */
+EXPORT_SYMBOL(print_module_list_to_buffer);