162306a36Sopenharmony_ciOverhead calculation 262306a36Sopenharmony_ci-------------------- 362306a36Sopenharmony_ciThe overhead can be shown in two columns as 'Children' and 'Self' when 462306a36Sopenharmony_ciperf collects callchains. The 'self' overhead is simply calculated by 562306a36Sopenharmony_ciadding all period values of the entry - usually a function (symbol). 662306a36Sopenharmony_ciThis is the value that perf shows traditionally and sum of all the 762306a36Sopenharmony_ci'self' overhead values should be 100%. 862306a36Sopenharmony_ci 962306a36Sopenharmony_ciThe 'children' overhead is calculated by adding all period values of 1062306a36Sopenharmony_cithe child functions so that it can show the total overhead of the 1162306a36Sopenharmony_cihigher level functions even if they don't directly execute much. 1262306a36Sopenharmony_ci'Children' here means functions that are called from another (parent) 1362306a36Sopenharmony_cifunction. 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ciIt might be confusing that the sum of all the 'children' overhead 1662306a36Sopenharmony_civalues exceeds 100% since each of them is already an accumulation of 1762306a36Sopenharmony_ci'self' overhead of its child functions. But with this enabled, users 1862306a36Sopenharmony_cican find which function has the most overhead even if samples are 1962306a36Sopenharmony_cispread over the children. 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ciConsider the following example; there are three functions like below. 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci----------------------- 2462306a36Sopenharmony_civoid foo(void) { 2562306a36Sopenharmony_ci /* do something */ 2662306a36Sopenharmony_ci} 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_civoid bar(void) { 2962306a36Sopenharmony_ci /* do something */ 3062306a36Sopenharmony_ci foo(); 3162306a36Sopenharmony_ci} 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ciint main(void) { 3462306a36Sopenharmony_ci bar() 3562306a36Sopenharmony_ci return 0; 3662306a36Sopenharmony_ci} 3762306a36Sopenharmony_ci----------------------- 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ciIn this case 'foo' is a child of 'bar', and 'bar' is an immediate 4062306a36Sopenharmony_cichild of 'main' so 'foo' also is a child of 'main'. In other words, 4162306a36Sopenharmony_ci'main' is a parent of 'foo' and 'bar', and 'bar' is a parent of 'foo'. 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ciSuppose all samples are recorded in 'foo' and 'bar' only. When it's 4462306a36Sopenharmony_cirecorded with callchains the output will show something like below 4562306a36Sopenharmony_ciin the usual (self-overhead-only) output of perf report: 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci---------------------------------- 4862306a36Sopenharmony_ciOverhead Symbol 4962306a36Sopenharmony_ci........ ..................... 5062306a36Sopenharmony_ci 60.00% foo 5162306a36Sopenharmony_ci | 5262306a36Sopenharmony_ci --- foo 5362306a36Sopenharmony_ci bar 5462306a36Sopenharmony_ci main 5562306a36Sopenharmony_ci __libc_start_main 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci 40.00% bar 5862306a36Sopenharmony_ci | 5962306a36Sopenharmony_ci --- bar 6062306a36Sopenharmony_ci main 6162306a36Sopenharmony_ci __libc_start_main 6262306a36Sopenharmony_ci---------------------------------- 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ciWhen the --children option is enabled, the 'self' overhead values of 6562306a36Sopenharmony_cichild functions (i.e. 'foo' and 'bar') are added to the parents to 6662306a36Sopenharmony_cicalculate the 'children' overhead. In this case the report could be 6762306a36Sopenharmony_cidisplayed as: 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci------------------------------------------- 7062306a36Sopenharmony_ciChildren Self Symbol 7162306a36Sopenharmony_ci........ ........ .................... 7262306a36Sopenharmony_ci 100.00% 0.00% __libc_start_main 7362306a36Sopenharmony_ci | 7462306a36Sopenharmony_ci --- __libc_start_main 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci 100.00% 0.00% main 7762306a36Sopenharmony_ci | 7862306a36Sopenharmony_ci --- main 7962306a36Sopenharmony_ci __libc_start_main 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci 100.00% 40.00% bar 8262306a36Sopenharmony_ci | 8362306a36Sopenharmony_ci --- bar 8462306a36Sopenharmony_ci main 8562306a36Sopenharmony_ci __libc_start_main 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci 60.00% 60.00% foo 8862306a36Sopenharmony_ci | 8962306a36Sopenharmony_ci --- foo 9062306a36Sopenharmony_ci bar 9162306a36Sopenharmony_ci main 9262306a36Sopenharmony_ci __libc_start_main 9362306a36Sopenharmony_ci------------------------------------------- 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ciIn the above output, the 'self' overhead of 'foo' (60%) was add to the 9662306a36Sopenharmony_ci'children' overhead of 'bar', 'main' and '\_\_libc_start_main'. 9762306a36Sopenharmony_ciLikewise, the 'self' overhead of 'bar' (40%) was added to the 9862306a36Sopenharmony_ci'children' overhead of 'main' and '\_\_libc_start_main'. 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ciSo '\_\_libc_start_main' and 'main' are shown first since they have 10162306a36Sopenharmony_cisame (100%) 'children' overhead (even though they have zero 'self' 10262306a36Sopenharmony_cioverhead) and they are the parents of 'foo' and 'bar'. 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ciSince v3.16 the 'children' overhead is shown by default and the output 10562306a36Sopenharmony_ciis sorted by its values. The 'children' overhead is disabled by 10662306a36Sopenharmony_cispecifying --no-children option on the command line or by adding 10762306a36Sopenharmony_ci'report.children = false' or 'top.children = false' in the perf config 10862306a36Sopenharmony_cifile. 109