[Ilugc] Kernel size

  • From: girishvenkatachalam@xxxxxxxxx (Girish Venkatachalam)
  • Date: Fri Aug 25 10:06:16 2006

On 8/25/06, Suman Adak <ilugsuman@xxxxxxxxx> wrote:

Sorry , i forgot to send list also....


On 8/24/06, Sundar SM <mee.sundar@xxxxxxxxx> wrote:

Hi Friends

1) What is the range of the running kernel stack in main memory?


look at /proc interface.

cat /proc/iomem | grep -i 'kernel data'. You would get the address range.


2) How can you find out size of kernel sapce and user space in your main
memory?


Do u mean virtual memory? if yes just check this code


main()
{
   char *ch = getenv("HOME");
   if((unsigned long)ch > (unsigned long)(0x7FFFFFFF))
      printf("3/1 GB split\n");
   else
      printf("2/2 GB split\n");

}



you can enable memory_accounting option in kernel configuration. User space
memory can be calculated using sum of (pmap <each pid from /proc> | grep -i
'total'). U can write a small script to calculate the total user space. But
remind it will not give you the actual size.

If u want to write a kernel module , then u can do like...by manipulating
(task_struct,mm_struct,vm_area_struct). You could pass the PID from /proc
interface
as a parameter and manipulate the total size.



3) How to find the avialable kernel / user space and used kernel / user
space? is there any shell command to see that?



cat /proc/meminfo


I am also learning kernel programming.  if i do mistake please correct me.

Unfortunately I am not able to try out your stuff since I don't have
access to linux this moment.

However I am very very happy to see more kernel hackers.

I think it is somewhat odd to start with the kernel before
understanding rest of UNIX design and philosophy but one has to get
acquainted with the kernel design and code for sure.

I urge more and more folks to try kernel hacking so you could help me
when I am in trouble! :-)

regards,
Girish

Other related posts: