1dd309207SNamhyung KimOverhead calculation 2dd309207SNamhyung Kim-------------------- 3dd309207SNamhyung KimThe overhead can be shown in two columns as 'Children' and 'Self' when 4dd309207SNamhyung Kimperf collects callchains. The 'self' overhead is simply calculated by 5dd309207SNamhyung Kimadding all period values of the entry - usually a function (symbol). 6dd309207SNamhyung KimThis is the value that perf shows traditionally and sum of all the 7dd309207SNamhyung Kim'self' overhead values should be 100%. 8dd309207SNamhyung Kim 9dd309207SNamhyung KimThe 'children' overhead is calculated by adding all period values of 10dd309207SNamhyung Kimthe child functions so that it can show the total overhead of the 11dd309207SNamhyung Kimhigher level functions even if they don't directly execute much. 12dd309207SNamhyung Kim'Children' here means functions that are called from another (parent) 13dd309207SNamhyung Kimfunction. 14dd309207SNamhyung Kim 15dd309207SNamhyung KimIt might be confusing that the sum of all the 'children' overhead 16dd309207SNamhyung Kimvalues exceeds 100% since each of them is already an accumulation of 17dd309207SNamhyung Kim'self' overhead of its child functions. But with this enabled, users 18dd309207SNamhyung Kimcan find which function has the most overhead even if samples are 19dd309207SNamhyung Kimspread over the children. 20dd309207SNamhyung Kim 21dd309207SNamhyung KimConsider the following example; there are three functions like below. 22dd309207SNamhyung Kim 23dd309207SNamhyung Kim----------------------- 24dd309207SNamhyung Kimvoid foo(void) { 25dd309207SNamhyung Kim /* do something */ 26dd309207SNamhyung Kim} 27dd309207SNamhyung Kim 28dd309207SNamhyung Kimvoid bar(void) { 29dd309207SNamhyung Kim /* do something */ 30dd309207SNamhyung Kim foo(); 31dd309207SNamhyung Kim} 32dd309207SNamhyung Kim 33dd309207SNamhyung Kimint main(void) { 34dd309207SNamhyung Kim bar() 35dd309207SNamhyung Kim return 0; 36dd309207SNamhyung Kim} 37dd309207SNamhyung Kim----------------------- 38dd309207SNamhyung Kim 39dd309207SNamhyung KimIn this case 'foo' is a child of 'bar', and 'bar' is an immediate 40dd309207SNamhyung Kimchild of 'main' so 'foo' also is a child of 'main'. In other words, 41dd309207SNamhyung Kim'main' is a parent of 'foo' and 'bar', and 'bar' is a parent of 'foo'. 42dd309207SNamhyung Kim 43dd309207SNamhyung KimSuppose all samples are recorded in 'foo' and 'bar' only. When it's 44dd309207SNamhyung Kimrecorded with callchains the output will show something like below 45dd309207SNamhyung Kimin the usual (self-overhead-only) output of perf report: 46dd309207SNamhyung Kim 47dd309207SNamhyung Kim---------------------------------- 48dd309207SNamhyung KimOverhead Symbol 49dd309207SNamhyung Kim........ ..................... 50dd309207SNamhyung Kim 60.00% foo 51dd309207SNamhyung Kim | 52dd309207SNamhyung Kim --- foo 53dd309207SNamhyung Kim bar 54dd309207SNamhyung Kim main 55dd309207SNamhyung Kim __libc_start_main 56dd309207SNamhyung Kim 57dd309207SNamhyung Kim 40.00% bar 58dd309207SNamhyung Kim | 59dd309207SNamhyung Kim --- bar 60dd309207SNamhyung Kim main 61dd309207SNamhyung Kim __libc_start_main 62dd309207SNamhyung Kim---------------------------------- 63dd309207SNamhyung Kim 64dd309207SNamhyung KimWhen the --children option is enabled, the 'self' overhead values of 65dd309207SNamhyung Kimchild functions (i.e. 'foo' and 'bar') are added to the parents to 66dd309207SNamhyung Kimcalculate the 'children' overhead. In this case the report could be 67dd309207SNamhyung Kimdisplayed as: 68dd309207SNamhyung Kim 69dd309207SNamhyung Kim------------------------------------------- 70dd309207SNamhyung KimChildren Self Symbol 71dd309207SNamhyung Kim........ ........ .................... 72dd309207SNamhyung Kim 100.00% 0.00% __libc_start_main 73dd309207SNamhyung Kim | 74dd309207SNamhyung Kim --- __libc_start_main 75dd309207SNamhyung Kim 76dd309207SNamhyung Kim 100.00% 0.00% main 77dd309207SNamhyung Kim | 78dd309207SNamhyung Kim --- main 79dd309207SNamhyung Kim __libc_start_main 80dd309207SNamhyung Kim 81dd309207SNamhyung Kim 100.00% 40.00% bar 82dd309207SNamhyung Kim | 83dd309207SNamhyung Kim --- bar 84dd309207SNamhyung Kim main 85dd309207SNamhyung Kim __libc_start_main 86dd309207SNamhyung Kim 87dd309207SNamhyung Kim 60.00% 60.00% foo 88dd309207SNamhyung Kim | 89dd309207SNamhyung Kim --- foo 90dd309207SNamhyung Kim bar 91dd309207SNamhyung Kim main 92dd309207SNamhyung Kim __libc_start_main 93dd309207SNamhyung Kim------------------------------------------- 94dd309207SNamhyung Kim 95dd309207SNamhyung KimIn the above output, the 'self' overhead of 'foo' (60%) was add to the 96dd309207SNamhyung Kim'children' overhead of 'bar', 'main' and '\_\_libc_start_main'. 97dd309207SNamhyung KimLikewise, the 'self' overhead of 'bar' (40%) was added to the 98dd309207SNamhyung Kim'children' overhead of 'main' and '\_\_libc_start_main'. 99dd309207SNamhyung Kim 100dd309207SNamhyung KimSo '\_\_libc_start_main' and 'main' are shown first since they have 101dd309207SNamhyung Kimsame (100%) 'children' overhead (even though they have zero 'self' 102dd309207SNamhyung Kimoverhead) and they are the parents of 'foo' and 'bar'. 103dd309207SNamhyung Kim 104dd309207SNamhyung KimSince v3.16 the 'children' overhead is shown by default and the output 105dd309207SNamhyung Kimis sorted by its values. The 'children' overhead is disabled by 106dd309207SNamhyung Kimspecifying --no-children option on the command line or by adding 107dd309207SNamhyung Kim'report.children = false' or 'top.children = false' in the perf config 108dd309207SNamhyung Kimfile. 109