perf/core improvements and fixes:
User visible: - Change default selection TUI background color to yellow (Ingo Molnar) Infrastructure: - Start paving the way to reuse some cmdline functions with other tools/ living utilities (Josh Poimboeuf) - Reference count fixes using the refcount debugger, unleaking some objects (Masami Hiramatsu) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJWaFvZAAoJENZQFvNTUqpAYioP/1EPE4kJUUSc4QNWaN39vIWq /saTLPiEPWZOQpG0AbY4D01NQvBSbVS+6zu8akr4v5I/pR7sP6Xb7k4k0GjVsMkA dy8xmDKzdzfmZQpd6jrIhUzOG/vCO7rki51gWqxGgpZ+4izA2/Lpd3Q5lvViRHi8 h1wOfW5w3Y6R7Y2gF8NIm2/+SZDAmn166X+vy71xV2HOYpGBJ4rSl1hwH5AZFqH3 9Buxxlb3VHebqZ/0Zo+jbDYSIGe0lSKmnj/Osd4FXhJTrTIXTbmrA8jMwjIXvu33 TejnpboGT6dAJxIL6wSoyspPF8eR6HaWiSn+tN5nT4ePTACQ1tC4V61ZJHSrcYz3 DH5KKUwQrCD7VOZhx+FqchJ6pTQ2ZbsJCVCjjARa19MVawpWVBuyM+ui11GsJECg tDSQIy/wFJMJekviimPY8OFJkwyvOur6vK7vt0X65ZGSGMjDkRwyJpJoxeHXGe0K wYalhHrtoMwaXQmhEHk9Q9YDtAsTNxXQjLFCX25Qf0UBcN9fNyT+gqNS1Gb1bG98 nvqjKJfbvWnV/nmRRuB32aOLuJrBGXMfQz7E10nhPHTBG7P8a7a8uAftVFm9HGad 5sLYQXNKM9fXi+4BCYD0j949O6S3k2K4Xt5wm9PuYTBe0TMtVc2aF90dLJlfCIgP 145mFIEtsFOtvQJj+tAY =OkaH -----END PGP SIGNATURE----- Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core Pull perf/core improvements and fixes: User visible changes: - Change default selection TUI background color to yellow (Ingo Molnar) Infrastructure changes: - Start paving the way to reuse some cmdline functions with other tools/ living utilities (Josh Poimboeuf) - Reference count fixes using the refcount debugger, unleaking some objects (Masami Hiramatsu) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
commit
d18929e9fd
|
@ -20,6 +20,7 @@ perf-y += builtin-kvm.o
|
||||||
perf-y += builtin-inject.o
|
perf-y += builtin-inject.o
|
||||||
perf-y += builtin-mem.o
|
perf-y += builtin-mem.o
|
||||||
perf-y += builtin-data.o
|
perf-y += builtin-data.o
|
||||||
|
perf-y += builtin-version.o
|
||||||
|
|
||||||
perf-$(CONFIG_AUDIT) += builtin-trace.o
|
perf-$(CONFIG_AUDIT) += builtin-trace.o
|
||||||
perf-$(CONFIG_LIBELF) += builtin-probe.o
|
perf-$(CONFIG_LIBELF) += builtin-probe.o
|
||||||
|
|
|
@ -1094,6 +1094,14 @@ static int perf_stat_init_aggr_mode(void)
|
||||||
return cpus_aggr_map ? 0 : -ENOMEM;
|
return cpus_aggr_map ? 0 : -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void perf_stat__exit_aggr_mode(void)
|
||||||
|
{
|
||||||
|
cpu_map__put(aggr_map);
|
||||||
|
cpu_map__put(cpus_aggr_map);
|
||||||
|
aggr_map = NULL;
|
||||||
|
cpus_aggr_map = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add default attributes, if there were no attributes specified or
|
* Add default attributes, if there were no attributes specified or
|
||||||
* if -d/--detailed, -d -d or -d -d -d is used:
|
* if -d/--detailed, -d -d or -d -d -d is used:
|
||||||
|
@ -1442,6 +1450,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
|
||||||
if (!forever && status != -1 && !interval)
|
if (!forever && status != -1 && !interval)
|
||||||
print_counters(NULL, argc, argv);
|
print_counters(NULL, argc, argv);
|
||||||
|
|
||||||
|
perf_stat__exit_aggr_mode();
|
||||||
perf_evlist__free_stats(evsel_list);
|
perf_evlist__free_stats(evsel_list);
|
||||||
out:
|
out:
|
||||||
perf_evlist__delete(evsel_list);
|
perf_evlist__delete(evsel_list);
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
#include "util/util.h"
|
||||||
|
#include "builtin.h"
|
||||||
|
#include "perf.h"
|
||||||
|
|
||||||
|
int cmd_version(int argc __maybe_unused, const char **argv __maybe_unused,
|
||||||
|
const char *prefix __maybe_unused)
|
||||||
|
{
|
||||||
|
printf("perf version %s\n", perf_version_string);
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -384,6 +384,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
|
||||||
use_pager = 1;
|
use_pager = 1;
|
||||||
commit_pager_choice();
|
commit_pager_choice();
|
||||||
|
|
||||||
|
perf_env__set_cmdline(&perf_env, argc, argv);
|
||||||
status = p->fn(argc, argv, prefix);
|
status = p->fn(argc, argv, prefix);
|
||||||
exit_browser(status);
|
exit_browser(status);
|
||||||
perf_env__exit(&perf_env);
|
perf_env__exit(&perf_env);
|
||||||
|
|
|
@ -528,7 +528,7 @@ static struct ui_browser_colorset {
|
||||||
.colorset = HE_COLORSET_SELECTED,
|
.colorset = HE_COLORSET_SELECTED,
|
||||||
.name = "selected",
|
.name = "selected",
|
||||||
.fg = "black",
|
.fg = "black",
|
||||||
.bg = "lightgray",
|
.bg = "yellow",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.colorset = HE_COLORSET_CODE,
|
.colorset = HE_COLORSET_CODE,
|
||||||
|
|
|
@ -6,7 +6,6 @@ libperf-y += config.o
|
||||||
libperf-y += ctype.o
|
libperf-y += ctype.o
|
||||||
libperf-y += db-export.o
|
libperf-y += db-export.o
|
||||||
libperf-y += env.o
|
libperf-y += env.o
|
||||||
libperf-y += environment.o
|
|
||||||
libperf-y += event.o
|
libperf-y += event.o
|
||||||
libperf-y += evlist.o
|
libperf-y += evlist.o
|
||||||
libperf-y += evsel.o
|
libperf-y += evsel.o
|
||||||
|
@ -87,6 +86,7 @@ libperf-$(CONFIG_AUXTRACE) += intel-pt.o
|
||||||
libperf-$(CONFIG_AUXTRACE) += intel-bts.o
|
libperf-$(CONFIG_AUXTRACE) += intel-bts.o
|
||||||
libperf-y += parse-branch-options.o
|
libperf-y += parse-branch-options.o
|
||||||
libperf-y += parse-regs-options.o
|
libperf-y += parse-regs-options.o
|
||||||
|
libperf-y += term.o
|
||||||
|
|
||||||
libperf-$(CONFIG_LIBBPF) += bpf-loader.o
|
libperf-$(CONFIG_LIBBPF) += bpf-loader.o
|
||||||
libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o
|
libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o
|
||||||
|
|
|
@ -31,7 +31,6 @@ extern const char *perf_config_dirname(const char *, const char *);
|
||||||
/* pager.c */
|
/* pager.c */
|
||||||
extern void setup_pager(void);
|
extern void setup_pager(void);
|
||||||
extern int pager_in_use(void);
|
extern int pager_in_use(void);
|
||||||
extern int pager_use_color;
|
|
||||||
|
|
||||||
char *alias_lookup(const char *alias);
|
char *alias_lookup(const char *alias);
|
||||||
int split_cmdline(char *cmdline, const char ***argv);
|
int split_cmdline(char *cmdline, const char ***argv);
|
||||||
|
|
|
@ -24,7 +24,7 @@ int perf_config_colorbool(const char *var, const char *value, int stdout_is_tty)
|
||||||
auto_color:
|
auto_color:
|
||||||
if (stdout_is_tty < 0)
|
if (stdout_is_tty < 0)
|
||||||
stdout_is_tty = isatty(1);
|
stdout_is_tty = isatty(1);
|
||||||
if (stdout_is_tty || (pager_in_use() && pager_use_color)) {
|
if (stdout_is_tty || pager_in_use()) {
|
||||||
char *term = getenv("TERM");
|
char *term = getenv("TERM");
|
||||||
if (term && strcmp(term, "dumb"))
|
if (term && strcmp(term, "dumb"))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -25,15 +25,6 @@ int perf_env__set_cmdline(struct perf_env *env, int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/*
|
|
||||||
* If env->cmdline_argv has already been set, do not override it. This allows
|
|
||||||
* a command to set the cmdline, parse args and then call another
|
|
||||||
* builtin function that implements a command -- e.g, cmd_kvm calling
|
|
||||||
* cmd_record.
|
|
||||||
*/
|
|
||||||
if (env->cmdline_argv != NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* do not include NULL termination */
|
/* do not include NULL termination */
|
||||||
env->cmdline_argv = calloc(argc, sizeof(char *));
|
env->cmdline_argv = calloc(argc, sizeof(char *));
|
||||||
if (env->cmdline_argv == NULL)
|
if (env->cmdline_argv == NULL)
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
/*
|
|
||||||
* We put all the perf config variables in this same object
|
|
||||||
* file, so that programs can link against the config parser
|
|
||||||
* without having to link against all the rest of perf.
|
|
||||||
*/
|
|
||||||
#include "cache.h"
|
|
||||||
|
|
||||||
int pager_use_color = 1;
|
|
|
@ -724,7 +724,7 @@ static int write_numa_topology(int fd, struct perf_header *h __maybe_unused,
|
||||||
done:
|
done:
|
||||||
free(buf);
|
free(buf);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
free(node_map);
|
cpu_map__put(node_map);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -332,10 +332,3 @@ const char *help_unknown_cmd(const char *cmd)
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmd_version(int argc __maybe_unused, const char **argv __maybe_unused,
|
|
||||||
const char *prefix __maybe_unused)
|
|
||||||
{
|
|
||||||
printf("perf version %s\n", perf_version_string);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1567,6 +1567,13 @@ static int hists_evsel__init(struct perf_evsel *evsel)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void hists_evsel__exit(struct perf_evsel *evsel)
|
||||||
|
{
|
||||||
|
struct hists *hists = evsel__hists(evsel);
|
||||||
|
|
||||||
|
hists__delete_entries(hists);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX We probably need a hists_evsel__exit() to free the hist_entries
|
* XXX We probably need a hists_evsel__exit() to free the hist_entries
|
||||||
* stored in the rbtree...
|
* stored in the rbtree...
|
||||||
|
@ -1575,7 +1582,8 @@ static int hists_evsel__init(struct perf_evsel *evsel)
|
||||||
int hists__init(void)
|
int hists__init(void)
|
||||||
{
|
{
|
||||||
int err = perf_evsel__object_config(sizeof(struct hists_evsel),
|
int err = perf_evsel__object_config(sizeof(struct hists_evsel),
|
||||||
hists_evsel__init, NULL);
|
hists_evsel__init,
|
||||||
|
hists_evsel__exit);
|
||||||
if (err)
|
if (err)
|
||||||
fputs("FATAL ERROR: Couldn't setup hists class\n", stderr);
|
fputs("FATAL ERROR: Couldn't setup hists class\n", stderr);
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,8 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
|
||||||
machine->comm_exec = false;
|
machine->comm_exec = false;
|
||||||
machine->kernel_start = 0;
|
machine->kernel_start = 0;
|
||||||
|
|
||||||
|
memset(machine->vmlinux_maps, 0, sizeof(machine->vmlinux_maps));
|
||||||
|
|
||||||
machine->root_dir = strdup(root_dir);
|
machine->root_dir = strdup(root_dir);
|
||||||
if (machine->root_dir == NULL)
|
if (machine->root_dir == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -770,6 +772,9 @@ int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel)
|
||||||
enum map_type type;
|
enum map_type type;
|
||||||
u64 start = machine__get_running_kernel_start(machine, NULL);
|
u64 start = machine__get_running_kernel_start(machine, NULL);
|
||||||
|
|
||||||
|
/* In case of renewal the kernel map, destroy previous one */
|
||||||
|
machine__destroy_kernel_maps(machine);
|
||||||
|
|
||||||
for (type = 0; type < MAP__NR_TYPES; ++type) {
|
for (type = 0; type < MAP__NR_TYPES; ++type) {
|
||||||
struct kmap *kmap;
|
struct kmap *kmap;
|
||||||
struct map *map;
|
struct map *map;
|
||||||
|
|
|
@ -691,6 +691,7 @@ static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp
|
||||||
__map_groups__insert(pos->groups, before);
|
__map_groups__insert(pos->groups, before);
|
||||||
if (verbose >= 2)
|
if (verbose >= 2)
|
||||||
map__fprintf(before, fp);
|
map__fprintf(before, fp);
|
||||||
|
map__put(before);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map->end < pos->end) {
|
if (map->end < pos->end) {
|
||||||
|
@ -705,6 +706,7 @@ static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp
|
||||||
__map_groups__insert(pos->groups, after);
|
__map_groups__insert(pos->groups, after);
|
||||||
if (verbose >= 2)
|
if (verbose >= 2)
|
||||||
map__fprintf(after, fp);
|
map__fprintf(after, fp);
|
||||||
|
map__put(after);
|
||||||
}
|
}
|
||||||
put_map:
|
put_map:
|
||||||
map__put(pos);
|
map__put(pos);
|
||||||
|
@ -742,6 +744,7 @@ int map_groups__clone(struct map_groups *mg,
|
||||||
if (new == NULL)
|
if (new == NULL)
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
map_groups__insert(mg, new);
|
map_groups__insert(mg, new);
|
||||||
|
map__put(new);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = 0;
|
err = 0;
|
||||||
|
|
|
@ -501,8 +501,6 @@ int parse_options_subcommand(int argc, const char **argv, const struct option *o
|
||||||
{
|
{
|
||||||
struct parse_opt_ctx_t ctx;
|
struct parse_opt_ctx_t ctx;
|
||||||
|
|
||||||
perf_env__set_cmdline(&perf_env, argc, argv);
|
|
||||||
|
|
||||||
/* build usage string if it's not provided */
|
/* build usage string if it's not provided */
|
||||||
if (subcommands && !usagestr[0]) {
|
if (subcommands && !usagestr[0]) {
|
||||||
struct strbuf buf = STRBUF_INIT;
|
struct strbuf buf = STRBUF_INIT;
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
void get_term_dimensions(struct winsize *ws)
|
||||||
|
{
|
||||||
|
char *s = getenv("LINES");
|
||||||
|
|
||||||
|
if (s != NULL) {
|
||||||
|
ws->ws_row = atoi(s);
|
||||||
|
s = getenv("COLUMNS");
|
||||||
|
if (s != NULL) {
|
||||||
|
ws->ws_col = atoi(s);
|
||||||
|
if (ws->ws_row && ws->ws_col)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef TIOCGWINSZ
|
||||||
|
if (ioctl(1, TIOCGWINSZ, ws) == 0 &&
|
||||||
|
ws->ws_row && ws->ws_col)
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
ws->ws_row = 25;
|
||||||
|
ws->ws_col = 80;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_term_quiet_input(struct termios *old)
|
||||||
|
{
|
||||||
|
struct termios tc;
|
||||||
|
|
||||||
|
tcgetattr(0, old);
|
||||||
|
tc = *old;
|
||||||
|
tc.c_lflag &= ~(ICANON | ECHO);
|
||||||
|
tc.c_cc[VMIN] = 0;
|
||||||
|
tc.c_cc[VTIME] = 0;
|
||||||
|
tcsetattr(0, TCSANOW, &tc);
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef __PERF_TERM_H
|
||||||
|
#define __PERF_TERM_H
|
||||||
|
|
||||||
|
struct termios;
|
||||||
|
struct winsize;
|
||||||
|
|
||||||
|
void get_term_dimensions(struct winsize *ws);
|
||||||
|
void set_term_quiet_input(struct termios *old);
|
||||||
|
|
||||||
|
#endif /* __PERF_TERM_H */
|
|
@ -355,40 +355,6 @@ void sighandler_dump_stack(int sig)
|
||||||
exit(sig);
|
exit(sig);
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_term_dimensions(struct winsize *ws)
|
|
||||||
{
|
|
||||||
char *s = getenv("LINES");
|
|
||||||
|
|
||||||
if (s != NULL) {
|
|
||||||
ws->ws_row = atoi(s);
|
|
||||||
s = getenv("COLUMNS");
|
|
||||||
if (s != NULL) {
|
|
||||||
ws->ws_col = atoi(s);
|
|
||||||
if (ws->ws_row && ws->ws_col)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef TIOCGWINSZ
|
|
||||||
if (ioctl(1, TIOCGWINSZ, ws) == 0 &&
|
|
||||||
ws->ws_row && ws->ws_col)
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
ws->ws_row = 25;
|
|
||||||
ws->ws_col = 80;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_term_quiet_input(struct termios *old)
|
|
||||||
{
|
|
||||||
struct termios tc;
|
|
||||||
|
|
||||||
tcgetattr(0, old);
|
|
||||||
tc = *old;
|
|
||||||
tc.c_lflag &= ~(ICANON | ECHO);
|
|
||||||
tc.c_cc[VMIN] = 0;
|
|
||||||
tc.c_cc[VTIME] = 0;
|
|
||||||
tcsetattr(0, TCSANOW, &tc);
|
|
||||||
}
|
|
||||||
|
|
||||||
int parse_nsec_time(const char *str, u64 *ptime)
|
int parse_nsec_time(const char *str, u64 *ptime)
|
||||||
{
|
{
|
||||||
u64 time_sec, time_nsec;
|
u64 time_sec, time_nsec;
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <term.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
@ -282,9 +283,6 @@ void sighandler_dump_stack(int sig);
|
||||||
extern unsigned int page_size;
|
extern unsigned int page_size;
|
||||||
extern int cacheline_size;
|
extern int cacheline_size;
|
||||||
|
|
||||||
void get_term_dimensions(struct winsize *ws);
|
|
||||||
void set_term_quiet_input(struct termios *old);
|
|
||||||
|
|
||||||
struct parse_tag {
|
struct parse_tag {
|
||||||
char tag;
|
char tag;
|
||||||
int mult;
|
int mult;
|
||||||
|
|
Loading…
Reference in New Issue