Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have an linux kernel 2.6.30 on an ARM based embedded device and I have to do some kernel memory usage profiling on the device.

I am thinking of monitoring the ps output on various kernel threads and modules while I carry out actions like wifi on/off etc.

Can you suggest me:

Which threads I need to monitor? How to monitor the kernel module memory usage?

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

There are several ways to monitor memory usage in a Linux system. Some may or may not be available depending on

  1. What version you are running
  2. How the kernel is configured
  3. What user-space tools are included in the root file-system

Since Linux typically is a virtual memory system, some statistics may be misleading and/or inaccurate. It is important to dig and understand what each statstic means.

With all that said, I typically monitor memory usage by running vmstat to get an idea of the total memory usage:

# vmstat -s
       127168  total memory
        44072  used memory
        33296  active memory
         2164  inactive memory
        83096  free memory
            0  buffer memory
        20468  swap cache
            0  total swap
            0  used swap
            0  free swap
       582750 non-nice user cpu ticks
            0 nice user cpu ticks
       160883 system cpu ticks
      7448748 idle cpu ticks
            0 IO-wait cpu ticks
        16066 IRQ cpu ticks
        18249 softirq cpu ticks
            0 stolen cpu ticks
            0 pages paged in
            0 pages paged out
            0 pages swapped in
            0 pages swapped out
     15079537 interrupts
     28629740 CPU context switches
   1344249586 boot time
        25532 forks

"free" Will also give you a bird's eye view of the memory usage. If I see anything unexpected, I will look on suspect processes by examining files in procfs. Good files to look at are

/proc/PID/maps - This lists all the memory currently mapped by the process

/proc/PID/smaps - Provides more details about how much memory is resident/shared/dirty/etc... This file can be verbose, but a Python script could be written to generate more meaningful data

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.