我的内核模块使用多少内存?

我的内核模块使用多少内存?,第1张

概述lsmod,/ proc / modules和slabinfo,/ proc / meminfo 不给我内核模块使用多少内存 有没有办法找到这个? btw,我基本上写了一个小的测试程序,一个设备驱动程序需要ioctl调用来分配1MB,我每秒从我的应用程序发送这个ioctl消息,所以我的驱动器每秒做kmalloc. Iam不能看到“cat / proc / meminfo | grep Slab”的 lsmod,/ proc / modules和slabinfo,/ proc / meminfo
不给我内核模块使用多少内存

有没有办法找到这个?

btw,我基本上写了一个小的测试程序,一个设备驱动程序需要ioctl调用来分配1MB,我每秒从我的应用程序发送这个ioctl消息,所以我的驱动器每秒做kmalloc. Iam不能看到“cat / proc / meminfo | grep Slab”的增加

– snip —

int device_ioctl(         struct file *file,unsigned int ioctl_num,unsigned long ioctl_param){    /*      * Switch according to the ioctl called      */    printk ( "<l> insIDe ioctl %d IOCTL_ALLOC_MSG = %d\n",ioctl_num,IOCTL_ALLOC_MSG );    switch (ioctl_num) {    case IOCTL_ALLOC_MSG:        allocfunc(); // kmalloc 1MB // printk in this function is OK        break;    case IOCTL_DEALLOC_MSG:        deallocfunc();        break;    }    return 0;}

应用/用户空间

while ( !stop )        {            ret_val = ioctl(memfile,IOCTL_ALLOC_MSG);            if (ret_val < 0) {                printf("ioctl Failed. Return code: %d,meaning: %s\n",ret_val,strerror(errno));                return -1;            }            sleep ( 10 );        }

我没有看到slabinfo内存的增长.我知道linux做cache-> slabs-> pages->对象,但在用户界面中必须有一些方法来确定特定内核模块的内存大小.

谢谢,

解决方法 我不确定它是否适合您,但您可以使用’cat / proc / modules’获取模块所占用的内存量,第二列是第一列中模块的大小(以字节为单位)正在使用.

示例输出显示drm模块使用多少内存:

cat / proc / modules | grep ^ drm | awk'{print $1“”$2}“

drm_kms_helper 49394
drm 286028

希望有帮助.

总结

以上是内存溢出为你收集整理的我的内核模块使用多少内存?全部内容,希望文章能够帮你解决我的内核模块使用多少内存?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1251295.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-07
下一篇 2022-06-07

发表评论

登录后才能评论

评论列表(0条)

保存