@@ -2190,6 +2190,40 @@ static int remove_loops(struct branch_entry *l, int nr,
2190
2190
return nr ;
2191
2191
}
2192
2192
2193
+ static int lbr_callchain_add_kernel_ip (struct thread * thread ,
2194
+ struct callchain_cursor * cursor ,
2195
+ struct perf_sample * sample ,
2196
+ struct symbol * * parent ,
2197
+ struct addr_location * root_al ,
2198
+ u64 branch_from ,
2199
+ bool callee , int end )
2200
+ {
2201
+ struct ip_callchain * chain = sample -> callchain ;
2202
+ u8 cpumode = PERF_RECORD_MISC_USER ;
2203
+ int err , i ;
2204
+
2205
+ if (callee ) {
2206
+ for (i = 0 ; i < end + 1 ; i ++ ) {
2207
+ err = add_callchain_ip (thread , cursor , parent ,
2208
+ root_al , & cpumode , chain -> ips [i ],
2209
+ false, NULL , NULL , branch_from );
2210
+ if (err )
2211
+ return err ;
2212
+ }
2213
+ return 0 ;
2214
+ }
2215
+
2216
+ for (i = end ; i >= 0 ; i -- ) {
2217
+ err = add_callchain_ip (thread , cursor , parent ,
2218
+ root_al , & cpumode , chain -> ips [i ],
2219
+ false, NULL , NULL , branch_from );
2220
+ if (err )
2221
+ return err ;
2222
+ }
2223
+
2224
+ return 0 ;
2225
+ }
2226
+
2193
2227
/*
2194
2228
* Recolve LBR callstack chain sample
2195
2229
* Return:
@@ -2242,17 +2276,12 @@ static int resolve_lbr_callchain_sample(struct thread *thread,
2242
2276
2243
2277
if (callchain_param .order == ORDER_CALLEE ) {
2244
2278
/* Add kernel ip */
2245
- for (j = 0 ; j < i + 1 ; j ++ ) {
2246
- ip = chain -> ips [j ];
2247
- branch = false;
2248
- flags = NULL ;
2249
- err = add_callchain_ip (thread , cursor , parent ,
2250
- root_al , & cpumode , ip ,
2251
- branch , flags , NULL ,
2252
- branch_from );
2253
- if (err )
2254
- goto error ;
2255
- }
2279
+ err = lbr_callchain_add_kernel_ip (thread , cursor , sample ,
2280
+ parent , root_al , branch_from ,
2281
+ true, i );
2282
+ if (err )
2283
+ goto error ;
2284
+
2256
2285
/* Add LBR ip from first entries.to */
2257
2286
ip = entries [0 ].to ;
2258
2287
branch = true;
@@ -2308,17 +2337,11 @@ static int resolve_lbr_callchain_sample(struct thread *thread,
2308
2337
goto error ;
2309
2338
2310
2339
/* Add kernel ip */
2311
- for (j = lbr_nr + 1 ; j < mix_chain_nr ; j ++ ) {
2312
- ip = chain -> ips [i + 1 - (j - lbr_nr )];
2313
- branch = false;
2314
- flags = NULL ;
2315
- err = add_callchain_ip (thread , cursor , parent ,
2316
- root_al , & cpumode , ip ,
2317
- branch , flags , NULL ,
2318
- branch_from );
2319
- if (err )
2320
- goto error ;
2321
- }
2340
+ err = lbr_callchain_add_kernel_ip (thread , cursor , sample ,
2341
+ parent , root_al , branch_from ,
2342
+ false, i );
2343
+ if (err )
2344
+ goto error ;
2322
2345
}
2323
2346
return 1 ;
2324
2347
0 commit comments