#!/bin/bash
set -x

echo 0 >/debug/tracing/tracing_enabled
cat mmap.list1 > /debug/tracing/set_ftrace_filter
echo function > /debug/tracing/current_tracer
echo func_stack_trace > /debug/tracing/trace_options
echo 1 >/debug/tracing/tracing_enabled
/root/a.out 1000
cat /debug/tracing/stack_trace
echo 0 > /proc/sys/kernel/stack_tracer_enabled
echo 0 >/debug/tracing/tracing_enabled
cat /debug/tracing/trace | tee ftrace/${0}$$.log


where mmap.list will contain a few of the mmap* related API (just an example):

mmap
mmap_init
mmap_kmem
mmap_mem
mmap_mem_ops
mmap_min_addr
mmap_min_addr_handler
mmap_region
mmap_rnd
mmap_zero
mon_bin_mmap
node_memmap_size_bytes


Where a.out 1000 is the following program:

 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>

 #define handle_error(msg) \
     do { perror(msg); exit(EXIT_FAILURE); } while (0)

 int
 main(int argc, char *argv[])
 {
    int length1 = atoi(argv[1]);
    unsigned char *addr;

    if ((addr = mmap(NULL, (size_t) length1 * 1024 * 1024 , PROT_READ | PROT_WRITE ,
           MAP_SHARED | MAP_ANONYMOUS, -1, 0)) == MAP_FAILED) {
       perror("mmap()");
       abort();
     }
    else printf("good one!!!!\n");
    memset(addr, 'c', length1 * 1024 * 1024);
 } /* main */


And the results:

     gnome-panel-2909  [000]  2869.687263: security_file_mmap <-do_mmap_pgoff
     gnome-panel-2909  [000]  2869.687264: <stack trace>
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.687267: cap_file_mmap <-security_file_mmap
     gnome-panel-2909  [000]  2869.687267: <stack trace>
 => security_file_mmap
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.687271: mmap_region <-do_mmap_pgoff
     gnome-panel-2909  [000]  2869.687271: <stack trace>
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.687276: generic_file_mmap <-mmap_region
     gnome-panel-2909  [000]  2869.687278: <stack trace>
 => mmap_region
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.687284: __perf_event_mmap <-mmap_region
     gnome-panel-2909  [000]  2869.687284: <stack trace>
 => mmap_region
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.687297: sys_mmap <-system_call_fastpath
     gnome-panel-2909  [000]  2869.687298: <stack trace>
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.687301: do_mmap_pgoff <-sys_mmap
     gnome-panel-2909  [000]  2869.687301: <stack trace>
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.687304: security_file_mmap <-do_mmap_pgoff
     gnome-panel-2909  [000]  2869.687305: <stack trace>
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.687308: cap_file_mmap <-security_file_mmap
     gnome-panel-2909  [000]  2869.687308: <stack trace>
 => security_file_mmap
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.687312: mmap_region <-do_mmap_pgoff
     gnome-panel-2909  [000]  2869.687312: <stack trace>
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.687323: generic_file_mmap <-mmap_region
     gnome-panel-2909  [000]  2869.687323: <stack trace>
 => mmap_region
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.695637: sys_mmap <-system_call_fastpath
     gnome-panel-2909  [000]  2869.695638: <stack trace>
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.695642: do_mmap_pgoff <-sys_mmap
     gnome-panel-2909  [000]  2869.695643: <stack trace>
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.695646: security_file_mmap <-do_mmap_pgoff
     gnome-panel-2909  [000]  2869.695647: <stack trace>
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.695650: cap_file_mmap <-security_file_mmap
     gnome-panel-2909  [000]  2869.695650: <stack trace>
 => security_file_mmap
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.695654: mmap_region <-do_mmap_pgoff
     gnome-panel-2909  [000]  2869.695654: <stack trace>
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.695762: sys_mmap <-system_call_fastpath
     gnome-panel-2909  [000]  2869.695762: <stack trace>
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.695766: do_mmap_pgoff <-sys_mmap
     gnome-panel-2909  [000]  2869.695766: <stack trace>
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.695772: security_file_mmap <-do_mmap_pgoff
     gnome-panel-2909  [000]  2869.695773: <stack trace>
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.695776: cap_file_mmap <-security_file_mmap
     gnome-panel-2909  [000]  2869.695776: <stack trace>
 => security_file_mmap
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.695780: mmap_region <-do_mmap_pgoff
     gnome-panel-2909  [000]  2869.695780: <stack trace>
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.695785: generic_file_mmap <-mmap_region
     gnome-panel-2909  [000]  2869.695786: <stack trace>
 => mmap_region
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.695791: __perf_event_mmap <-mmap_region
     gnome-panel-2909  [000]  2869.695791: <stack trace>
 => mmap_region
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.695815: sys_mmap <-system_call_fastpath
     gnome-panel-2909  [000]  2869.695815: <stack trace>
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.695819: do_mmap_pgoff <-sys_mmap
     gnome-panel-2909  [000]  2869.695819: <stack trace>
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.695822: security_file_mmap <-do_mmap_pgoff
     gnome-panel-2909  [000]  2869.695823: <stack trace>
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.695826: cap_file_mmap <-security_file_mmap
     gnome-panel-2909  [000]  2869.695826: <stack trace>
 => security_file_mmap
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.695830: mmap_region <-do_mmap_pgoff
     gnome-panel-2909  [000]  2869.695830: <stack trace>
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.695838: generic_file_mmap <-mmap_region
     gnome-panel-2909  [000]  2869.695838: <stack trace>
 => mmap_region
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.699423: sys_mmap <-system_call_fastpath
     gnome-panel-2909  [000]  2869.699425: <stack trace>
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.699429: do_mmap_pgoff <-sys_mmap
     gnome-panel-2909  [000]  2869.699429: <stack trace>
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.699434: security_file_mmap <-do_mmap_pgoff
     gnome-panel-2909  [000]  2869.699435: <stack trace>
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.699438: cap_file_mmap <-security_file_mmap
     gnome-panel-2909  [000]  2869.699438: <stack trace>
 => security_file_mmap
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.699442: mmap_region <-do_mmap_pgoff
     gnome-panel-2909  [000]  2869.699442: <stack trace>
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.699447: generic_file_mmap <-mmap_region
     gnome-panel-2909  [000]  2869.699448: <stack trace>
 => mmap_region
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.699454: __perf_event_mmap <-mmap_region
     gnome-panel-2909  [000]  2869.699454: <stack trace>
 => mmap_region
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.699466: sys_mmap <-system_call_fastpath
     gnome-panel-2909  [000]  2869.699466: <stack trace>
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.699469: do_mmap_pgoff <-sys_mmap
     gnome-panel-2909  [000]  2869.699470: <stack trace>
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.699474: security_file_mmap <-do_mmap_pgoff
     gnome-panel-2909  [000]  2869.699474: <stack trace>
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.699477: cap_file_mmap <-security_file_mmap
     gnome-panel-2909  [000]  2869.699478: <stack trace>
 => security_file_mmap
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.699481: mmap_region <-do_mmap_pgoff
     gnome-panel-2909  [000]  2869.699481: <stack trace>
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [000]  2869.699491: generic_file_mmap <-mmap_region
     gnome-panel-2909  [000]  2869.699492: <stack trace>
 => mmap_region
 => do_mmap_pgoff
 => sys_mmap
 => system_call_fastpath
     gnome-panel-2909  [001]  2869.715248: security_file_mmap <-expand_downwards
     gnome-panel-2909  [001]  2869.715251: <stack trace>
 => expand_downwards
 => expand_stack
 => do_page_fault
 => page_fault
     gnome-panel-2909  [001]  2869.715257: cap_file_mmap <-security_file_mmap
     gnome-panel-2909  [001]  2869.715258: <stack trace>
 => security_file_mmap
 => expand_downwards
 => expand_stack
 => do_page_fault
 => page_fault
     gnome-panel-2909  [001]  2869.716277: security_file_mmap <-expand_downwards
     gnome-panel-2909  [001]  2869.716278: <stack trace>
 => expand_downwards
 => expand_stack
 => do_page_fault
 => page_fault
     gnome-panel-2909  [001]  2869.716283: cap_file_mmap <-security_file_mmap
     gnome-panel-2909  [001]  2869.716283: <stack trace>
 => security_file_mmap
 => expand_downwards
 => expand_stack
 => do_page_fault
 => page_fault
             cat-4807  [000]  2869.729087: exit_mmap <-mmput
             cat-4807  [000]  2869.729089: <stack trace>
 => mmput
 => exit_mm
 => do_exit
 => sys_exit_group
 => sys_exit_group
 => system_call_fastpath


Reply via email to