• Namhyung Kim's avatar
    perf kmem: Implement stat --page --caller · c9758cc4
    Namhyung Kim authored
    It is 'perf kmem' support caller statistics for page.  Unlike slab case,
    the tracepoints in page allocator don't provide callsite info.  So it
    records with callchain and extracts callsite info.
    
    Note that the callchain contains several memory allocation functions
    which has no meaning for users.  So skip those functions to get proper
    callsites.  I used following regex pattern to skip the allocator
    functions:
    
      ^_?_?(alloc|get_free|get_zeroed)_pages?
    
    This gave me a following list of functions:
    
      # perf kmem record --page sleep 3
      # perf kmem stat --page -v
      ...
      alloc func: __get_free_pages
      alloc func: get_zeroed_page
      alloc func: alloc_pages_exact
      alloc func: __alloc_pages_direct_compact
      alloc func: __alloc_pages_nodemask
      alloc func: alloc_page_interleave
      alloc func: alloc_pages_current
      alloc func: alloc_pages_vma
      alloc func: alloc_page_buffers
      alloc func: alloc_pages_exact_nid
      ...
    
    The output looks mostly same as --alloc (I also added callsite column
    to that) but groups entries by callsite.  Currently, the order,
    migrate type and GFP flag info is for the last allocation and not
    guaranteed to be same for all allocations from the callsite.
    
      ---------------------------------------------------------------------------------------------
       Total_alloc (KB) | Hits      | Order | Mig.type | GFP flags | Callsite
      ---------------------------------------------------------------------------------------------
                  1,064 |       266 |     0 | UNMOVABL |  000000d0 | __pollwait
                     52 |        13 |     0 | UNMOVABL |  002084d0 | pte_alloc_one
                     44 |        11 |     0 |  MOVABLE |  000280da | handle_mm_fault
                     20 |         5 |     0 |  MOVABLE |  000200da | do_cow_fault
                     20 |         5 |     0 |  MOVABLE |  000200da | do_wp_page
                     16 |         4 |     0 | UNMOVABL |  000084d0 | __pmd_alloc
                     16 |         4 |     0 | UNMOVABL |  00000200 | __tlb_remove_page
                     12 |         3 |     0 | UNMOVABL |  000084d0 | __pud_alloc
                      8 |         2 |     0 | UNMOVABL |  00000010 | bio_copy_user_iov
                      4 |         1 |     0 | UNMOVABL |  000200d2 | pipe_write
                      4 |         1 |     0 |  MOVABLE |  000280da | do_wp_page
                      4 |         1 |     0 | UNMOVABL |  002084d0 | pgd_alloc
      ---------------------------------------------------------------------------------------------
    Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
    Acked-by: default avatarPekka Enberg <penberg@kernel.org>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Joonsoo Kim <js1304@gmail.com>
    Cc: Minchan Kim <minchan@kernel.org>
    Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Cc: linux-mm@kvack.org
    Link: http://lkml.kernel.org/r/1429592107-1807-2-git-send-email-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    c9758cc4
builtin-kmem.c 34.4 KB