mirror of
https://github.com/torvalds/linux.git
synced 2024-12-15 07:33:56 +00:00
Fixes for perf/urgent
. Set name of tracepoints when reading the perf.data headers, so that we don't end up using the local ones, from /sys. . Fix default output file for perf stat, from Stephane Eranian. . Fix endian handling of features bitmask in perf.data header, from David Ahern Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (GNU/Linux) iQIcBAABAgAGBQJP2K//AAoJENZQFvNTUqpAMDMP/3/SbjZSr4YQZx6CNXBjak3D DiJc7R0h6VjxuStQknn9x+pL1Mwd0Avy6c1BUx4DSJntdTvjrFCFxo8ryc837Ry0 pJ+tWYGHu3RhGUAMYL1kgG/5lL907Zv1jrSMkuY9bMTTwao7wacuH79JYb8OPbIp Fcth00OU5O1az++U36rTKGzIP5/vaJPyGL8l3VblzMQNpADWYQ5KWSa0hfwwbd/r w1oARIh9WBmKEMO6xVgAWzgyfcsjJMFoIhk77A+YNHwrcb/3XQRxeIIy9I8yg9s5 1cwb3KlfdLi+V1j2x0O2Elnta0KsVeCdurVrdp8Kc4b3yeDeCZnQ7j5N9B2afuE3 eIbWVMsIqfA5uGanSzPEz36qgb+JcPQmlEqrIwPIiK7QZXDSSTMgthq8RHiMv+g1 sbRgxpRSo9HjRGz65LL0C4umkbRXyLB30RSW2yvqyzQMxVkhlieDQxGet2ICkcus tdVHhfGSk7aGVAKwMX1FnRsAgzPrVwUOvj1WoUo5MQpE4gPC/nvx3/LnSF86lPop hF+WqPUybCn/j3+rR/SfuQEC5YygDwLK4DB1MfdzWVfAXBunrVSsZTIEGnR9Eqrt 8wCFRAftks/xmwVHeXE8XjQcrF8xAe4nOrJUDcC42uIIBa7JwkKUS2TRUrU8Oyau i3+2THoljqfnWPEP5zY7 =nEew -----END PGP SIGNATURE----- Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent Pull perf fixes from Arnaldo Carvalho de Melo: * Set name of tracepoints when reading the perf.data headers, so that we don't end up using the local ones, from /sys. * Fix default output file for perf stat, from Stephane Eranian. * Fix endian handling of features bitmask in perf.data header, from David Ahern. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
commit
8ed9eac476
@ -1179,6 +1179,12 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
|
||||
fprintf(stderr, "cannot use both --output and --log-fd\n");
|
||||
usage_with_options(stat_usage, options);
|
||||
}
|
||||
|
||||
if (output_fd < 0) {
|
||||
fprintf(stderr, "argument to --log-fd must be a > 0\n");
|
||||
usage_with_options(stat_usage, options);
|
||||
}
|
||||
|
||||
if (!output) {
|
||||
struct timespec tm;
|
||||
mode = append_file ? "a" : "w";
|
||||
@ -1190,7 +1196,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
|
||||
}
|
||||
clock_gettime(CLOCK_REALTIME, &tm);
|
||||
fprintf(output, "# started on %s\n", ctime(&tm.tv_sec));
|
||||
} else if (output_fd != 2) {
|
||||
} else if (output_fd > 0) {
|
||||
mode = append_file ? "a" : "w";
|
||||
output = fdopen(output_fd, mode);
|
||||
if (!output) {
|
||||
|
@ -1942,7 +1942,6 @@ int perf_file_header__read(struct perf_file_header *header,
|
||||
else
|
||||
return -1;
|
||||
} else if (ph->needs_swap) {
|
||||
unsigned int i;
|
||||
/*
|
||||
* feature bitmap is declared as an array of unsigned longs --
|
||||
* not good since its size can differ between the host that
|
||||
@ -1958,14 +1957,17 @@ int perf_file_header__read(struct perf_file_header *header,
|
||||
* file), punt and fallback to the original behavior --
|
||||
* clearing all feature bits and setting buildid.
|
||||
*/
|
||||
for (i = 0; i < BITS_TO_LONGS(HEADER_FEAT_BITS); ++i)
|
||||
header->adds_features[i] = bswap_64(header->adds_features[i]);
|
||||
mem_bswap_64(&header->adds_features,
|
||||
BITS_TO_U64(HEADER_FEAT_BITS));
|
||||
|
||||
if (!test_bit(HEADER_HOSTNAME, header->adds_features)) {
|
||||
for (i = 0; i < BITS_TO_LONGS(HEADER_FEAT_BITS); ++i) {
|
||||
header->adds_features[i] = bswap_64(header->adds_features[i]);
|
||||
header->adds_features[i] = bswap_32(header->adds_features[i]);
|
||||
}
|
||||
/* unswap as u64 */
|
||||
mem_bswap_64(&header->adds_features,
|
||||
BITS_TO_U64(HEADER_FEAT_BITS));
|
||||
|
||||
/* unswap as u32 */
|
||||
mem_bswap_32(&header->adds_features,
|
||||
BITS_TO_U32(HEADER_FEAT_BITS));
|
||||
}
|
||||
|
||||
if (!test_bit(HEADER_HOSTNAME, header->adds_features)) {
|
||||
@ -2091,6 +2093,35 @@ static int read_attr(int fd, struct perf_header *ph,
|
||||
return ret <= 0 ? -1 : 0;
|
||||
}
|
||||
|
||||
static int perf_evsel__set_tracepoint_name(struct perf_evsel *evsel)
|
||||
{
|
||||
struct event_format *event = trace_find_event(evsel->attr.config);
|
||||
char bf[128];
|
||||
|
||||
if (event == NULL)
|
||||
return -1;
|
||||
|
||||
snprintf(bf, sizeof(bf), "%s:%s", event->system, event->name);
|
||||
evsel->name = strdup(bf);
|
||||
if (event->name == NULL)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int perf_evlist__set_tracepoint_names(struct perf_evlist *evlist)
|
||||
{
|
||||
struct perf_evsel *pos;
|
||||
|
||||
list_for_each_entry(pos, &evlist->entries, node) {
|
||||
if (pos->attr.type == PERF_TYPE_TRACEPOINT &&
|
||||
perf_evsel__set_tracepoint_name(pos))
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int perf_session__read_header(struct perf_session *session, int fd)
|
||||
{
|
||||
struct perf_header *header = &session->header;
|
||||
@ -2172,6 +2203,9 @@ int perf_session__read_header(struct perf_session *session, int fd)
|
||||
|
||||
lseek(fd, header->data_offset, SEEK_SET);
|
||||
|
||||
if (perf_evlist__set_tracepoint_names(session->evlist))
|
||||
goto out_delete_evlist;
|
||||
|
||||
header->frozen = 1;
|
||||
return 0;
|
||||
out_errno:
|
||||
|
@ -8,6 +8,8 @@
|
||||
#define BITS_PER_LONG __WORDSIZE
|
||||
#define BITS_PER_BYTE 8
|
||||
#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
|
||||
#define BITS_TO_U64(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u64))
|
||||
#define BITS_TO_U32(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u32))
|
||||
|
||||
#define for_each_set_bit(bit, addr, size) \
|
||||
for ((bit) = find_first_bit((addr), (size)); \
|
||||
|
@ -442,6 +442,16 @@ static void perf_tool__fill_defaults(struct perf_tool *tool)
|
||||
tool->finished_round = process_finished_round_stub;
|
||||
}
|
||||
}
|
||||
|
||||
void mem_bswap_32(void *src, int byte_size)
|
||||
{
|
||||
u32 *m = src;
|
||||
while (byte_size > 0) {
|
||||
*m = bswap_32(*m);
|
||||
byte_size -= sizeof(u32);
|
||||
++m;
|
||||
}
|
||||
}
|
||||
|
||||
void mem_bswap_64(void *src, int byte_size)
|
||||
{
|
||||
|
@ -80,6 +80,7 @@ struct branch_info *machine__resolve_bstack(struct machine *self,
|
||||
bool perf_session__has_traces(struct perf_session *self, const char *msg);
|
||||
|
||||
void mem_bswap_64(void *src, int byte_size);
|
||||
void mem_bswap_32(void *src, int byte_size);
|
||||
void perf_event__attr_swap(struct perf_event_attr *attr);
|
||||
|
||||
int perf_session__create_kernel_maps(struct perf_session *self);
|
||||
|
Loading…
Reference in New Issue
Block a user