提交 2f9c0452 编写于 作者: W Wei Li 提交者: Xie XiuQi

perf tools: add perf_evlist__terminate() for terminate

hulk inclusion
category: bugfix
bugzilla: 24005
CVE: NA

-------------------------------------------

In __cmd_record(), when receiving SIGINT(ctrl + c), a done flag will
be set and the event list will be disabled by perf_evlist__disable()
once.

While in auxtrace_record.read_finish(), the related events will be
enabled again, if they are continuous, the recording seems to be endless.

Mark the evlist's state as terminated, preparing for the following fix.
Signed-off-by: NWei Li <liwei391@huawei.com>
Reviewed-by: NXuefeng Wang <wxf.wang@hisilicon.com>
Reviewed-by: NTan Xiaojun <tanxiaojun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 e7569e4a
...@@ -1132,7 +1132,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) ...@@ -1132,7 +1132,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
*/ */
if (done && !disabled && !target__none(&opts->target)) { if (done && !disabled && !target__none(&opts->target)) {
trigger_off(&auxtrace_snapshot_trigger); trigger_off(&auxtrace_snapshot_trigger);
perf_evlist__disable(rec->evlist); perf_evlist__terminate(rec->evlist);
disabled = true; disabled = true;
} }
} }
......
...@@ -357,6 +357,20 @@ static int perf_evlist__nr_threads(struct perf_evlist *evlist, ...@@ -357,6 +357,20 @@ static int perf_evlist__nr_threads(struct perf_evlist *evlist,
return thread_map__nr(evlist->threads); return thread_map__nr(evlist->threads);
} }
void perf_evlist__terminate(struct perf_evlist *evlist)
{
struct perf_evsel *pos;
evlist__for_each_entry(evlist, pos) {
if (!perf_evsel__is_group_leader(pos) || !pos->fd)
continue;
perf_evsel__disable(pos);
pos->terminated = true;
}
evlist->enabled = false;
}
void perf_evlist__disable(struct perf_evlist *evlist) void perf_evlist__disable(struct perf_evlist *evlist)
{ {
struct perf_evsel *pos; struct perf_evsel *pos;
......
...@@ -168,6 +168,7 @@ void perf_evlist__munmap(struct perf_evlist *evlist); ...@@ -168,6 +168,7 @@ void perf_evlist__munmap(struct perf_evlist *evlist);
size_t perf_evlist__mmap_size(unsigned long pages); size_t perf_evlist__mmap_size(unsigned long pages);
void perf_evlist__terminate(struct perf_evlist *evlist);
void perf_evlist__disable(struct perf_evlist *evlist); void perf_evlist__disable(struct perf_evlist *evlist);
void perf_evlist__enable(struct perf_evlist *evlist); void perf_evlist__enable(struct perf_evlist *evlist);
void perf_evlist__toggle_enable(struct perf_evlist *evlist); void perf_evlist__toggle_enable(struct perf_evlist *evlist);
......
...@@ -146,6 +146,7 @@ struct perf_evsel { ...@@ -146,6 +146,7 @@ struct perf_evsel {
bool collect_stat; bool collect_stat;
bool weak_group; bool weak_group;
const char *pmu_name; const char *pmu_name;
bool terminated;
}; };
union u64_swap { union u64_swap {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册