res*_*way 10 c linux memory kernel
lsmod,/ proc/modules和slabinfo,/ proc/meminfo不会给我的内核模块使用多少内存
有没有办法找到这个?
顺便说一句,我基本上写了一个小测试程序,一个设备驱动程序,它接受ioctl调用以分配1MB,我每秒从我的应用程序发送这个ioctl消息,所以我的驱动器每秒都会执行kmalloc.我无法看到"cat/proc/meminfo | grep Slab"的增加
- 剪断---
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;
}
Run Code Online (Sandbox Code Playgroud)
应用/用户空间
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 );
}
Run Code Online (Sandbox Code Playgroud)
我看不到slabinfo中记忆的增长.我知道linux会执行cache-> slabs-> pages-> objects,但是在用户区中必须有一些方法来确定特定内核模块的内存大小.
谢谢,
归档时间: |
|
查看次数: |
3695 次 |
最近记录: |