Skip to content

Commit

Permalink
Merge branch 'perf' of git://git.kernel.org/pub/scm/linux/kernel/git/…
Browse files Browse the repository at this point in the history
…acme/linux-2.6 into perf/core
  • Loading branch information
Ingo Molnar committed May 21, 2010
2 parents 915e555 + 5d06e69 commit 1c34bde
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 26 deletions.
17 changes: 1 addition & 16 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ static bool multiplex = false;
static int multiplex_fd = -1;

static long samples = 0;
static struct timeval last_read;
static struct timeval this_read;

static u64 bytes_written = 0;

static struct pollfd *event_array;
Expand Down Expand Up @@ -147,8 +144,6 @@ static void mmap_read(struct mmap_data *md)
void *buf;
int diff;

gettimeofday(&this_read, NULL);

/*
* If we're further behind than half the buffer, there's a chance
* the writer will bite our tail and mess up the samples under us.
Expand All @@ -159,23 +154,13 @@ static void mmap_read(struct mmap_data *md)
*/
diff = head - old;
if (diff < 0) {
struct timeval iv;
unsigned long msecs;

timersub(&this_read, &last_read, &iv);
msecs = iv.tv_sec*1000 + iv.tv_usec/1000;

fprintf(stderr, "WARNING: failed to keep up with mmap data."
" Last read %lu msecs ago.\n", msecs);

fprintf(stderr, "WARNING: failed to keep up with mmap data\n");
/*
* head points to a known good entry, start there.
*/
old = head;
}

last_read = this_read;

if (old != head)
samples++;

Expand Down
8 changes: 4 additions & 4 deletions tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static int perf_session__add_hist_entry(struct perf_session *self,
* so we don't allocated the extra space needed because the stdio
* code will not use it.
*/
if (use_browser)
if (use_browser > 0)
err = hist_entry__inc_addr_samples(he, al->addr);
out_free_syms:
free(syms);
Expand Down Expand Up @@ -330,7 +330,7 @@ static int __cmd_report(void)
hists = rb_entry(next, struct hists, rb_node);
hists__collapse_resort(hists);
hists__output_resort(hists);
if (use_browser)
if (use_browser > 0)
hists__browse(hists, help, input_name);
else {
const char *evname = NULL;
Expand All @@ -347,7 +347,7 @@ static int __cmd_report(void)
next = rb_next(&hists->rb_node);
}

if (!use_browser && sort_order == default_sort_order &&
if (use_browser <= 0 && sort_order == default_sort_order &&
parent_pattern == default_parent_pattern) {
fprintf(stdout, "#\n# (%s)\n#\n", help);

Expand Down Expand Up @@ -491,7 +491,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
* so don't allocate extra space that won't be used in the stdio
* implementation.
*/
if (use_browser)
if (use_browser > 0)
symbol_conf.priv_size = sizeof(struct sym_priv);

if (symbol__init() < 0)
Expand Down
25 changes: 23 additions & 2 deletions tools/perf/perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
#include "util/parse-events.h"
#include "util/debugfs.h"

bool use_browser;

const char perf_usage_string[] =
"perf [--version] [--help] COMMAND [ARGS]";

const char perf_more_info_string[] =
"See 'perf help COMMAND' for more information on a specific command.";

int use_browser = -1;
static int use_pager = -1;

struct pager_config {
const char *cmd;
int val;
Expand All @@ -49,6 +49,24 @@ int check_pager_config(const char *cmd)
return c.val;
}

static int tui_command_config(const char *var, const char *value, void *data)
{
struct pager_config *c = data;
if (!prefixcmp(var, "tui.") && !strcmp(var + 4, c->cmd))
c->val = perf_config_bool(var, value);
return 0;
}

/* returns 0 for "no tui", 1 for "use tui", and -1 for "not specified" */
static int check_tui_config(const char *cmd)
{
struct pager_config c;
c.cmd = cmd;
c.val = -1;
perf_config(tui_command_config, &c);
return c.val;
}

static void commit_pager_choice(void)
{
switch (use_pager) {
Expand Down Expand Up @@ -255,6 +273,9 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
if (p->option & RUN_SETUP)
prefix = NULL; /* setup_perf_directory(); */

if (use_browser == -1)
use_browser = check_tui_config(p->cmd);

if (use_pager == -1 && p->option & RUN_SETUP)
use_pager = check_pager_config(p->cmd);
if (use_pager == -1 && p->option & USE_PAGER)
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extern const char *pager_program;
extern int pager_in_use(void);
extern int pager_use_color;

extern bool use_browser;
extern int use_browser;

#ifdef NO_NEWT_SUPPORT
static inline void setup_browser(void)
Expand Down
9 changes: 6 additions & 3 deletions tools/perf/util/newt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1068,10 +1068,13 @@ static struct newtPercentTreeColors {
void setup_browser(void)
{
struct newtPercentTreeColors *c = &defaultPercentTreeColors;
if (!isatty(1))

if (!isatty(1) || !use_browser) {
setup_pager();
return;
}

use_browser = true;
use_browser = 1;
newtInit();
newtCls();
ui_helpline__puts(" ");
Expand All @@ -1084,7 +1087,7 @@ void setup_browser(void)

void exit_browser(bool wait_for_ok)
{
if (use_browser) {
if (use_browser > 0) {
if (wait_for_ok) {
char title[] = "Fatal Error", ok[] = "Ok";
newtWinMessage(title, ok, browser__last_msg);
Expand Down

0 comments on commit 1c34bde

Please sign in to comment.