perf tools: Assorted fixes and cleanups for namespace events
Namhyung Kim
maintainercover perf tools: Assorted fixes and cleanups for namespace events
Hello,
These are some missing pieces that I found during the code-reading.
Thanks,
Namhyung
Namhyung Kim (3):
perf tools: Protect reading thread's namespace perf tools: Add missing swap ops for namespace events perf top: Enable --namespaces option
tools/perf/Documentation/perf-top.txt | 5 +++++ tools/perf/builtin-top.c | 5 +++++ tools/perf/util/session.c | 21 +++++++++++++++++++++ tools/perf/util/thread.c | 15 +++++++++++++-- 4 files changed, 44 insertions(+), 2 deletions(-)
Signature · 1 line
2.21.0.1020.gf2820cf01a-goog
Namhyung Kim
maintainerPATCH 1/3 perf tools: Protect reading thread's namespace
It seems that the current code lacks holding the namespace lock in thread__namespaces(). Otherwise it can see inconsistent results.
--- tools/perf/util/thread.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
tools/perf/util/thread.c +13 -2
@@ -133,7 +133,7 @@ void thread__put(struct thread *thread) } } -struct namespaces *thread__namespaces (const struct thread *thread) +static struct namespaces *__thread__namespaces (const struct thread *thread) {if (list_empty (&thread->namespaces_list))return NULL ;
@@ -141,10 +141,21 @@ struct namespaces *thread__namespaces(const struct thread *thread) return list_first_entry(&thread->namespaces_list, struct namespaces, list); } +struct namespaces *thread__namespaces (const struct thread *thread) +{ +struct namespaces *ns; + +down_read ((struct rw_semaphore *)&thread->namespaces_lock); + ns =__thread__namespaces (thread); +up_read ((struct rw_semaphore *)&thread->namespaces_lock); + +return ns; +} +static int __thread__set_namespaces (struct thread *thread,u64 timestamp,struct namespaces_event *event) { -struct namespaces *new, *curr =thread__namespaces (thread); +struct namespaces *new, *curr =__thread__namespaces (thread); new =namespaces__new (event);if (!new)
Signature · 1 line
2.21.0.1020.gf2820cf01a-goog
Re: [PATCH 1/3] perf tools: Protect reading thread's namespace
Em Wed, May 22, 2019 at 02:32:48PM +0900, Namhyung Kim escreveu:
Quoted 23 lines
It seems that the current code lacks holding the namespace lock in
thread__namespaces(). Otherwise it can see inconsistent results.Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/util/thread.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)tools/perf/util/thread.c +1
-1@@ -133,7 +133,7 @@ void thread__put(struct thread *thread) } } -struct namespaces *thread__namespaces (const struct thread *thread) +static struct namespaces *__thread__namespaces (const struct thread *thread) {if (list_empty (&thread->namespaces_list))return NULL ;@@ -141,10 +141,21 @@ struct namespaces *thread__namespaces(const struct thread *thread) return list_first_entry(&thread->namespaces_list, struct namespaces, list);
tools/perf/util/thread.c struct namespaces *thread__namespaces(const struct thread *thread) · line 151
Quoted 10 lines
tools/perf/util/thread.c +8
-0} +struct namespaces *thread__namespaces (const struct thread *thread) +{ +struct namespaces *ns; + +down_read ((struct rw_semaphore *)&thread->namespaces_lock); + ns =__thread__namespaces (thread); +up_read ((struct rw_semaphore *)&thread->namespaces_lock); +
Humm, so we need to change thread__namespaces() to remove that const instead of throwing it away with that cast, right?
- Arnaldo
Quoted 13 lines
tools/perf/util/thread.c +4
-1+return ns; +} +static int __thread__set_namespaces (struct thread *thread,u64 timestamp,struct namespaces_event *event) { -struct namespaces *new, *curr =thread__namespaces (thread); +struct namespaces *new, *curr =__thread__namespaces (thread); new =namespaces__new (event);if (!new)Signature · 1 line
2.21.0.1020.gf2820cf01a-goog
Signature · 1 line
- Arnaldo
Namhyung Kim
maintainerRe: [PATCH 1/3] perf tools: Protect reading thread's namespace
Hi Arnaldo,
Quoted 26 lines · Arnaldo Carvalho de Melo
Em Wed, May 22, 2019 at 02:32:48PM +0900, Namhyung Kim escreveu:
Quoted 25 lines
It seems that the current code lacks holding the namespace lock in
thread__namespaces(). Otherwise it can see inconsistent results.Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/util/thread.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)tools/perf/util/thread.c +1
-1@@ -133,7 +133,7 @@ void thread__put(struct thread *thread) } } -struct namespaces *thread__namespaces (const struct thread *thread) +static struct namespaces *__thread__namespaces (const struct thread *thread) {if (list_empty (&thread->namespaces_list))return NULL ;@@ -141,10 +141,21 @@ struct namespaces *thread__namespaces(const struct thread *thread) return list_first_entry(&thread->namespaces_list, struct namespaces, list); }
Quoted 11 lines
tools/perf/util/thread.c struct namespaces *thread__namespaces(const struct thread *thread) · line 151
Quoted 8 lines
tools/perf/util/thread.c +8
-0+struct namespaces *thread__namespaces (const struct thread *thread) +{ +struct namespaces *ns; + +down_read ((struct rw_semaphore *)&thread->namespaces_lock); + ns =__thread__namespaces (thread); +up_read ((struct rw_semaphore *)&thread->namespaces_lock); +Humm, so we need to change
thread__namespaces()to remove that const instead of throwing it away with that cast, right?
Yes, that's possible too. Note that thread__comm_str() has the same issue as well.
Thanks,
Namhyung
Namhyung Kim
maintainer[PATCH 4/3] perf tools: Remove const from thread read accessors
The namespaces and comm fields of a thread are protected by rwsem and require write access for it. So it ended up using a cast to remove the const qualifier. Let's get rid of the const then.
--- tools/perf/util/hist.c | 2 +- tools/perf/util/thread.c | 12 ++++++------ tools/perf/util/thread.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-)
tools/perf/util/hist.c +1 -1
@@ -2561,7 +2561,7 @@ int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, bool shchar unit;int printed;const struct dso *dso = hists->dso_filter; -const struct thread *thread = hists->thread_filter; +struct thread *thread = hists->thread_filter;int socket_id = hists->socket_filter;unsigned long nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE ];u64 nr_events = hists->stats.total_period;
tools/perf/util/thread.c +6 -6
@@ -141,13 +141,13 @@ static struct namespaces *__thread__namespaces(const struct thread *thread) return list_first_entry(&thread->namespaces_list, struct namespaces, list); } -struct namespaces *thread__namespaces (const struct thread *thread) +struct namespaces *thread__namespaces (struct thread *thread) {struct namespaces *ns; -down_read ((struct rw_semaphore *)&thread->namespaces_lock); +down_read (&thread->namespaces_lock); ns =__thread__namespaces (thread); -up_read ((struct rw_semaphore *)&thread->namespaces_lock); +up_read (&thread->namespaces_lock);return ns; }
@@ -271,13 +271,13 @@ static const char *__thread__comm_str(const struct thread *thread)return comm__str (comm); } -const char *thread__comm_str (const struct thread *thread) +const char *thread__comm_str (struct thread *thread) {const char *str; -down_read ((struct rw_semaphore *)&thread->comm_lock); +down_read (&thread->comm_lock); str =__thread__comm_str (thread); -up_read ((struct rw_semaphore *)&thread->comm_lock); +up_read (&thread->comm_lock);return str; }
tools/perf/util/thread.h +2 -2
@@ -76,7 +76,7 @@ static inline void thread__exited(struct thread *thread) thread->dead = true; } -struct namespaces *thread__namespaces (const struct thread *thread); +struct namespaces *thread__namespaces (struct thread *thread);int thread__set_namespaces (struct thread *thread,u64 timestamp,struct namespaces_event *event);
@@ -93,7 +93,7 @@ int thread__set_comm_from_proc(struct thread *thread);int thread__comm_len (struct thread *thread);struct comm *thread__comm (const struct thread *thread);struct comm *thread__exec_comm (const struct thread *thread); -const char *thread__comm_str (const struct thread *thread); +const char *thread__comm_str (struct thread *thread);int thread__insert_map (struct thread *thread,struct map *map);int thread__fork (struct thread *thread,struct thread *parent,u64 timestamp,bool do_maps_clone);size_t thread__fprintf (struct thread *thread,FILE *fp);
Signature · 1 line
2.22.0.rc1.257.g3120a18244-goog
Arnaldo Carvalho de Melo
AppliedRe: [PATCH 4/3] perf tools: Remove const from thread read accessors
Em Mon, May 27, 2019 at 03:11:49PM +0900, Namhyung Kim escreveu:
Quoted 3 lines
The namespaces and comm fields of a thread are protected by rwsem and require write access for it. So it ended up using a cast to remove the const qualifier. Let's get rid of the const then.
Thanks, applied 1/3 and 4/3.
- Arnaldo
Quoted 82 lines
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/util/hist.c | 2 +- tools/perf/util/thread.c | 12 ++++++------ tools/perf/util/thread.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-)tools/perf/util/hist.c +1
-1@@ -2561,7 +2561,7 @@ int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, bool shchar unit;int printed;const struct dso *dso = hists->dso_filter; -const struct thread *thread = hists->thread_filter; +struct thread *thread = hists->thread_filter;int socket_id = hists->socket_filter;unsigned long nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE ];u64 nr_events = hists->stats.total_period;tools/perf/util/thread.c +6
-6@@ -141,13 +141,13 @@ static struct namespaces *__thread__namespaces(const struct thread *thread) return list_first_entry(&thread->namespaces_list, struct namespaces, list); } -struct namespaces *thread__namespaces (const struct thread *thread) +struct namespaces *thread__namespaces (struct thread *thread) {struct namespaces *ns; -down_read ((struct rw_semaphore *)&thread->namespaces_lock); +down_read (&thread->namespaces_lock); ns =__thread__namespaces (thread); -up_read ((struct rw_semaphore *)&thread->namespaces_lock); +up_read (&thread->namespaces_lock);return ns; }@@ -271,13 +271,13 @@ static const char *__thread__comm_str(const struct thread *thread)return comm__str (comm); } -const char *thread__comm_str (const struct thread *thread) +const char *thread__comm_str (struct thread *thread) {const char *str; -down_read ((struct rw_semaphore *)&thread->comm_lock); +down_read (&thread->comm_lock); str =__thread__comm_str (thread); -up_read ((struct rw_semaphore *)&thread->comm_lock); +up_read (&thread->comm_lock);return str; }tools/perf/util/thread.h +2
-2@@ -76,7 +76,7 @@ static inline void thread__exited(struct thread *thread) thread->dead = true; } -struct namespaces *thread__namespaces (const struct thread *thread); +struct namespaces *thread__namespaces (struct thread *thread);int thread__set_namespaces (struct thread *thread,u64 timestamp,struct namespaces_event *event);@@ -93,7 +93,7 @@ int thread__set_comm_from_proc(struct thread *thread);int thread__comm_len (struct thread *thread);struct comm *thread__comm (const struct thread *thread);struct comm *thread__exec_comm (const struct thread *thread); -const char *thread__comm_str (const struct thread *thread); +const char *thread__comm_str (struct thread *thread);int thread__insert_map (struct thread *thread,struct map *map);int thread__fork (struct thread *thread,struct thread *parent,u64 timestamp,bool do_maps_clone);size_t thread__fprintf (struct thread *thread,FILE *fp);Signature · 1 line
2.22.0.rc1.257.g3120a18244-goog
Signature · 1 line
- Arnaldo
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf tools: Remove const from thread read accessors
In reply to Namhyung Kimperf tools: Remove const from thread read accessors
Commit-ID: 7cb10a08df98e643b87d4bc8422e50e9c43b5c60 Gitweb: https://git.kernel.org/tip/7cb10a08df98e643b87d4bc8422e50e9c43b5c60 Author: Namhyung Kim <[email protected]> AuthorDate: Mon, 27 May 2019 15:11:49 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 28 May 2019 18:37:43 -0300
perf tools: Remove const from thread read accessors
The namespaces and comm fields of a thread are protected by rwsem and require write access for it. So it ended up using a cast to remove the const qualifier. Let's get rid of the const then.
--- tools/perf/util/hist.c | 2 +- tools/perf/util/thread.c | 12 ++++++------ tools/perf/util/thread.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-)
tools/perf/util/hist.c +1 -1
@@ -2561,7 +2561,7 @@ int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, bool shchar unit;int printed;const struct dso *dso = hists->dso_filter; -const struct thread *thread = hists->thread_filter; +struct thread *thread = hists->thread_filter;int socket_id = hists->socket_filter;unsigned long nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE ];u64 nr_events = hists->stats.total_period;
tools/perf/util/thread.c +6 -6
@@ -141,13 +141,13 @@ static struct namespaces *__thread__namespaces(const struct thread *thread) return list_first_entry(&thread->namespaces_list, struct namespaces, list); } -struct namespaces *thread__namespaces (const struct thread *thread) +struct namespaces *thread__namespaces (struct thread *thread) {struct namespaces *ns; -down_read ((struct rw_semaphore *)&thread->namespaces_lock); +down_read (&thread->namespaces_lock); ns =__thread__namespaces (thread); -up_read ((struct rw_semaphore *)&thread->namespaces_lock); +up_read (&thread->namespaces_lock);return ns; }
@@ -271,13 +271,13 @@ static const char *__thread__comm_str(const struct thread *thread)return comm__str (comm); } -const char *thread__comm_str (const struct thread *thread) +const char *thread__comm_str (struct thread *thread) {const char *str; -down_read ((struct rw_semaphore *)&thread->comm_lock); +down_read (&thread->comm_lock); str =__thread__comm_str (thread); -up_read ((struct rw_semaphore *)&thread->comm_lock); +up_read (&thread->comm_lock);return str; }
tools/perf/util/thread.h +2 -2
@@ -76,7 +76,7 @@ static inline void thread__exited(struct thread *thread) thread->dead = true; } -struct namespaces *thread__namespaces (const struct thread *thread); +struct namespaces *thread__namespaces (struct thread *thread);int thread__set_namespaces (struct thread *thread,u64 timestamp,struct namespaces_event *event);
@@ -93,7 +93,7 @@ int thread__set_comm_from_proc(struct thread *thread);int thread__comm_len (struct thread *thread);struct comm *thread__comm (const struct thread *thread);struct comm *thread__exec_comm (const struct thread *thread); -const char *thread__comm_str (const struct thread *thread); +const char *thread__comm_str (struct thread *thread);int thread__insert_map (struct thread *thread,struct map *map);int thread__fork (struct thread *thread,struct thread *parent,u64 timestamp,bool do_maps_clone);size_t thread__fprintf (struct thread *thread,FILE *fp);
tip-bot for Namhyung Kim
merge bot[tip:perf/urgent] perf namespace: Protect reading thread's namespace
In reply to Namhyung Kimperf namespace: Protect reading thread's namespace
Commit-ID: 6584140ba9e6762dd7ec73795243289b914f31f9 Gitweb: https://git.kernel.org/tip/6584140ba9e6762dd7ec73795243289b914f31f9 Author: Namhyung Kim <[email protected]> AuthorDate: Wed, 22 May 2019 14:32:48 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 28 May 2019 09:52:23 -0300
perf namespace: Protect reading thread's namespace
It seems that the current code lacks holding the namespace lock in thread__namespaces(). Otherwise it can see inconsistent results.
--- tools/perf/util/thread.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
tools/perf/util/thread.c +13 -2
@@ -133,7 +133,7 @@ void thread__put(struct thread *thread) } } -struct namespaces *thread__namespaces (const struct thread *thread) +static struct namespaces *__thread__namespaces (const struct thread *thread) {if (list_empty (&thread->namespaces_list))return NULL ;
@@ -141,10 +141,21 @@ struct namespaces *thread__namespaces(const struct thread *thread) return list_first_entry(&thread->namespaces_list, struct namespaces, list); } +struct namespaces *thread__namespaces (const struct thread *thread) +{ +struct namespaces *ns; + +down_read ((struct rw_semaphore *)&thread->namespaces_lock); + ns =__thread__namespaces (thread); +up_read ((struct rw_semaphore *)&thread->namespaces_lock); + +return ns; +} +static int __thread__set_namespaces (struct thread *thread,u64 timestamp,struct namespaces_event *event) { -struct namespaces *new, *curr =thread__namespaces (thread); +struct namespaces *new, *curr =__thread__namespaces (thread); new =namespaces__new (event);if (!new)
Namhyung Kim
maintainerPATCH 2/3 perf tools: Add missing swap ops for namespace events
In reply to Namhyung KimIn case it's recorded from other arch.
--- tools/perf/util/session.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
tools/perf/util/session.c +21 -0
@@ -647,6 +647,26 @@ static void perf_event__throttle_swap(union perf_event *event,swap_sample_id_all (event, &event->throttle +1 ); } +static void perf_event__namespaces_swap (union perf_event *event, +bool sample_id_all) +{ +u64 i; + + event->namespaces.pid =bswap_32 (event->namespaces.pid); + event->namespaces.tid =bswap_32 (event->namespaces.tid); + event->namespaces.nr_namespaces =bswap_64 (event->namespaces.nr_namespaces); + +for (i =0 ; i < event->namespaces.nr_namespaces; i++) { +struct perf_ns_link_info *ns = &event->namespaces.link_info[i]; + + ns->dev =bswap_64 (ns->dev); + ns->ino =bswap_64 (ns->ino); + } + +if (sample_id_all) +swap_sample_id_all (event, &event->namespaces.link_info[i]); +} +static u8 revbyte (u8 b) {int rev = (b >>4 ) | ((b &0xf ) <<4 );
@@ -887,6 +907,7 @@ static perf_event__swap_op perf_event__swap_ops[] = { [PERF_RECORD_LOST_SAMPLES] = perf_event__all64_swap, [PERF_RECORD_SWITCH] = perf_event__switch_swap, [PERF_RECORD_SWITCH_CPU_WIDE] = perf_event__switch_swap, + [PERF_RECORD_NAMESPACES] = perf_event__namespaces_swap, [PERF_RECORD_HEADER_ATTR] = perf_event__hdr_attr_swap, [PERF_RECORD_HEADER_EVENT_TYPE] = perf_event__event_type_swap, [PERF_RECORD_HEADER_TRACING_DATA] = perf_event__tracing_data_swap,
Signature · 1 line
2.21.0.1020.gf2820cf01a-goog
Re: [PATCH 2/3] perf tools: Add missing swap ops for namespace events
Em Wed, May 22, 2019 at 02:32:49PM +0900, Namhyung Kim escreveu:
Quoted 1 line
In case it's recorded from other arch.
Applied and added:
So that the stable guys can pick it.
- Arnaldo
Quoted 46 lines
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/util/session.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)tools/perf/util/session.c +21
-0@@ -647,6 +647,26 @@ static void perf_event__throttle_swap(union perf_event *event,swap_sample_id_all (event, &event->throttle +1 ); } +static void perf_event__namespaces_swap (union perf_event *event, +bool sample_id_all) +{ +u64 i; + + event->namespaces.pid =bswap_32 (event->namespaces.pid); + event->namespaces.tid =bswap_32 (event->namespaces.tid); + event->namespaces.nr_namespaces =bswap_64 (event->namespaces.nr_namespaces); + +for (i =0 ; i < event->namespaces.nr_namespaces; i++) { +struct perf_ns_link_info *ns = &event->namespaces.link_info[i]; + + ns->dev =bswap_64 (ns->dev); + ns->ino =bswap_64 (ns->ino); + } + +if (sample_id_all) +swap_sample_id_all (event, &event->namespaces.link_info[i]); +} +static u8 revbyte (u8 b) {int rev = (b >>4 ) | ((b &0xf ) <<4 );@@ -887,6 +907,7 @@ static perf_event__swap_op perf_event__swap_ops[] = { [PERF_RECORD_LOST_SAMPLES] = perf_event__all64_swap, [PERF_RECORD_SWITCH] = perf_event__switch_swap, [PERF_RECORD_SWITCH_CPU_WIDE] = perf_event__switch_swap, + [PERF_RECORD_NAMESPACES] = perf_event__namespaces_swap, [PERF_RECORD_HEADER_ATTR] = perf_event__hdr_attr_swap, [PERF_RECORD_HEADER_EVENT_TYPE] = perf_event__event_type_swap, [PERF_RECORD_HEADER_TRACING_DATA] = perf_event__tracing_data_swap,Signature · 1 line
2.21.0.1020.gf2820cf01a-goog
Signature · 1 line
- Arnaldo
tip-bot for Namhyung Kim
merge bot[tip:perf/urgent] perf session: Add missing swap ops for namespace events
In reply to Namhyung Kimperf session: Add missing swap ops for namespace events
Commit-ID: acd244b84b80d53fa2cee98659b55d3f09b4f5a7 Gitweb: https://git.kernel.org/tip/acd244b84b80d53fa2cee98659b55d3f09b4f5a7 Author: Namhyung Kim <[email protected]> AuthorDate: Wed, 22 May 2019 14:32:49 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 28 May 2019 09:52:23 -0300
perf session: Add missing swap ops for namespace events
In case it's recorded in a different arch.
--- tools/perf/util/session.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
tools/perf/util/session.c +21 -0
@@ -647,6 +647,26 @@ static void perf_event__throttle_swap(union perf_event *event,swap_sample_id_all (event, &event->throttle +1 ); } +static void perf_event__namespaces_swap (union perf_event *event, +bool sample_id_all) +{ +u64 i; + + event->namespaces.pid =bswap_32 (event->namespaces.pid); + event->namespaces.tid =bswap_32 (event->namespaces.tid); + event->namespaces.nr_namespaces =bswap_64 (event->namespaces.nr_namespaces); + +for (i =0 ; i < event->namespaces.nr_namespaces; i++) { +struct perf_ns_link_info *ns = &event->namespaces.link_info[i]; + + ns->dev =bswap_64 (ns->dev); + ns->ino =bswap_64 (ns->ino); + } + +if (sample_id_all) +swap_sample_id_all (event, &event->namespaces.link_info[i]); +} +static u8 revbyte (u8 b) {int rev = (b >>4 ) | ((b &0xf ) <<4 );
@@ -887,6 +907,7 @@ static perf_event__swap_op perf_event__swap_ops[] = { [PERF_RECORD_LOST_SAMPLES] = perf_event__all64_swap, [PERF_RECORD_SWITCH] = perf_event__switch_swap, [PERF_RECORD_SWITCH_CPU_WIDE] = perf_event__switch_swap, + [PERF_RECORD_NAMESPACES] = perf_event__namespaces_swap, [PERF_RECORD_HEADER_ATTR] = perf_event__hdr_attr_swap, [PERF_RECORD_HEADER_EVENT_TYPE] = perf_event__event_type_swap, [PERF_RECORD_HEADER_TRACING_DATA] = perf_event__tracing_data_swap,
Namhyung Kim
maintainerPATCH 3/3 perf top: Enable --namespaces option
In reply to Namhyung KimSince perf record already have the option, let's have it for perf top as well.
--- tools/perf/Documentation/perf-top.txt | 5 +++++ tools/perf/builtin-top.c | 5 +++++ 2 files changed, 10 insertions(+)
tools/perf/Documentation/perf-top.txt +5 -0
@@ -262,6 +262,11 @@ Default is to monitor all CPUS. The number of threads to run when synthesizing events for existing processes. By default, the number of threads equals to the number of online CPUs. +--namespaces:: + Record events of type PERF_RECORD_NAMESPACES and display it with the + 'cgroup_id' sort key. + + INTERACTIVE PROMPTING KEYS --------------------------
tools/perf/builtin-top.c +5 -0
@@ -1208,6 +1208,9 @@ static int __cmd_top(struct perf_top *top)init_process_thread (top); +if (opts->record_namespaces) + top->tool.namespace_events = true; + ret =perf_event__synthesize_bpf_events (top->session, perf_event__process, &top->session->machines.host, &top->record_opts);
@@ -1500,6 +1503,8 @@ int cmd_top(int argc, const char **argv)OPT_BOOLEAN (0 ,"force" , &symbol_conf.force,"don't complain, do it" ),OPT_UINTEGER (0 ,"num-thread-synthesize" , &top.nr_threads_synthesize,"number of thread to run event synthesize" ), +OPT_BOOLEAN (0 ,"namespaces" , &opts->record_namespaces, +"Record namespaces events" ), OPT_END() };struct perf_evlist *sb_evlist =NULL ;
Signature · 1 line
2.21.0.1020.gf2820cf01a-goog
Re: [PATCH 3/3] perf top: Enable --namespaces option
Em Wed, May 22, 2019 at 02:32:50PM +0900, Namhyung Kim escreveu:
Quoted 2 lines
Since perf record already have the option, let's have it for perf top as well.
I'm applying, but I wonder if this shouldn't be the default...
- Arnaldo
Quoted 47 lines
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/Documentation/perf-top.txt | 5 +++++ tools/perf/builtin-top.c | 5 +++++ 2 files changed, 10 insertions(+)tools/perf/Documentation/perf-top.txt +5
-0@@ -262,6 +262,11 @@ Default is to monitor all CPUS. The number of threads to run when synthesizing events for existing processes. By default, the number of threads equals to the number of online CPUs. +--namespaces:: + Record events of type PERF_RECORD_NAMESPACES and display it with the + 'cgroup_id' sort key. + + INTERACTIVE PROMPTING KEYS --------------------------tools/perf/builtin-top.c +5
-0@@ -1208,6 +1208,9 @@ static int __cmd_top(struct perf_top *top)init_process_thread (top); +if (opts->record_namespaces) + top->tool.namespace_events = true; + ret =perf_event__synthesize_bpf_events (top->session, perf_event__process, &top->session->machines.host, &top->record_opts);@@ -1500,6 +1503,8 @@ int cmd_top(int argc, const char **argv)OPT_BOOLEAN (0 ,"force" , &symbol_conf.force,"don't complain, do it" ),OPT_UINTEGER (0 ,"num-thread-synthesize" , &top.nr_threads_synthesize,"number of thread to run event synthesize" ), +OPT_BOOLEAN (0 ,"namespaces" , &opts->record_namespaces, +"Record namespaces events" ), OPT_END() };struct perf_evlist *sb_evlist =NULL ;Signature · 1 line
2.21.0.1020.gf2820cf01a-goog
Signature · 1 line
- Arnaldo
Namhyung Kim
maintainerRe: [PATCH 3/3] perf top: Enable --namespaces option
Quoted 5 lines · Arnaldo Carvalho de Melo
Em Wed, May 22, 2019 at 02:32:50PM +0900, Namhyung Kim escreveu:
Quoted 2 lines
Since perf record already have the option, let's have it for perf top as well.
I'm applying, but I wonder if this shouldn't be the default...
Not sure, it'll only add a bit of overhead to task and/or namespace creation.
Thanks,
Namhyung
Quoted 54 lines
- Arnaldo
Quoted 47 lines
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/Documentation/perf-top.txt | 5 +++++ tools/perf/builtin-top.c | 5 +++++ 2 files changed, 10 insertions(+)tools/perf/Documentation/perf-top.txt +5
-0@@ -262,6 +262,11 @@ Default is to monitor all CPUS. The number of threads to run when synthesizing events for existing processes. By default, the number of threads equals to the number of online CPUs. +--namespaces:: + Record events of type PERF_RECORD_NAMESPACES and display it with the + 'cgroup_id' sort key. + + INTERACTIVE PROMPTING KEYS --------------------------tools/perf/builtin-top.c +5
-0@@ -1208,6 +1208,9 @@ static int __cmd_top(struct perf_top *top)init_process_thread (top); +if (opts->record_namespaces) + top->tool.namespace_events = true; + ret =perf_event__synthesize_bpf_events (top->session, perf_event__process, &top->session->machines.host, &top->record_opts);@@ -1500,6 +1503,8 @@ int cmd_top(int argc, const char **argv)OPT_BOOLEAN (0 ,"force" , &symbol_conf.force,"don't complain, do it" ),OPT_UINTEGER (0 ,"num-thread-synthesize" , &top.nr_threads_synthesize,"number of thread to run event synthesize" ), +OPT_BOOLEAN (0 ,"namespaces" , &opts->record_namespaces, +"Record namespaces events" ), OPT_END() };struct perf_evlist *sb_evlist =NULL ;Signature · 1 line
2.21.0.1020.gf2820cf01a-googSignature · 1 line
- Arnaldo
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf top: Add --namespaces option
In reply to Namhyung Kimperf top: Add --namespaces option
Commit-ID: a0c0a4ac021b017e385d0328541ccfebeef165fc Gitweb: https://git.kernel.org/tip/a0c0a4ac021b017e385d0328541ccfebeef165fc Author: Namhyung Kim <[email protected]> AuthorDate: Wed, 22 May 2019 14:32:50 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 28 May 2019 18:37:43 -0300
perf top: Add --namespaces option
Since 'perf record' already have this option, let's have it for 'perf top' as well.
--- tools/perf/Documentation/perf-top.txt | 5 +++++ tools/perf/builtin-top.c | 5 +++++ 2 files changed, 10 insertions(+)
tools/perf/Documentation/perf-top.txt +5 -0
@@ -262,6 +262,11 @@ Default is to monitor all CPUS. The number of threads to run when synthesizing events for existing processes. By default, the number of threads equals to the number of online CPUs. +--namespaces:: + Record events of type PERF_RECORD_NAMESPACES and display it with the + 'cgroup_id' sort key. + + INTERACTIVE PROMPTING KEYS --------------------------
tools/perf/builtin-top.c +5 -0
@@ -1208,6 +1208,9 @@ static int __cmd_top(struct perf_top *top)init_process_thread (top); +if (opts->record_namespaces) + top->tool.namespace_events = true; + ret =perf_event__synthesize_bpf_events (top->session, perf_event__process, &top->session->machines.host, &top->record_opts);
@@ -1500,6 +1503,8 @@ int cmd_top(int argc, const char **argv)OPT_BOOLEAN (0 ,"force" , &symbol_conf.force,"don't complain, do it" ),OPT_UINTEGER (0 ,"num-thread-synthesize" , &top.nr_threads_synthesize,"number of thread to run event synthesize" ), +OPT_BOOLEAN (0 ,"namespaces" , &opts->record_namespaces, +"Record namespaces events" ), OPT_END() };struct perf_evlist *sb_evlist =NULL ;