Sungju's Slow Life

Personal journal


simple explanation about ‘lsmod’ output

When you execute ‘lsmod’ command, you would see something like this.

[root@localhost ~]# lsmod
Module                  Size  Used by
ipheth                  5105  0 
cpufreq_stats           3117  0 
fuse                   51432  3 
ebtable_nat             1431  0 
ebtables               12142  1 ebtable_nat
bridge                 57131  0 
stp                     1438  1 bridge
...

It shows very simple and clear information but I couldn’t understand what ‘Size’ means here.
Is this use byte as a unit or KByte? Is this a size of a file or includes some other information as well?
So, I checked the code and following is the related information.

2120static int m_show(struct seq_file *m, void *p)
2121{
2122        struct module *mod = list_entry(p, struct module, list);
2123        seq_printf(m, "%s %lu",
2124                   mod->name, mod->init_size + mod->core_size);
2125        print_unload_info(m, mod);
2126
2127        /* Informative for users. */
2128        seq_printf(m, " %s",
2129                   mod->state == MODULE_STATE_GOING ? "Unloading":
2130                   mod->state == MODULE_STATE_COMING ? "Loading":
2131                   "Live");
2132        /* Used by oprofile and other similar tools. */
2133        seq_printf(m, " 0x%p", mod->module_core);
2134
2135        seq_printf(m, "n");
2136        return 0;
2137}
2138

In ‘struct module’, init_size and core_size has the following meaning.

struct module {
...
 297        /* Here is the actual code + data, vfree'd on unload. */
 298        void *module_core;
 299
 300        /* Here are the sizes of the init and core sections */
 301        unsigned long init_size, core_size;
 302
 303        /* The size of the executable code in each section.  */
 304        unsigned long init_text_size, core_text_size;
...
}


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About Me

A software engineer who loves any technologies that makes life easier. That’s why I love Linux and Mac at the same time.

Newsletter

%d bloggers like this: