I would like to implement my kernel to be able to monitoring memory of each process. However, all I can do is to only print out the process and pid. I can't find a function that can help in monitoring memory. Here is the code in the kernel that i Implemented. I use Linux kernel version 4.11.0-rc7.
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/resource.h>
#include <linux/sched.h>
#include <linux/syscalls.h>
asmlinkage long sys_listProcessInfo(void){
struct task_struct *process;
struct rusage usage;
int i = 0;
for_each_process(process){
if(i%10 == 0){
printk("Process %s\n PID: %ld\n",process->comm,(long)task_pid_nr(process));
i++;
}
}
return 0;
}
This one can only view process and pid. I would like to know if there is any function that can look for the memory of the process. Thank you in advance.