Skip to content

Commit f860326

Browse files
Kan Liangacmel
authored andcommitted
perf machine: Remove the indent in resolve_lbr_callchain_sample
The indent is unnecessary in resolve_lbr_callchain_sample. Removing it will make the following patch simpler. Current code path for resolve_lbr_callchain_sample() /* LBR only affects the user callchain */ if (i != chain_nr) { body of the function .... return 1; } return 0; With the patch, /* LBR only affects the user callchain */ if (i == chain_nr) return 0; body of the function ... return 1; No functional changes. Signed-off-by: Kan Liang <[email protected]> Reviewed-by: Andi Kleen <[email protected]> Acked-by: Jiri Olsa <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexey Budankov <[email protected]> Cc: Mathieu Poirier <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Pavel Gerasimov <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ravi Bangoria <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Vitaly Slobodskoy <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 6f91ea2 commit f860326

File tree

1 file changed

+63
-60
lines changed

1 file changed

+63
-60
lines changed

tools/perf/util/machine.c

Lines changed: 63 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,78 +2208,81 @@ static int resolve_lbr_callchain_sample(struct thread *thread,
22082208
int chain_nr = min(max_stack, (int)chain->nr), i;
22092209
u8 cpumode = PERF_RECORD_MISC_USER;
22102210
u64 ip, branch_from = 0;
2211+
struct branch_stack *lbr_stack;
2212+
struct branch_entry *entries;
2213+
int lbr_nr, j, k;
2214+
bool branch;
2215+
struct branch_flags *flags;
2216+
int mix_chain_nr;
22112217

22122218
for (i = 0; i < chain_nr; i++) {
22132219
if (chain->ips[i] == PERF_CONTEXT_USER)
22142220
break;
22152221
}
22162222

22172223
/* LBR only affects the user callchain */
2218-
if (i != chain_nr) {
2219-
struct branch_stack *lbr_stack = sample->branch_stack;
2220-
struct branch_entry *entries = perf_sample__branch_entries(sample);
2221-
int lbr_nr = lbr_stack->nr, j, k;
2222-
bool branch;
2223-
struct branch_flags *flags;
2224-
/*
2225-
* LBR callstack can only get user call chain.
2226-
* The mix_chain_nr is kernel call chain
2227-
* number plus LBR user call chain number.
2228-
* i is kernel call chain number,
2229-
* 1 is PERF_CONTEXT_USER,
2230-
* lbr_nr + 1 is the user call chain number.
2231-
* For details, please refer to the comments
2232-
* in callchain__printf
2233-
*/
2234-
int mix_chain_nr = i + 1 + lbr_nr + 1;
2235-
2236-
for (j = 0; j < mix_chain_nr; j++) {
2237-
int err;
2238-
branch = false;
2239-
flags = NULL;
2224+
if (i == chain_nr)
2225+
return 0;
22402226

2241-
if (callchain_param.order == ORDER_CALLEE) {
2242-
if (j < i + 1)
2243-
ip = chain->ips[j];
2244-
else if (j > i + 1) {
2245-
k = j - i - 2;
2246-
ip = entries[k].from;
2247-
branch = true;
2248-
flags = &entries[k].flags;
2249-
} else {
2250-
ip = entries[0].to;
2251-
branch = true;
2252-
flags = &entries[0].flags;
2253-
branch_from = entries[0].from;
2254-
}
2227+
lbr_stack = sample->branch_stack;
2228+
entries = perf_sample__branch_entries(sample);
2229+
lbr_nr = lbr_stack->nr;
2230+
/*
2231+
* LBR callstack can only get user call chain.
2232+
* The mix_chain_nr is kernel call chain
2233+
* number plus LBR user call chain number.
2234+
* i is kernel call chain number,
2235+
* 1 is PERF_CONTEXT_USER,
2236+
* lbr_nr + 1 is the user call chain number.
2237+
* For details, please refer to the comments
2238+
* in callchain__printf
2239+
*/
2240+
mix_chain_nr = i + 1 + lbr_nr + 1;
2241+
2242+
for (j = 0; j < mix_chain_nr; j++) {
2243+
int err;
2244+
2245+
branch = false;
2246+
flags = NULL;
2247+
2248+
if (callchain_param.order == ORDER_CALLEE) {
2249+
if (j < i + 1)
2250+
ip = chain->ips[j];
2251+
else if (j > i + 1) {
2252+
k = j - i - 2;
2253+
ip = entries[k].from;
2254+
branch = true;
2255+
flags = &entries[k].flags;
22552256
} else {
2256-
if (j < lbr_nr) {
2257-
k = lbr_nr - j - 1;
2258-
ip = entries[k].from;
2259-
branch = true;
2260-
flags = &entries[k].flags;
2261-
}
2262-
else if (j > lbr_nr)
2263-
ip = chain->ips[i + 1 - (j - lbr_nr)];
2264-
else {
2265-
ip = entries[0].to;
2266-
branch = true;
2267-
flags = &entries[0].flags;
2268-
branch_from = entries[0].from;
2269-
}
2257+
ip = entries[0].to;
2258+
branch = true;
2259+
flags = &entries[0].flags;
2260+
branch_from = entries[0].from;
2261+
}
2262+
} else {
2263+
if (j < lbr_nr) {
2264+
k = lbr_nr - j - 1;
2265+
ip = entries[k].from;
2266+
branch = true;
2267+
flags = &entries[k].flags;
2268+
} else if (j > lbr_nr)
2269+
ip = chain->ips[i + 1 - (j - lbr_nr)];
2270+
else {
2271+
ip = entries[0].to;
2272+
branch = true;
2273+
flags = &entries[0].flags;
2274+
branch_from = entries[0].from;
22702275
}
2271-
2272-
err = add_callchain_ip(thread, cursor, parent,
2273-
root_al, &cpumode, ip,
2274-
branch, flags, NULL,
2275-
branch_from);
2276-
if (err)
2277-
return (err < 0) ? err : 0;
22782276
}
2279-
return 1;
2280-
}
22812277

2282-
return 0;
2278+
err = add_callchain_ip(thread, cursor, parent,
2279+
root_al, &cpumode, ip,
2280+
branch, flags, NULL,
2281+
branch_from);
2282+
if (err)
2283+
return (err < 0) ? err : 0;
2284+
}
2285+
return 1;
22832286
}
22842287

22852288
static int find_prev_cpumode(struct ip_callchain *chain, struct thread *thread,

0 commit comments

Comments
 (0)