[Crash-utility] [PATCH v2] Add -m option to kmem

Dave Anderson anderson at redhat.com
Fri Apr 5 18:30:47 UTC 2013



----- Original Message -----
> 
> ----- Original Message -----
>>
>> ----- Original Message -----
>>>> kmem -m|-M is used for displaying information of all ksm pages or
>>>> some ksm pages for specified ksm stable tree node addresses
>>>>
>>>> for example:
>>>> crash> kmem -m
>>>> STABLE_NODE : ffff88083fc927e0
>>>> PAGE : ffffea000e667998
>>>> PHYSICAL ADDRESS: 41d475000
>>>>
>>>> PID: 2967 MAPPING: 3
>>>>
>>>> STABLE_NODE : ffff88083fc84a10
>>>> PAGE : ffffea000e3dd5d8
>>>> PHYSICAL ADDRESS: 411aad000
>>>>
>>>> PID: 2967 MAPPING: 7
>>>>
>>>> STABLE_NODE : ffff88041980dda8
>>>> PAGE : ffffea000e335568
>>>> PHYSICAL ADDRESS: 40eaab000
>>>>
>>>> PID: 2967 MAPPING: 8
>>>> ...
>>>>
>>>> STABLE_NODE : ffff880841ea43f8
>>>> PAGE : ffffea000f62de38
>>>> PHYSICAL ADDRESS: 465641000
>>>>
>>>> PID: 2967 MAPPING: 729
>>>> PID: 3017 MAPPING: 499
>>>>
>>>> P.S.
>>>> This patch is based on the patch from Qiao(qiaonuohan cn fujitsu com )
>>>> 0001-make-rbtree-manipulation-functions-global.patch
>>>> Because this patch also uses rb_tree operations.
>>>
>>> I cannot test this because all of my sample dumps either return:
>>>
>>> crash> kmem -m
>>> kmem: -m option not supported or applicable on this architecture or
>>> kernel
>>> crash>
>>>
>>> this is the kernel that doesn't support ksm
>>>
>>> or:
>>>
>>> crash> kmem -m
>>> ksm may not be enabled
>>> crash>
>>>
>>> This is because ksm is disabled or there is no ksm page in your
>>> system.
>> 
>> Which one?  Can't you determine that?
>
> I will change the message to:
>
> no ksm pages in the system
>
> meaning that there is not any ksm page in the system.
>
>> 
>>>
>>> which, by the way, is not a very helpful error message.
>>>
>>> Do you have a reasonably-sized vmcore that I can download and test?
>>>
>>> I have no vmcore on hand now. You could follow the below steps to
>>> make ksm work in your system.
>>>
>>>     * Ensure you are using kernel >= 2.6.31-0.94.rc4.fc12 and qemu-kvm >=0.10.92-4.fc12
>>>     * Run two or more similar virtual machines
>>>     * service ksm start
>>>     * service ksmtuned start
>>>     * Wait a while
>>>     * Check whether pages were merged using /sys/kernel/mm/ksm/pages_shared
>>>     * If value in /sys/kernel/mm/ksm/pages_shared is not zero, you
>>>       could run crash kmem -m to see the output.
>> 
>> OK look, if I get the time, I'll try to set this up...  
>> 
>> But just the fact that I have to go to all this trouble, and the fact 
>> that you don't even have a sample vmcore available again begs the question
>> as to how useful -- or better put -- how often, this command would ever
>> be utilized.
>
> Sorry about this. I will make a vmcore and tell where you can download it later.
>
>> 
>> On the other hand, if you were to create a "ksm" extension module, then 
>> I would be more than happy to post it with all of the others on the 
>> extensions web page.
>> 
>>> Also, I have a question about the help message:
>>>
>>> crash> help kmem
>>>
>>> NAME
>>> kmem - kernel memory
>>>
>>> SYNOPSIS
>>> kmem [-f|-F|-p|-c|-C|-i|-s|-S|-v|-V|-n|-z|-o|-m|-M] [slab] [[-P]
>>> address]
>>> [-g [flags]
>>>
>>> DESCRIPTION
>>> ... [ cut ] ...
>>> -m displays information of ksm pages.
>>> -M same as -m, but also dumps virtual addresses that mapping the
>>> ksm pages.
>>> ... [ cut ] ...
>>> address when used with -m or -M, the address can be either a ksm stable
>>> tree node address, a page's physical address, or a page pointer,
>>> the information of the ksm page (if it is) is displayed.
>>> ... [ cut ] ...
>>>
>>> Display information of ksm pages:
>>>
>>> crash> kmem -m ffff88086f22eec0 ffff8803573964c0
>>> STABLE_NODE : ffff88083fc927e0
>>> PAGE : ffffea000e667998
>>> PHYSICAL ADDRESS: 41d475000
>>>
>>> PID: 2967 MAPPING: 3
>>>
>>> STABLE_NODE : ffff88083fc84a10
>>> PAGE : ffffea000e3dd5d8
>>> PHYSICAL ADDRESS: 411aad000
>>>
>>> PID: 2967 MAPPING: 7
>>>
>>> STABLE_NODE : ffff88041980dda8
>>> PAGE : ffffea000e335568
>>> PHYSICAL ADDRESS: 40eaab000
>>>
>>> PID: 2967 MAPPING: 8
>>>
>>> ......
>>>
>>> STABLE_NODE : ffff880841ea43f8
>>> PAGE : ffffea000f62de38
>>> PHYSICAL ADDRESS: 465641000
>>>
>>> PID: 2967 MAPPING: 729
>>> PID: 3017 MAPPING: 499
>>>
>>> crash>
>>>
>>> Please tell me how the two address arguments ffff88086f22eec0 and
>>> ffff8803573964c0 have any relationship to the subsequent display?
>>>
>>>
>>> Sorry this is a mistake. The two addresses in the example are
>>> redundant.
>> 
>> Well, they aren't "redundant", they just don't make any sense at all.
>> I'm presuming that they don't belong there at all, and that you're
>> just showing the output of "kmem -m" alone, correct?
> 
> Yes, you are right.
> 
> Thanks
> Zhang


Hello Zhang,

I have spent some time testing/playing with this with a local
system set up with 4 KVM guests, and also with the sample
vmcore that you sent to me.

The problem I have is that I find it difficult to justify adding
the command to the base crash utility.  It's hard to conceive
of a situation where the command would be useful in a kernel
debugging session -- that is unless perhaps you were actually 
developing the KSM feature, or if the KSM subsystem were to be
prone to breakage, which doesn't seem to be the case.  

It also could be argued that it's output is more relevant to 
the "vm" command instead of the "kmem" command.  In other words,
it's really an abstraction of the virtual-to-physical aspect
of the "vm -p" output, but specific to only "qemu-kvm" tasks.  

Now, like I mentioned before, I'm sure you do have your reasons,
but certainly have not responded as to why this functionality
is not more suitable as an extension module?  To me it makes
perfect sense as a standalone command.

And to that end, I have flipped your patch into a "ksm" extension
module, which I've attached.  I've slightly tinkered with the 
output display, and given that it's an standalone command, replaced
the -m and -M options with a -v for the virtual addresses dump.  
The help page looks like this: 
  
  crash> help ksm
  
  NAME
    ksm - kernel samepage merging (KSM) information
  
  SYNOPSIS
    ksm [-v] [[-p] address ...]
  
  DESCRIPTION
    This command displays information about all KSM pages currently
    in use.  For each KSM page, the display includes its stable_node
    address, its page struct address, its physical address, the TGID/PID
    for each task that is using the page, and the number of mappings in
    the task's address space for the page.
   
         -v  also dump each virtual address in a PID's virtual address
             space that maps the KSM page.
    address  restricts the output to the KSM data associated with a
             stable_node address, a page's physical address, or a page
             pointer.
         -p  specifies that the address argument is a physical address,
             for architectures that require it.
  
  EXAMPLE
    Display information about all KSM pages:
  
      crash> ksm
                  PAGE: ffffea000ae7f6a8
           STABLE_NODE: ffff8806248c2d80
      PHYSICAL ADDRESS: 31db43000
                   PID: 2205  MAPPINGS: 2
  
                  PAGE: ffffea000ae800f0
           STABLE_NODE: ffff880624aa57b8
      PHYSICAL ADDRESS: 31db72000
                   PID: 2205  MAPPINGS: 2
  
                  PAGE: ffffea000ae7f8d8
           STABLE_NODE: ffff8806248c2dd0
      PHYSICAL ADDRESS: 31db4d000
                   PID: 2205  MAPPINGS: 2
      ...
  
    Display all information about the KSM page whose physical
    address is 0x626e60000:
  
      crash> ksm -v 626e60000
                  PAGE: ffffea0015882500
           STABLE_NODE: ffff88028b2af3d0
      PHYSICAL ADDRESS: 626e60000
                   PID: 2603  MAPPINGS: 8
                   VIRTUAL:
                   7ff46bcb4000
                   7ff46bcad000
                   7ff46bc9f000
                   7ff46bc7c000
                   7ff46bc6e000
                   7ff46bc67000
                   7ff46bc60000
                   7ff46bc59000
  
  crash>
  
I've attached the ksm.c extension module for you to check out.
Just throw it into a crash-<version>/extensions subdirectory,
enter "make extensions", and it will build automatically.
For that matter, you may even want to consider adding additional
KSM-related functionality to the command?  But anyway, with your
approval, I'd like to add it to the extensions web page.

Thanks,
  Dave



-------------- next part --------------
A non-text attachment was scrubbed...
Name: ksm.c
Type: text/x-c++src
Size: 10364 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/crash-utility/attachments/20130405/2cb4750f/attachment.bin>


More information about the Crash-utility mailing list