linux 内核物理内存管理有哪些常用算法
1个回答
展开全部
/proc/meminfo 能反映每进程内存使用
些东西/proc/xxxx/statm maps memmap 体现
需要查看些虚拟文件linux内核实现即
例cat /proc/1/statm ,7组数据第二组进程1物理内存使用量单位前内核PAGE_SIZE
具体说明详见 Documentation/filesystems/proc.txt
具体实现fs/proc/array.c
C/C++ code?123456789101112131415int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns, struct pid *pid, struct task_struct *task){ unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0; struct mm_struct *mm = get_task_mm(task); if (mm) { size = task_statm(mm, &shared, &text, &data, &resident); mmput(mm); } seq_printf(m, "%lu %lu %lu %lu 0 %lu 0\n", size, resident, shared, text, data); return 0;}
函数改需要结难点根据pid应 task_struct
知道没现api遍历查找全局 task_struct链表应该难解决
些东西/proc/xxxx/statm maps memmap 体现
需要查看些虚拟文件linux内核实现即
例cat /proc/1/statm ,7组数据第二组进程1物理内存使用量单位前内核PAGE_SIZE
具体说明详见 Documentation/filesystems/proc.txt
具体实现fs/proc/array.c
C/C++ code?123456789101112131415int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns, struct pid *pid, struct task_struct *task){ unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0; struct mm_struct *mm = get_task_mm(task); if (mm) { size = task_statm(mm, &shared, &text, &data, &resident); mmput(mm); } seq_printf(m, "%lu %lu %lu %lu 0 %lu 0\n", size, resident, shared, text, data); return 0;}
函数改需要结难点根据pid应 task_struct
知道没现api遍历查找全局 task_struct链表应该难解决
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询