enable ftrace in android kernel

disable Wno-error=unused-but-set-variable

just delete -Wall

build kernel


export CROSS_COMPILE=aarch64-linux-android-
export ARCH=arm64
export CROSS_COMPILE_ARM32=/media/alex/08387397-8c9b-4a7c-8e14-e2cae7e0922c/aosp-9-r10/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-
sed -i "s/\-Wall / /g" `grep "\-Wall " -rl ./` # avoid warning to corrupt compile

# after compile kernel
cp ./arch/arm64/boot/Image.gz-dtb /media/alex/08387397-8c9b-4a7c-8e14-e2cae7e0922c/aosp-9-r10/device/google/wahoo-kernel

do as google say:

https://source.android.com/devices/tech/debug/ftrace#dftrace

linux official doc:

https://www.kernel.org/doc/Documentation/trace/ftrace.txt

then I find ftrace doesn't work well on android, after some time try. I find linux kernel can log all functions, while android cann't. I find a way to work arround it

walleye:/d/tracing # echo ip_* > set_ftrace_filter # all ip_* function are traced
walleye:/d/tracing # echo function_graph > current_tracer
walleye:/d/tracing # echo 1 > tracing_on               #curl www.baidu.com                                                                                                                              
walleye:/d/tracing # echo 0 > tracing_on
walleye:/d/tracing # cat trace
# tracer: function_graph
#
# CPU  DURATION                  FUNCTION CALLS
# |     |   |                     |   |   |   |
 7) ! 379.114 us  |  ip_local_deliver();
 7) + 80.729 us   |  ip_local_deliver();
 7) ! 172.292 us  |  ip_local_deliver();
 7) ! 108.698 us  |  ip_local_deliver();
 7) ! 133.125 us  |  ip_local_deliver();
 7) ! 121.667 us  |  ip_local_deliver();
 7) ! 174.844 us  |  ip_local_deliver();
 0)   2.448 us    |  ip_mc_drop_socket();
 0)   2.708 us    |  ip_mc_drop_socket();
 1)   3.021 us    |  ip_mc_drop_socket();
 1)               |  ip_queue_xmit() {
 1)               |    ip_local_out() {
 1)               |      ip_output() {
 1)               |        ip_finish_output() {
 1) ! 197.135 us  |          ip_finish_output2();
 1) ! 202.656 us  |        }
 1) ! 271.093 us  |      }
 1) ! 417.969 us  |    }
 1) ! 427.552 us  |  }
 ------------------------------------------
 1)  OkHttp -3302  =>    -0   
 ------------------------------------------

 1)               |  ip_queue_xmit() {
 1)               |    ip_local_out() {
 1)               |      ip_output() {
 1)               |        ip_finish_output() {
 1) ! 246.146 us  |          ip_finish_output2();
 1) ! 254.531 us  |        }
 1) ! 292.865 us  |      }
 1) ! 463.438 us  |    }
 1) ! 471.354 us  |  }
 7)               |  ip_rcv() {
 7)               |    ip_rcv_finish() {
 7)               |      ip_local_deliver() {
 7) + 74.583 us   |        ip_local_deliver_finish();
 7) ! 129.167 us  |      }
 7) ! 141.406 us  |    }
 7) ! 211.146 us  |  }
 7)               |  ip_rcv() {
 7)               |    ip_rcv_finish() {
 7) + 29.532 us   |      ip_route_input_noref();
 7)               |      ip_local_deliver() {
 7) + 26.666 us   |        ip_local_deliver_finish();
 7) + 72.239 us   |      }
 7) ! 116.979 us  |    }
 7) ! 171.198 us  |  }
 ------------------------------------------
 1)    -0    =>  [email protected]  
 ------------------------------------------

 1)   2.395 us    |  ip_mc_drop_socket();
 2)   2.708 us    |  ip_mc_drop_socket();
 ------------------------------------------
 1)  [email protected]   =>  netlink-942  
 ------------------------------------------

 1)   1.823 us    |  ip_mc_drop_socket();
 ------------------------------------------
 7)  cds_ol_-2461  =>  netlink-942  
 ------------------------------------------

 7)   1.667 us    |  ip_mc_drop_socket();
 0)   2.500 us    |  ip_mc_drop_socket();
 ------------------------------------------
 7)  netlink-942   =>   curl-3351   
 ------------------------------------------

 7)   1.823 us    |  ip_mc_drop_socket();
 ------------------------------------------
 0)  [email protected]   =>   netd-3353   
 ------------------------------------------

 0)   3.073 us    |  ip_generic_getfrag();
 ------------------------------------------
 7)   curl-3351    =>   netd-3353   
 ------------------------------------------

 7)   2.031 us    |  ip_mc_drop_socket();
 7) + 15.313 us   |  ip_route_output_flow();
 7)   0.417 us    |  ip_mc_drop_socket();
 7)   3.854 us    |  ip_route_output_flow();
 7)   0.521 us    |  ip_mc_drop_socket();
 4)   7.188 us    |  ip_route_output_flow();
 4)   3.855 us    |  ip_route_output_flow();
 4)               |  ip_queue_xmit() {
 4)               |    ip_local_out() {
 4)               |      ip_output() {
 4)               |        ip_finish_output() {
 4) ! 256.875 us  |          ip_finish_output2();
 4) ! 263.490 us  |        }
 4) ! 319.791 us  |      }
 4) ! 466.875 us  |    }
 4) ! 473.646 us  |  }
 ------------------------------------------
 7)   netd-3353    =>  cds_ol_-2461 
 ------------------------------------------

 7)               |  ip_rcv() {
 7)               |    ip_rcv_finish() {
 7) + 18.906 us   |      ip_route_input_noref();
 7)               |      ip_local_deliver() {
 7)               |        ip_local_deliver_finish() {
 7) ! 121.666 us  |          ip_queue_xmit();
 7) ! 261.979 us  |        }
 7) ! 310.885 us  |      }
 7) ! 343.281 us  |    }
 7) ! 403.802 us  |  }
 4)               |  ip_queue_xmit() {
 4)               |    ip_local_out() {
 4)               |      ip_output() {
 4)               |        ip_finish_output() {
 4) + 51.927 us   |          ip_finish_output2();
 4) + 57.604 us   |        }
 4) + 80.469 us   |      }
 4) ! 147.813 us  |    }
 4) ! 153.489 us  |  }
 7)               |  ip_rcv() {
 7)               |    ip_rcv_finish() {
 7)               |      ip_local_deliver() {
 7) + 63.177 us   |        ip_local_deliver_finish();
 7) ! 109.323 us  |      }
 7) ! 121.302 us  |    }
 7) ! 171.927 us  |  }
 7)               |  ip_rcv() {
 7)               |    ip_rcv_finish() {
 7)               |      ip_local_deliver() {
 7)               |        ip_local_deliver_finish() {
 7) ! 133.542 us  |          ip_queue_xmit();
 7) ! 200.417 us  |        }
 7) ! 297.448 us  |      }
 7) ! 308.803 us  |    }
 7) ! 342.657 us  |  }
 7)               |  ip_rcv() {
 7)               |    ip_rcv_finish() {
 7)               |      ip_local_deliver() {
 7)               |        ip_local_deliver_finish() {
 7) ! 115.834 us  |          ip_queue_xmit();
 7) ! 176.198 us  |        }
 7) ! 217.604 us  |      }
 7) ! 226.354 us  |    }
 7) ! 265.208 us  |  }
 7)               |  ip_rcv() {
 7)               |    ip_rcv_finish() {
 7)               |      ip_local_deliver() {
 7)               |        ip_local_deliver_finish() {
 7) ! 106.510 us  |          ip_queue_xmit();
 7) ! 160.000 us  |        }
 7) ! 195.313 us  |      }
 7) ! 202.084 us  |    }
 7) ! 240.833 us  |  }
 ------------------------------------------
 7)  cds_ol_-2461  =>   curl-3351   
 ------------------------------------------

 7)   1.562 us    |  ip_mc_drop_socket();
 7)               |  ip_queue_xmit() {
 7)               |    ip_local_out() {
 7)               |      ip_output() {
 7)               |        ip_finish_output() {
 7) + 44.218 us   |          ip_finish_output2();
 7) + 49.114 us   |        }
 7) + 72.292 us   |      }
 7) ! 126.927 us  |    }
 7) ! 132.761 us  |  }
 ------------------------------------------

That's all

你可能感兴趣的:(enable ftrace in android kernel)