Memory usage of a kernel module

强颜欢笑 提交于 2019-12-03 03:32:45

You mention that no allocation is done in the init function, but does that take into account calls such as register_chrdev(9) which allocate memory internally for the device instance? The comment that it is a constant difference makes me wonder if this might be the cause.

May be the functions used by the module are counted into the module size ? Try

cat /proc/kallsyms | grep module_name

The difference between the two size is 404. Text + data + 404 = 1024. May be this is some kind of granularity problem ? I don't know how the size is calculated inside the kernel...

However, kernel code and data are allocated using dynamic memory. And kmalloc uses pre-allocated block of memory, so it is quite likely that there is some rounding up when code and data sections are allocated.

Try to increment the size of the data sections and see if the lsmod reported size change

Without more information, I'm tempted to guess that its debug overhead. I say tempted because I don't have your kernel configuration.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!