Skip to content

Commit

Permalink
Merge branch 'perf/core' of git://github.com/acmel/linux into perf/core
Browse files Browse the repository at this point in the history
  • Loading branch information
Ingo Molnar committed Oct 15, 2011
2 parents 910e94d + 6c3c5b2 commit c73a3cb
Show file tree
Hide file tree
Showing 13 changed files with 375 additions and 165 deletions.
25 changes: 20 additions & 5 deletions tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ static void print_sym_table(void)

hists__collapse_resort_threaded(&top.sym_evsel->hists);
hists__output_resort_threaded(&top.sym_evsel->hists);
hists__decay_entries(&top.sym_evsel->hists);
hists__decay_entries_threaded(&top.sym_evsel->hists);
hists__output_recalc_col_len(&top.sym_evsel->hists, winsize.ws_row - 3);
putchar('\n');
hists__fprintf(&top.sym_evsel->hists, NULL, false, false,
Expand Down Expand Up @@ -555,7 +555,7 @@ static void perf_top__sort_new_samples(void *arg)

hists__collapse_resort_threaded(&t->sym_evsel->hists);
hists__output_resort_threaded(&t->sym_evsel->hists);
hists__decay_entries(&t->sym_evsel->hists);
hists__decay_entries_threaded(&t->sym_evsel->hists);
hists__output_recalc_col_len(&t->sym_evsel->hists, winsize.ws_row - 3);
}

Expand Down Expand Up @@ -585,16 +585,31 @@ static void *display_thread(void *arg __used)
tc.c_cc[VMIN] = 0;
tc.c_cc[VTIME] = 0;

pthread__unblock_sigwinch();
repeat:
delay_msecs = top.delay_secs * 1000;
tcsetattr(0, TCSANOW, &tc);
/* trash return*/
getc(stdin);

do {
while (1) {
print_sym_table();
} while (!poll(&stdin_poll, 1, delay_msecs) == 1);

/*
* Either timeout expired or we got an EINTR due to SIGWINCH,
* refresh screen in both cases.
*/
switch (poll(&stdin_poll, 1, delay_msecs)) {
case 0:
continue;
case -1:
if (errno == EINTR)
continue;
/* Fall trhu */
default:
goto process_hotkey;
}
}
process_hotkey:
c = getc(stdin);
tcsetattr(0, TCSAFLUSH, &save);

Expand Down
24 changes: 24 additions & 0 deletions tools/perf/perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,24 @@ static void get_debugfs_mntpt(void)
debugfs_mntpt[0] = '\0';
}

static void pthread__block_sigwinch(void)
{
sigset_t set;

sigemptyset(&set);
sigaddset(&set, SIGWINCH);
pthread_sigmask(SIG_BLOCK, &set, NULL);
}

void pthread__unblock_sigwinch(void)
{
sigset_t set;

sigemptyset(&set);
sigaddset(&set, SIGWINCH);
pthread_sigmask(SIG_UNBLOCK, &set, NULL);
}

int main(int argc, const char **argv)
{
const char *cmd;
Expand Down Expand Up @@ -480,6 +498,12 @@ int main(int argc, const char **argv)
* time.
*/
setup_path();
/*
* Block SIGWINCH notifications so that the thread that wants it can
* unblock and get syscalls like select interrupted instead of waiting
* forever while the signal goes to some other non interested thread.
*/
pthread__block_sigwinch();

while (1) {
static int done_help;
Expand Down
2 changes: 2 additions & 0 deletions tools/perf/perf.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,6 @@ struct ip_callchain {
extern bool perf_host, perf_guest;
extern const char perf_version_string[];

void pthread__unblock_sigwinch(void);

#endif
2 changes: 1 addition & 1 deletion tools/perf/util/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir)
if (access(linkname, F_OK))
goto out_free;

if (readlink(linkname, filename, size) < 0)
if (readlink(linkname, filename, size - 1) < 0)
goto out_free;

if (unlink(linkname))
Expand Down
24 changes: 20 additions & 4 deletions tools/perf/util/hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,31 @@ static void hist_entry__decay(struct hist_entry *he)

static bool hists__decay_entry(struct hists *hists, struct hist_entry *he)
{
if (he->period == 0)
return true;
hists->stats.total_period -= he->period;
hist_entry__decay(he);
hists->stats.total_period += he->period;
return he->period == 0;
}

void hists__decay_entries(struct hists *hists)
static void __hists__decay_entries(struct hists *hists, bool threaded)
{
struct rb_node *next = rb_first(&hists->entries);
struct hist_entry *n;

while (next) {
n = rb_entry(next, struct hist_entry, rb_node);
next = rb_next(&n->rb_node);

if (hists__decay_entry(hists, n)) {
/*
* We may be annotating this, for instance, so keep it here in
* case some it gets new samples, we'll eventually free it when
* the user stops browsing and it agains gets fully decayed.
*/
if (hists__decay_entry(hists, n) && !n->used) {
rb_erase(&n->rb_node, &hists->entries);

if (sort__need_collapse)
if (sort__need_collapse || threaded)
rb_erase(&n->rb_node_in, &hists->entries_collapsed);

hist_entry__free(n);
Expand All @@ -127,6 +133,16 @@ void hists__decay_entries(struct hists *hists)
}
}

void hists__decay_entries(struct hists *hists)
{
return __hists__decay_entries(hists, false);
}

void hists__decay_entries_threaded(struct hists *hists)
{
return __hists__decay_entries(hists, true);
}

/*
* histogram, sorted on item, collects periods
*/
Expand Down
11 changes: 8 additions & 3 deletions tools/perf/util/hist.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ void hists__collapse_resort(struct hists *self);
void hists__collapse_resort_threaded(struct hists *hists);

void hists__decay_entries(struct hists *hists);
void hists__decay_entries_threaded(struct hists *hists);
void hists__output_recalc_col_len(struct hists *hists, int max_rows);

void hists__inc_nr_events(struct hists *self, u32 type);
Expand All @@ -103,16 +104,20 @@ struct perf_evlist;
#ifdef NO_NEWT_SUPPORT
static inline
int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __used,
const char *help __used, void(*timer)(void *arg) __used, void *arg,
const char *help __used,
void(*timer)(void *arg) __used,
void *arg __used,
int refresh __used)
{
return 0;
}

static inline int hist_entry__tui_annotate(struct hist_entry *self __used,
int evidx __used, int nr_events __used,
int evidx __used,
int nr_events __used,
void(*timer)(void *arg) __used,
void *arg __used, int delay_secs __used);
void *arg __used,
int delay_secs __used)
{
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/sort.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ struct hist_entry {

bool init_have_children;
char level;
bool used;
u8 filtered;
struct symbol *parent;
union {
Expand Down
Loading

0 comments on commit c73a3cb

Please sign in to comment.