mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-04 04:06:26 +00:00
perf sched: Move thread::shortname to thread_runtime
The thread::shortname only used by sched command, so move it to sched private structure. Signed-off-by: Changbin Du <changbin.du@intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1520307457-23668-2-git-send-email-changbin.du@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
923a0fb332
commit
8640da9f4f
@ -254,6 +254,8 @@ struct thread_runtime {
|
|||||||
u64 total_delay_time;
|
u64 total_delay_time;
|
||||||
|
|
||||||
int last_state;
|
int last_state;
|
||||||
|
|
||||||
|
char shortname[3];
|
||||||
u64 migrations;
|
u64 migrations;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -897,6 +899,37 @@ struct sort_dimension {
|
|||||||
struct list_head list;
|
struct list_head list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* handle runtime stats saved per thread
|
||||||
|
*/
|
||||||
|
static struct thread_runtime *thread__init_runtime(struct thread *thread)
|
||||||
|
{
|
||||||
|
struct thread_runtime *r;
|
||||||
|
|
||||||
|
r = zalloc(sizeof(struct thread_runtime));
|
||||||
|
if (!r)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
init_stats(&r->run_stats);
|
||||||
|
thread__set_priv(thread, r);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct thread_runtime *thread__get_runtime(struct thread *thread)
|
||||||
|
{
|
||||||
|
struct thread_runtime *tr;
|
||||||
|
|
||||||
|
tr = thread__priv(thread);
|
||||||
|
if (tr == NULL) {
|
||||||
|
tr = thread__init_runtime(thread);
|
||||||
|
if (tr == NULL)
|
||||||
|
pr_debug("Failed to malloc memory for runtime data.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return tr;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
thread_lat_cmp(struct list_head *list, struct work_atoms *l, struct work_atoms *r)
|
thread_lat_cmp(struct list_head *list, struct work_atoms *l, struct work_atoms *r)
|
||||||
{
|
{
|
||||||
@ -1480,6 +1513,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,
|
|||||||
{
|
{
|
||||||
const u32 next_pid = perf_evsel__intval(evsel, sample, "next_pid");
|
const u32 next_pid = perf_evsel__intval(evsel, sample, "next_pid");
|
||||||
struct thread *sched_in;
|
struct thread *sched_in;
|
||||||
|
struct thread_runtime *tr;
|
||||||
int new_shortname;
|
int new_shortname;
|
||||||
u64 timestamp0, timestamp = sample->time;
|
u64 timestamp0, timestamp = sample->time;
|
||||||
s64 delta;
|
s64 delta;
|
||||||
@ -1519,22 +1553,28 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,
|
|||||||
if (sched_in == NULL)
|
if (sched_in == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
tr = thread__get_runtime(sched_in);
|
||||||
|
if (tr == NULL) {
|
||||||
|
thread__put(sched_in);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
sched->curr_thread[this_cpu] = thread__get(sched_in);
|
sched->curr_thread[this_cpu] = thread__get(sched_in);
|
||||||
|
|
||||||
printf(" ");
|
printf(" ");
|
||||||
|
|
||||||
new_shortname = 0;
|
new_shortname = 0;
|
||||||
if (!sched_in->shortname[0]) {
|
if (!tr->shortname[0]) {
|
||||||
if (!strcmp(thread__comm_str(sched_in), "swapper")) {
|
if (!strcmp(thread__comm_str(sched_in), "swapper")) {
|
||||||
/*
|
/*
|
||||||
* Don't allocate a letter-number for swapper:0
|
* Don't allocate a letter-number for swapper:0
|
||||||
* as a shortname. Instead, we use '.' for it.
|
* as a shortname. Instead, we use '.' for it.
|
||||||
*/
|
*/
|
||||||
sched_in->shortname[0] = '.';
|
tr->shortname[0] = '.';
|
||||||
sched_in->shortname[1] = ' ';
|
tr->shortname[1] = ' ';
|
||||||
} else {
|
} else {
|
||||||
sched_in->shortname[0] = sched->next_shortname1;
|
tr->shortname[0] = sched->next_shortname1;
|
||||||
sched_in->shortname[1] = sched->next_shortname2;
|
tr->shortname[1] = sched->next_shortname2;
|
||||||
|
|
||||||
if (sched->next_shortname1 < 'Z') {
|
if (sched->next_shortname1 < 'Z') {
|
||||||
sched->next_shortname1++;
|
sched->next_shortname1++;
|
||||||
@ -1552,6 +1592,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,
|
|||||||
for (i = 0; i < cpus_nr; i++) {
|
for (i = 0; i < cpus_nr; i++) {
|
||||||
int cpu = sched->map.comp ? sched->map.comp_cpus[i] : i;
|
int cpu = sched->map.comp ? sched->map.comp_cpus[i] : i;
|
||||||
struct thread *curr_thread = sched->curr_thread[cpu];
|
struct thread *curr_thread = sched->curr_thread[cpu];
|
||||||
|
struct thread_runtime *curr_tr;
|
||||||
const char *pid_color = color;
|
const char *pid_color = color;
|
||||||
const char *cpu_color = color;
|
const char *cpu_color = color;
|
||||||
|
|
||||||
@ -1569,9 +1610,14 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,
|
|||||||
else
|
else
|
||||||
color_fprintf(stdout, cpu_color, "*");
|
color_fprintf(stdout, cpu_color, "*");
|
||||||
|
|
||||||
if (sched->curr_thread[cpu])
|
if (sched->curr_thread[cpu]) {
|
||||||
color_fprintf(stdout, pid_color, "%2s ", sched->curr_thread[cpu]->shortname);
|
curr_tr = thread__get_runtime(sched->curr_thread[cpu]);
|
||||||
else
|
if (curr_tr == NULL) {
|
||||||
|
thread__put(sched_in);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
color_fprintf(stdout, pid_color, "%2s ", curr_tr->shortname);
|
||||||
|
} else
|
||||||
color_fprintf(stdout, color, " ");
|
color_fprintf(stdout, color, " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1587,7 +1633,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,
|
|||||||
pid_color = COLOR_PIDS;
|
pid_color = COLOR_PIDS;
|
||||||
|
|
||||||
color_fprintf(stdout, pid_color, "%s => %s:%d",
|
color_fprintf(stdout, pid_color, "%s => %s:%d",
|
||||||
sched_in->shortname, thread__comm_str(sched_in), sched_in->tid);
|
tr->shortname, thread__comm_str(sched_in), sched_in->tid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sched->map.comp && new_cpu)
|
if (sched->map.comp && new_cpu)
|
||||||
@ -2200,37 +2246,6 @@ static void save_idle_callchain(struct idle_thread_runtime *itr,
|
|||||||
callchain_cursor__copy(&itr->cursor, &callchain_cursor);
|
callchain_cursor__copy(&itr->cursor, &callchain_cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* handle runtime stats saved per thread
|
|
||||||
*/
|
|
||||||
static struct thread_runtime *thread__init_runtime(struct thread *thread)
|
|
||||||
{
|
|
||||||
struct thread_runtime *r;
|
|
||||||
|
|
||||||
r = zalloc(sizeof(struct thread_runtime));
|
|
||||||
if (!r)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
init_stats(&r->run_stats);
|
|
||||||
thread__set_priv(thread, r);
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct thread_runtime *thread__get_runtime(struct thread *thread)
|
|
||||||
{
|
|
||||||
struct thread_runtime *tr;
|
|
||||||
|
|
||||||
tr = thread__priv(thread);
|
|
||||||
if (tr == NULL) {
|
|
||||||
tr = thread__init_runtime(thread);
|
|
||||||
if (tr == NULL)
|
|
||||||
pr_debug("Failed to malloc memory for runtime data.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
return tr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct thread *timehist_get_thread(struct perf_sched *sched,
|
static struct thread *timehist_get_thread(struct perf_sched *sched,
|
||||||
struct perf_sample *sample,
|
struct perf_sample *sample,
|
||||||
struct machine *machine,
|
struct machine *machine,
|
||||||
|
@ -26,7 +26,6 @@ struct thread {
|
|||||||
pid_t ppid;
|
pid_t ppid;
|
||||||
int cpu;
|
int cpu;
|
||||||
refcount_t refcnt;
|
refcount_t refcnt;
|
||||||
char shortname[3];
|
|
||||||
bool comm_set;
|
bool comm_set;
|
||||||
int comm_len;
|
int comm_len;
|
||||||
bool dead; /* if set thread has exited */
|
bool dead; /* if set thread has exited */
|
||||||
|
Loading…
Reference in New Issue
Block a user