Skip to content

Commit 45f0357

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-core-for-mingo-5.6-20200201' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: perf maps: Cengiz Can: - Add missing unlock to maps__insert() error case. srcline: Changbin Du: - Make perf able to build with latest libbfd. perf parse: Leo Yan: - Keep copy of string in perf_evsel_config_term() to fix sink terms processing in ARM CoreSight. perf test: Thomas Richter: - Fix test case Merge cpu map, removing extra reference count drop that causes a segfault on s/390. perf probe: Thomas Richter: - Add ustring support for perf probe command Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2 parents fdff7c2 + 85fc95d commit 45f0357

File tree

8 files changed

+71
-32
lines changed

8 files changed

+71
-32
lines changed

tools/perf/arch/arm/util/cs-etm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ static int cs_etm_set_sink_attr(struct perf_pmu *pmu,
226226
if (term->type != PERF_EVSEL__CONFIG_TERM_DRV_CFG)
227227
continue;
228228

229-
sink = term->val.drv_cfg;
229+
sink = term->val.str;
230230
snprintf(path, PATH_MAX, "sinks/%s", sink);
231231

232232
ret = perf_pmu__scan_file(pmu, path, "%x", &hash);

tools/perf/tests/cpumap.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ int test__cpu_map_merge(struct test *test __maybe_unused, int subtest __maybe_un
131131
TEST_ASSERT_VAL("failed to merge map: bad nr", c->nr == 5);
132132
cpu_map__snprint(c, buf, sizeof(buf));
133133
TEST_ASSERT_VAL("failed to merge map: bad result", !strcmp(buf, "1-2,4-5,7"));
134-
perf_cpu_map__put(a);
135134
perf_cpu_map__put(b);
136135
perf_cpu_map__put(c);
137136
return 0;

tools/perf/util/evsel.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -808,12 +808,12 @@ static void apply_config_terms(struct evsel *evsel,
808808
perf_evsel__reset_sample_bit(evsel, TIME);
809809
break;
810810
case PERF_EVSEL__CONFIG_TERM_CALLGRAPH:
811-
callgraph_buf = term->val.callgraph;
811+
callgraph_buf = term->val.str;
812812
break;
813813
case PERF_EVSEL__CONFIG_TERM_BRANCH:
814-
if (term->val.branch && strcmp(term->val.branch, "no")) {
814+
if (term->val.str && strcmp(term->val.str, "no")) {
815815
perf_evsel__set_sample_bit(evsel, BRANCH_STACK);
816-
parse_branch_str(term->val.branch,
816+
parse_branch_str(term->val.str,
817817
&attr->branch_sample_type);
818818
} else
819819
perf_evsel__reset_sample_bit(evsel, BRANCH_STACK);
@@ -1265,6 +1265,8 @@ static void perf_evsel__free_config_terms(struct evsel *evsel)
12651265

12661266
list_for_each_entry_safe(term, h, &evsel->config_terms, list) {
12671267
list_del_init(&term->list);
1268+
if (term->free_str)
1269+
zfree(&term->val.str);
12681270
free(term);
12691271
}
12701272
}

tools/perf/util/evsel_config.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,21 @@ enum evsel_term_type {
3232
struct perf_evsel_config_term {
3333
struct list_head list;
3434
enum evsel_term_type type;
35+
bool free_str;
3536
union {
3637
u64 period;
3738
u64 freq;
3839
bool time;
39-
char *callgraph;
40-
char *drv_cfg;
4140
u64 stack_user;
4241
int max_stack;
4342
bool inherit;
4443
bool overwrite;
45-
char *branch;
4644
unsigned long max_events;
4745
bool percore;
4846
bool aux_output;
4947
u32 aux_sample_size;
5048
u64 cfg_chg;
49+
char *str;
5150
} val;
5251
bool weak;
5352
};

tools/perf/util/map.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ void maps__insert(struct maps *maps, struct map *map)
549549

550550
if (maps_by_name == NULL) {
551551
__maps__free_maps_by_name(maps);
552+
up_write(&maps->lock);
552553
return;
553554
}
554555

tools/perf/util/parse-events.c

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,8 +1219,7 @@ static int config_attr(struct perf_event_attr *attr,
12191219
static int get_config_terms(struct list_head *head_config,
12201220
struct list_head *head_terms __maybe_unused)
12211221
{
1222-
#define ADD_CONFIG_TERM(__type, __name, __val) \
1223-
do { \
1222+
#define ADD_CONFIG_TERM(__type) \
12241223
struct perf_evsel_config_term *__t; \
12251224
\
12261225
__t = zalloc(sizeof(*__t)); \
@@ -1229,63 +1228,87 @@ do { \
12291228
\
12301229
INIT_LIST_HEAD(&__t->list); \
12311230
__t->type = PERF_EVSEL__CONFIG_TERM_ ## __type; \
1232-
__t->val.__name = __val; \
12331231
__t->weak = term->weak; \
1234-
list_add_tail(&__t->list, head_terms); \
1232+
list_add_tail(&__t->list, head_terms)
1233+
1234+
#define ADD_CONFIG_TERM_VAL(__type, __name, __val) \
1235+
do { \
1236+
ADD_CONFIG_TERM(__type); \
1237+
__t->val.__name = __val; \
1238+
} while (0)
1239+
1240+
#define ADD_CONFIG_TERM_STR(__type, __val) \
1241+
do { \
1242+
ADD_CONFIG_TERM(__type); \
1243+
__t->val.str = strdup(__val); \
1244+
if (!__t->val.str) { \
1245+
zfree(&__t); \
1246+
return -ENOMEM; \
1247+
} \
1248+
__t->free_str = true; \
12351249
} while (0)
12361250

12371251
struct parse_events_term *term;
12381252

12391253
list_for_each_entry(term, head_config, list) {
12401254
switch (term->type_term) {
12411255
case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
1242-
ADD_CONFIG_TERM(PERIOD, period, term->val.num);
1256+
ADD_CONFIG_TERM_VAL(PERIOD, period, term->val.num);
12431257
break;
12441258
case PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ:
1245-
ADD_CONFIG_TERM(FREQ, freq, term->val.num);
1259+
ADD_CONFIG_TERM_VAL(FREQ, freq, term->val.num);
12461260
break;
12471261
case PARSE_EVENTS__TERM_TYPE_TIME:
1248-
ADD_CONFIG_TERM(TIME, time, term->val.num);
1262+
ADD_CONFIG_TERM_VAL(TIME, time, term->val.num);
12491263
break;
12501264
case PARSE_EVENTS__TERM_TYPE_CALLGRAPH:
1251-
ADD_CONFIG_TERM(CALLGRAPH, callgraph, term->val.str);
1265+
ADD_CONFIG_TERM_STR(CALLGRAPH, term->val.str);
12521266
break;
12531267
case PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE:
1254-
ADD_CONFIG_TERM(BRANCH, branch, term->val.str);
1268+
ADD_CONFIG_TERM_STR(BRANCH, term->val.str);
12551269
break;
12561270
case PARSE_EVENTS__TERM_TYPE_STACKSIZE:
1257-
ADD_CONFIG_TERM(STACK_USER, stack_user, term->val.num);
1271+
ADD_CONFIG_TERM_VAL(STACK_USER, stack_user,
1272+
term->val.num);
12581273
break;
12591274
case PARSE_EVENTS__TERM_TYPE_INHERIT:
1260-
ADD_CONFIG_TERM(INHERIT, inherit, term->val.num ? 1 : 0);
1275+
ADD_CONFIG_TERM_VAL(INHERIT, inherit,
1276+
term->val.num ? 1 : 0);
12611277
break;
12621278
case PARSE_EVENTS__TERM_TYPE_NOINHERIT:
1263-
ADD_CONFIG_TERM(INHERIT, inherit, term->val.num ? 0 : 1);
1279+
ADD_CONFIG_TERM_VAL(INHERIT, inherit,
1280+
term->val.num ? 0 : 1);
12641281
break;
12651282
case PARSE_EVENTS__TERM_TYPE_MAX_STACK:
1266-
ADD_CONFIG_TERM(MAX_STACK, max_stack, term->val.num);
1283+
ADD_CONFIG_TERM_VAL(MAX_STACK, max_stack,
1284+
term->val.num);
12671285
break;
12681286
case PARSE_EVENTS__TERM_TYPE_MAX_EVENTS:
1269-
ADD_CONFIG_TERM(MAX_EVENTS, max_events, term->val.num);
1287+
ADD_CONFIG_TERM_VAL(MAX_EVENTS, max_events,
1288+
term->val.num);
12701289
break;
12711290
case PARSE_EVENTS__TERM_TYPE_OVERWRITE:
1272-
ADD_CONFIG_TERM(OVERWRITE, overwrite, term->val.num ? 1 : 0);
1291+
ADD_CONFIG_TERM_VAL(OVERWRITE, overwrite,
1292+
term->val.num ? 1 : 0);
12731293
break;
12741294
case PARSE_EVENTS__TERM_TYPE_NOOVERWRITE:
1275-
ADD_CONFIG_TERM(OVERWRITE, overwrite, term->val.num ? 0 : 1);
1295+
ADD_CONFIG_TERM_VAL(OVERWRITE, overwrite,
1296+
term->val.num ? 0 : 1);
12761297
break;
12771298
case PARSE_EVENTS__TERM_TYPE_DRV_CFG:
1278-
ADD_CONFIG_TERM(DRV_CFG, drv_cfg, term->val.str);
1299+
ADD_CONFIG_TERM_STR(DRV_CFG, term->val.str);
12791300
break;
12801301
case PARSE_EVENTS__TERM_TYPE_PERCORE:
1281-
ADD_CONFIG_TERM(PERCORE, percore,
1282-
term->val.num ? true : false);
1302+
ADD_CONFIG_TERM_VAL(PERCORE, percore,
1303+
term->val.num ? true : false);
12831304
break;
12841305
case PARSE_EVENTS__TERM_TYPE_AUX_OUTPUT:
1285-
ADD_CONFIG_TERM(AUX_OUTPUT, aux_output, term->val.num ? 1 : 0);
1306+
ADD_CONFIG_TERM_VAL(AUX_OUTPUT, aux_output,
1307+
term->val.num ? 1 : 0);
12861308
break;
12871309
case PARSE_EVENTS__TERM_TYPE_AUX_SAMPLE_SIZE:
1288-
ADD_CONFIG_TERM(AUX_SAMPLE_SIZE, aux_sample_size, term->val.num);
1310+
ADD_CONFIG_TERM_VAL(AUX_SAMPLE_SIZE, aux_sample_size,
1311+
term->val.num);
12891312
break;
12901313
default:
12911314
break;
@@ -1322,7 +1345,7 @@ static int get_config_chgs(struct perf_pmu *pmu, struct list_head *head_config,
13221345
}
13231346

13241347
if (bits)
1325-
ADD_CONFIG_TERM(CFG_CHG, cfg_chg, bits);
1348+
ADD_CONFIG_TERM_VAL(CFG_CHG, cfg_chg, bits);
13261349

13271350
#undef ADD_CONFIG_TERM
13281351
return 0;

tools/perf/util/probe-finder.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ static int convert_variable_type(Dwarf_Die *vr_die,
303303
char prefix;
304304

305305
/* TODO: check all types */
306-
if (cast && strcmp(cast, "string") != 0 && strcmp(cast, "x") != 0 &&
306+
if (cast && strcmp(cast, "string") != 0 && strcmp(cast, "ustring") &&
307+
strcmp(cast, "x") != 0 &&
307308
strcmp(cast, "s") != 0 && strcmp(cast, "u") != 0) {
308309
/* Non string type is OK */
309310
/* and respect signedness/hexadecimal cast */

tools/perf/util/srcline.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,16 +193,30 @@ static void find_address_in_section(bfd *abfd, asection *section, void *data)
193193
bfd_vma pc, vma;
194194
bfd_size_type size;
195195
struct a2l_data *a2l = data;
196+
flagword flags;
196197

197198
if (a2l->found)
198199
return;
199200

200-
if ((bfd_get_section_flags(abfd, section) & SEC_ALLOC) == 0)
201+
#ifdef bfd_get_section_flags
202+
flags = bfd_get_section_flags(abfd, section);
203+
#else
204+
flags = bfd_section_flags(section);
205+
#endif
206+
if ((flags & SEC_ALLOC) == 0)
201207
return;
202208

203209
pc = a2l->addr;
210+
#ifdef bfd_get_section_vma
204211
vma = bfd_get_section_vma(abfd, section);
212+
#else
213+
vma = bfd_section_vma(section);
214+
#endif
215+
#ifdef bfd_get_section_size
205216
size = bfd_get_section_size(section);
217+
#else
218+
size = bfd_section_size(section);
219+
#endif
206220

207221
if (pc < vma || pc >= vma + size)
208222
return;

0 commit comments

Comments
 (0)