summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Nabirushkin <inabirushkin@nvidia.com>2019-02-25 06:52:32 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2019-04-11 16:42:52 -0400
commit68303a6bdeb9ac5fd193941b61dc8a2246d014d3 (patch)
tree39745f520f96d6476e6cc1067f73a7e5adfb5c02
parent9d1f5e243d40759e6eaed6b2d03ae7559b9da600 (diff)
misc: tegra-profiler: add task comm events
Add task COMM events: - Add support for quadd_event_comm() callback. - Send task COMM events to userspace. Bug 2514095 Jira DTSP-2432 Change-Id: Id5b92f544497b69098e3b16bf82baf0f6abb77e1 Signed-off-by: Igor Nabirushkin <inabirushkin@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2027490 (cherry picked from commit a0c0d3bf9eeabbdad2a43b768235e1cc846b04ef) Reviewed-on: https://git-master.nvidia.com/r/2093405 GVS: Gerrit_Virtual_Submit Reviewed-by: Roman Rybalko <rrybalko@nvidia.com> Reviewed-by: Bibek Basu <bbasu@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r--drivers/misc/tegra-profiler/hrt.c157
-rw-r--r--drivers/misc/tegra-profiler/hrt.h5
-rw-r--r--drivers/misc/tegra-profiler/main.c11
-rw-r--r--drivers/misc/tegra-profiler/mmap.c26
-rw-r--r--drivers/misc/tegra-profiler/quadd.h36
-rw-r--r--drivers/misc/tegra-profiler/version.h2
-rw-r--r--include/linux/tegra_profiler.h10
-rw-r--r--include/uapi/linux/tegra_profiler.h179
8 files changed, 278 insertions, 148 deletions
diff --git a/drivers/misc/tegra-profiler/hrt.c b/drivers/misc/tegra-profiler/hrt.c
index 35c4f01bc..642cfffdb 100644
--- a/drivers/misc/tegra-profiler/hrt.c
+++ b/drivers/misc/tegra-profiler/hrt.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/misc/tegra-profiler/hrt.c 2 * drivers/misc/tegra-profiler/hrt.c
3 * 3 *
4 * Copyright (c) 2015-2018, NVIDIA CORPORATION. All rights reserved. 4 * Copyright (c) 2015-2019, NVIDIA CORPORATION. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -339,6 +339,36 @@ put_sched_sample(struct task_struct *task, int is_sched_in)
339 quadd_put_sample_this_cpu(&record, vec, vec_idx); 339 quadd_put_sample_this_cpu(&record, vec, vec_idx);
340} 340}
341 341
342static void put_comm_sample(struct task_struct *task, bool exec)
343{
344 char name[TASK_COMM_LEN];
345 struct quadd_iovec vec;
346 struct quadd_record_data record;
347 struct quadd_comm_data *s = &record.comm;
348
349 s->time = quadd_get_time();
350 s->flags = 0;
351
352 s->pid = (u32)task_pid_nr(task);
353 s->tgid = (u32)task_tgid_nr(task);
354
355 memset(name, 0, sizeof(name));
356 get_task_comm(name, task);
357 name[sizeof(name) - 1] = '\0';
358
359 record.record_type = QUADD_RECORD_TYPE_COMM;
360
361 if (exec)
362 s->flags |= QUADD_COMM_FLAG_EXEC;
363
364 vec.base = name;
365 vec.len = ALIGN(strlen(name) + 1, sizeof(u64));
366
367 s->length = (u16)vec.len;
368
369 quadd_put_sample(&record, &vec, 1);
370}
371
342static int get_sample_data(struct quadd_sample_data *s, 372static int get_sample_data(struct quadd_sample_data *s,
343 struct pt_regs *regs, 373 struct pt_regs *regs,
344 struct task_struct *task) 374 struct task_struct *task)
@@ -629,48 +659,69 @@ static void init_hrtimer(struct quadd_cpu_context *cpu_ctx)
629 cpu_ctx->hrtimer.function = hrtimer_handler; 659 cpu_ctx->hrtimer.function = hrtimer_handler;
630} 660}
631 661
632static inline int 662static inline bool
633is_profile_process(struct task_struct *task, int is_trace) 663__is_profile_process(struct task_struct *task, bool is_trace, bool is_sample)
634{ 664{
635 pid_t root_pid = hrt.root_pid; 665 pid_t root_pid = hrt.root_pid;
636 struct quadd_ctx *ctx = hrt.quadd_ctx; 666 struct quadd_ctx *ctx = hrt.quadd_ctx;
637 667
638 if (root_pid > 0 && task_tgid_nr(task) == root_pid) 668 if (root_pid > 0 && task_tgid_nr(task) == root_pid)
639 return 1; 669 return true;
640 670
641 if ((is_trace && quadd_mode_is_trace_tree(ctx)) || 671 if ((is_trace && quadd_mode_is_trace_tree(ctx)) ||
642 (!is_trace && quadd_mode_is_sample_tree(ctx))) 672 (is_sample && quadd_mode_is_sample_tree(ctx)))
643 return pid_list_search(task_tgid_nr(task)); 673 return pid_list_search(task_tgid_nr(task));
644 674
645 return 0; 675 return false;
646} 676}
647 677
648static inline int 678static inline bool
649validate_task(struct task_struct *task) 679validate_task(struct task_struct *task)
650{ 680{
651 return task && !is_idle_task(task); 681 return task && !is_idle_task(task);
652} 682}
653 683
654static inline int 684static inline bool
655is_sample_process(struct task_struct *task) 685is_sample_process(struct task_struct *task)
656{ 686{
657 struct quadd_ctx *ctx = hrt.quadd_ctx; 687 struct quadd_ctx *ctx = hrt.quadd_ctx;
658 688
659 if (!validate_task(task) || !quadd_mode_is_sampling(ctx)) 689 if (!validate_task(task) || !quadd_mode_is_sampling(ctx))
660 return 0; 690 return false;
661 691
662 return (quadd_mode_is_sample_all(ctx) || is_profile_process(task, 0)); 692 if (quadd_mode_is_sample_all(ctx))
693 return true;
694
695 return __is_profile_process(task, false, true);
663} 696}
664 697
665static inline int 698static inline bool
666is_trace_process(struct task_struct *task) 699is_trace_process(struct task_struct *task)
667{ 700{
668 struct quadd_ctx *ctx = hrt.quadd_ctx; 701 struct quadd_ctx *ctx = hrt.quadd_ctx;
669 702
670 if (!validate_task(task) || !quadd_mode_is_tracing(ctx)) 703 if (!validate_task(task) || !quadd_mode_is_tracing(ctx))
671 return 0; 704 return false;
705
706 if (quadd_mode_is_trace_all(ctx))
707 return true;
708
709 return __is_profile_process(task, true, false);
710}
711
712static inline bool
713is_profile_process(struct task_struct *task)
714{
715 struct quadd_ctx *ctx = hrt.quadd_ctx;
716
717 if (!validate_task(task) ||
718 (!quadd_mode_is_tracing(ctx) && !quadd_mode_is_sampling(ctx)))
719 return false;
672 720
673 return (quadd_mode_is_trace_all(ctx) || is_profile_process(task, 1)); 721 if (quadd_mode_is_process_all(ctx))
722 return true;
723
724 return __is_profile_process(task, true, true);
674} 725}
675 726
676static void 727static void
@@ -790,23 +841,23 @@ void __quadd_event_mmap(struct vm_area_struct *vma)
790 quadd_process_mmap(vma, current); 841 quadd_process_mmap(vma, current);
791} 842}
792 843
793int quadd_is_inherited(struct task_struct *task) 844bool quadd_is_inherited(struct task_struct *task)
794{ 845{
795 struct task_struct *p; 846 struct task_struct *p;
796 847
797 if (unlikely(hrt.root_pid == 0)) 848 if (unlikely(hrt.root_pid == 0))
798 return 0; 849 return false;
799 850
800 for (p = task; p != &init_task;) { 851 for (p = task; p != &init_task;) {
801 if (task_pid_nr(p) == hrt.root_pid) 852 if (task_pid_nr(p) == hrt.root_pid)
802 return 1; 853 return true;
803 854
804 rcu_read_lock(); 855 rcu_read_lock();
805 p = rcu_dereference(p->real_parent); 856 p = rcu_dereference(p->real_parent);
806 rcu_read_unlock(); 857 rcu_read_unlock();
807 } 858 }
808 859
809 return 0; 860 return false;
810} 861}
811 862
812void __quadd_event_fork(struct task_struct *task) 863void __quadd_event_fork(struct task_struct *task)
@@ -839,6 +890,17 @@ void __quadd_event_exit(struct task_struct *task)
839 read_unlock(&tasklist_lock); 890 read_unlock(&tasklist_lock);
840} 891}
841 892
893void __quadd_event_comm(struct task_struct *task, bool exec)
894{
895 if (likely(!atomic_read(&hrt.active)))
896 return;
897
898 if (!is_profile_process(task))
899 return;
900
901 put_comm_sample(task, exec);
902}
903
842static void reset_cpu_ctx(void) 904static void reset_cpu_ctx(void)
843{ 905{
844 int cpu_id; 906 int cpu_id;
@@ -857,6 +919,51 @@ static void reset_cpu_ctx(void)
857 } 919 }
858} 920}
859 921
922static void get_initial_samples(struct quadd_ctx *ctx)
923{
924 struct task_struct *p, *t;
925
926 if (quadd_mode_is_sampling(ctx))
927 quadd_get_mmaps(ctx);
928
929 if (quadd_mode_is_process_all(ctx)) {
930 bool is_tree = quadd_mode_is_process_tree(ctx);
931
932 read_lock(&tasklist_lock);
933 for_each_process(p) {
934 for_each_thread(p, t)
935 put_comm_sample(t, false);
936
937 if (is_tree && quadd_is_inherited(p))
938 pid_list_add(task_pid_nr(p));
939 }
940 read_unlock(&tasklist_lock);
941 } else if (quadd_mode_is_process_tree(ctx)) {
942 read_lock(&tasklist_lock);
943 for_each_process(p) {
944 if (quadd_is_inherited(p)) {
945 pid_list_add(task_pid_nr(p));
946 for_each_thread(p, t)
947 put_comm_sample(t, false);
948 }
949 }
950 read_unlock(&tasklist_lock);
951 } else {
952 pid_t root_pid = hrt.root_pid;
953
954 if (root_pid > 0) {
955 read_lock(&tasklist_lock);
956 p = get_pid_task(find_vpid(root_pid), PIDTYPE_PID);
957 if (p) {
958 for_each_thread(p, t)
959 put_comm_sample(t, false);
960 put_task_struct(p);
961 }
962 read_unlock(&tasklist_lock);
963 }
964 }
965}
966
860int quadd_hrt_start(void) 967int quadd_hrt_start(void)
861{ 968{
862 int cpuid; 969 int cpuid;
@@ -920,25 +1027,13 @@ int quadd_hrt_start(void)
920 */ 1027 */
921 smp_wmb(); 1028 smp_wmb();
922 1029
923 if (quadd_mode_is_sampling(ctx)) { 1030 get_initial_samples(ctx);
924 if (extra & QUADD_PARAM_EXTRA_GET_MMAP)
925 quadd_get_mmaps(ctx);
926 1031
1032 if (quadd_mode_is_sampling(ctx)) {
927 if (ctx->pl310) 1033 if (ctx->pl310)
928 ctx->pl310->start(); 1034 ctx->pl310->start();
929 } 1035 }
930 1036
931 if (quadd_mode_is_process_tree(ctx)) {
932 struct task_struct *p;
933
934 read_lock(&tasklist_lock);
935 for_each_process(p) {
936 if (quadd_is_inherited(p))
937 pid_list_add(task_pid_nr(p));
938 }
939 read_unlock(&tasklist_lock);
940 }
941
942 quadd_ma_start(&hrt); 1037 quadd_ma_start(&hrt);
943 1038
944 /* Enable the sampling only after quadd_get_mmaps() */ 1039 /* Enable the sampling only after quadd_get_mmaps() */
diff --git a/drivers/misc/tegra-profiler/hrt.h b/drivers/misc/tegra-profiler/hrt.h
index e545b73e2..267426b71 100644
--- a/drivers/misc/tegra-profiler/hrt.h
+++ b/drivers/misc/tegra-profiler/hrt.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/misc/tegra-profiler/hrt.h 2 * drivers/misc/tegra-profiler/hrt.h
3 * 3 *
4 * Copyright (c) 2015-2018, NVIDIA CORPORATION. All rights reserved. 4 * Copyright (c) 2015-2019, NVIDIA CORPORATION. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -19,6 +19,7 @@
19 19
20#ifdef __KERNEL__ 20#ifdef __KERNEL__
21 21
22#include <linux/types.h>
22#include <linux/hrtimer.h> 23#include <linux/hrtimer.h>
23#include <linux/limits.h> 24#include <linux/limits.h>
24 25
@@ -113,7 +114,7 @@ quadd_put_sample(struct quadd_record_data *data,
113 114
114void quadd_hrt_get_state(struct quadd_module_state *state); 115void quadd_hrt_get_state(struct quadd_module_state *state);
115u64 quadd_get_time(void); 116u64 quadd_get_time(void);
116int quadd_is_inherited(struct task_struct *task); 117bool quadd_is_inherited(struct task_struct *task);
117 118
118#endif /* __KERNEL__ */ 119#endif /* __KERNEL__ */
119 120
diff --git a/drivers/misc/tegra-profiler/main.c b/drivers/misc/tegra-profiler/main.c
index 39ede51d8..23e43efd2 100644
--- a/drivers/misc/tegra-profiler/main.c
+++ b/drivers/misc/tegra-profiler/main.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/misc/tegra-profiler/main.c 2 * drivers/misc/tegra-profiler/main.c
3 * 3 *
4 * Copyright (c) 2013-2018, NVIDIA CORPORATION. All rights reserved. 4 * Copyright (c) 2013-2019, NVIDIA CORPORATION. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -267,6 +267,11 @@ set_parameters(struct quadd_parameters *p)
267 ctx.mode_is_trace_tree = 267 ctx.mode_is_trace_tree =
268 extra & QUADD_PARAM_EXTRA_TRACE_TREE ? 1 : 0; 268 extra & QUADD_PARAM_EXTRA_TRACE_TREE ? 1 : 0;
269 269
270 if (ctx.mode_is_sample_all)
271 ctx.mode_is_sample_tree = 0;
272 if (ctx.mode_is_trace_all)
273 ctx.mode_is_trace_tree = 0;
274
270 pr_info("flags: s/t/sa/ta/st/tt: %u/%u/%u/%u/%u/%u\n", 275 pr_info("flags: s/t/sa/ta/st/tt: %u/%u/%u/%u/%u/%u\n",
271 ctx.mode_is_sampling, 276 ctx.mode_is_sampling,
272 ctx.mode_is_tracing, 277 ctx.mode_is_tracing,
@@ -295,10 +300,12 @@ set_parameters(struct quadd_parameters *p)
295 } 300 }
296 301
297 /* Currently only first process */ 302 /* Currently only first process */
298 if (p->nr_pids != 1) 303 if (p->nr_pids != 1 || p->pids[0] == 0)
299 return -EINVAL; 304 return -EINVAL;
300 305
306 rcu_read_lock();
301 task = get_pid_task(find_vpid(p->pids[0]), PIDTYPE_PID); 307 task = get_pid_task(find_vpid(p->pids[0]), PIDTYPE_PID);
308 rcu_read_unlock();
302 if (!task) { 309 if (!task) {
303 pr_err("error: process not found: %u\n", p->pids[0]); 310 pr_err("error: process not found: %u\n", p->pids[0]);
304 return -ESRCH; 311 return -ESRCH;
diff --git a/drivers/misc/tegra-profiler/mmap.c b/drivers/misc/tegra-profiler/mmap.c
index 228ddd75b..3adaa5bef 100644
--- a/drivers/misc/tegra-profiler/mmap.c
+++ b/drivers/misc/tegra-profiler/mmap.c
@@ -214,7 +214,7 @@ __get_process_vmas(struct task_struct *task,
214 process_mmap(vma, task, buf, buf_size); 214 process_mmap(vma, task, buf, buf_size);
215} 215}
216 216
217static void get_all_processes(int is_root_pid) 217static void get_all_processes(bool is_root_pid)
218{ 218{
219 char *buf; 219 char *buf;
220 struct task_struct *p; 220 struct task_struct *p;
@@ -255,7 +255,6 @@ __continue:
255 255
256void quadd_get_mmaps(struct quadd_ctx *ctx) 256void quadd_get_mmaps(struct quadd_ctx *ctx)
257{ 257{
258 struct pid *pid;
259 struct task_struct *task; 258 struct task_struct *task;
260 struct quadd_parameters *param = &ctx->param; 259 struct quadd_parameters *param = &ctx->param;
261 260
@@ -263,22 +262,21 @@ void quadd_get_mmaps(struct quadd_ctx *ctx)
263 return; 262 return;
264 263
265 if (quadd_mode_is_sample_all(ctx)) { 264 if (quadd_mode_is_sample_all(ctx)) {
266 get_all_processes(0); 265 get_all_processes(false);
267 return; 266 return;
268 } 267 }
269 268
270 pid = find_vpid(param->pids[0]); 269 rcu_read_lock();
271 270 task = get_pid_task(find_vpid(param->pids[0]), PIDTYPE_PID);
272 task = get_pid_task(pid, PIDTYPE_PID); 271 rcu_read_unlock();
273 if (!task) 272 if (task) {
274 return; 273 if (quadd_mode_is_sample_tree(ctx))
275 274 get_all_processes(true);
276 if (quadd_mode_is_sample_tree(ctx)) 275 else
277 get_all_processes(1); 276 get_process_vmas(task);
278 else
279 get_process_vmas(task);
280 277
281 put_task_struct(task); 278 put_task_struct(task);
279 }
282} 280}
283 281
284void quadd_get_task_mmaps(struct quadd_ctx *ctx, struct task_struct *task) 282void quadd_get_task_mmaps(struct quadd_ctx *ctx, struct task_struct *task)
diff --git a/drivers/misc/tegra-profiler/quadd.h b/drivers/misc/tegra-profiler/quadd.h
index ba166e085..eb91a0737 100644
--- a/drivers/misc/tegra-profiler/quadd.h
+++ b/drivers/misc/tegra-profiler/quadd.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/misc/tegra-profiler/quadd.h 2 * drivers/misc/tegra-profiler/quadd.h
3 * 3 *
4 * Copyright (c) 2014-2018, NVIDIA CORPORATION. All rights reserved. 4 * Copyright (c) 2014-2019, NVIDIA CORPORATION. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -17,6 +17,7 @@
17#ifndef __QUADD_H 17#ifndef __QUADD_H
18#define __QUADD_H 18#define __QUADD_H
19 19
20#include <linux/types.h>
20#include <linux/list.h> 21#include <linux/list.h>
21#include <linux/spinlock.h> 22#include <linux/spinlock.h>
22 23
@@ -96,39 +97,44 @@ struct quadd_ctx {
96 raw_spinlock_t mmaps_lock; 97 raw_spinlock_t mmaps_lock;
97}; 98};
98 99
99static inline int quadd_mode_is_sampling(struct quadd_ctx *ctx) 100static inline bool quadd_mode_is_sampling(struct quadd_ctx *ctx)
100{ 101{
101 return ctx->mode_is_sampling; 102 return ctx->mode_is_sampling != 0;
102} 103}
103 104
104static inline int quadd_mode_is_tracing(struct quadd_ctx *ctx) 105static inline bool quadd_mode_is_tracing(struct quadd_ctx *ctx)
105{ 106{
106 return ctx->mode_is_tracing; 107 return ctx->mode_is_tracing != 0;
107} 108}
108 109
109static inline int quadd_mode_is_sample_all(struct quadd_ctx *ctx) 110static inline bool quadd_mode_is_sample_all(struct quadd_ctx *ctx)
110{ 111{
111 return ctx->mode_is_sample_all; 112 return ctx->mode_is_sample_all != 0;
112} 113}
113 114
114static inline int quadd_mode_is_trace_all(struct quadd_ctx *ctx) 115static inline bool quadd_mode_is_trace_all(struct quadd_ctx *ctx)
115{ 116{
116 return ctx->mode_is_trace_all; 117 return ctx->mode_is_trace_all != 0;
117} 118}
118 119
119static inline int quadd_mode_is_sample_tree(struct quadd_ctx *ctx) 120static inline bool quadd_mode_is_sample_tree(struct quadd_ctx *ctx)
120{ 121{
121 return ctx->mode_is_sample_tree; 122 return ctx->mode_is_sample_tree != 0;
122} 123}
123 124
124static inline int quadd_mode_is_trace_tree(struct quadd_ctx *ctx) 125static inline bool quadd_mode_is_trace_tree(struct quadd_ctx *ctx)
125{ 126{
126 return ctx->mode_is_trace_tree; 127 return ctx->mode_is_trace_tree != 0;
127} 128}
128 129
129static inline int quadd_mode_is_process_tree(struct quadd_ctx *ctx) 130static inline bool quadd_mode_is_process_tree(struct quadd_ctx *ctx)
130{ 131{
131 return (ctx->mode_is_sample_tree || ctx->mode_is_trace_tree); 132 return (ctx->mode_is_sample_tree != 0 || ctx->mode_is_trace_tree != 0);
133}
134
135static inline bool quadd_mode_is_process_all(struct quadd_ctx *ctx)
136{
137 return (ctx->mode_is_sample_all != 0 || ctx->mode_is_trace_all != 0);
132} 138}
133 139
134void quadd_get_state(struct quadd_module_state *state); 140void quadd_get_state(struct quadd_module_state *state);
diff --git a/drivers/misc/tegra-profiler/version.h b/drivers/misc/tegra-profiler/version.h
index c0e648d87..b0b75a7ee 100644
--- a/drivers/misc/tegra-profiler/version.h
+++ b/drivers/misc/tegra-profiler/version.h
@@ -17,7 +17,7 @@
17#ifndef __QUADD_VERSION_H 17#ifndef __QUADD_VERSION_H
18#define __QUADD_VERSION_H 18#define __QUADD_VERSION_H
19 19
20#define QUADD_MODULE_VERSION "1.132" 20#define QUADD_MODULE_VERSION "1.133"
21#define QUADD_MODULE_BRANCH "Dev" 21#define QUADD_MODULE_BRANCH "Dev"
22 22
23#endif /* __QUADD_VERSION_H */ 23#endif /* __QUADD_VERSION_H */
diff --git a/include/linux/tegra_profiler.h b/include/linux/tegra_profiler.h
index c55f25b57..edca37b25 100644
--- a/include/linux/tegra_profiler.h
+++ b/include/linux/tegra_profiler.h
@@ -31,6 +31,7 @@ extern void __quadd_task_sched_out(struct task_struct *prev,
31extern void __quadd_event_mmap(struct vm_area_struct *vma); 31extern void __quadd_event_mmap(struct vm_area_struct *vma);
32extern void __quadd_event_fork(struct task_struct *task); 32extern void __quadd_event_fork(struct task_struct *task);
33extern void __quadd_event_exit(struct task_struct *task); 33extern void __quadd_event_exit(struct task_struct *task);
34extern void __quadd_event_comm(struct task_struct *task, bool exec);
34 35
35static inline void quadd_task_sched_in(struct task_struct *prev, 36static inline void quadd_task_sched_in(struct task_struct *prev,
36 struct task_struct *task) 37 struct task_struct *task)
@@ -59,6 +60,11 @@ static inline void quadd_event_exit(struct task_struct *task)
59 __quadd_event_exit(task); 60 __quadd_event_exit(task);
60} 61}
61 62
63static inline void quadd_event_comm(struct task_struct *task, bool exec)
64{
65 __quadd_event_comm(task, exec);
66}
67
62#else /* CONFIG_TEGRA_PROFILER */ 68#else /* CONFIG_TEGRA_PROFILER */
63 69
64static inline void quadd_task_sched_in(struct task_struct *prev, 70static inline void quadd_task_sched_in(struct task_struct *prev,
@@ -83,6 +89,10 @@ static inline void quadd_event_exit(struct task_struct *task)
83{ 89{
84} 90}
85 91
92static inline void quadd_event_comm(struct task_struct *task, bool exec)
93{
94}
95
86#endif /* CONFIG_TEGRA_PROFILER */ 96#endif /* CONFIG_TEGRA_PROFILER */
87 97
88#endif /* __TEGRA_PROFILER_H */ 98#endif /* __TEGRA_PROFILER_H */
diff --git a/include/uapi/linux/tegra_profiler.h b/include/uapi/linux/tegra_profiler.h
index 0e0c36f15..b05e46724 100644
--- a/include/uapi/linux/tegra_profiler.h
+++ b/include/uapi/linux/tegra_profiler.h
@@ -20,71 +20,72 @@
20#include <linux/ioctl.h> 20#include <linux/ioctl.h>
21#include <linux/types.h> 21#include <linux/types.h>
22 22
23#define QUADD_SAMPLES_VERSION 46 23#define QUADD_SAMPLES_VERSION 47
24#define QUADD_IO_VERSION 26 24#define QUADD_IO_VERSION 26
25 25
26#define QUADD_IO_VERSION_DYNAMIC_RB 5 26#define QUADD_IO_VERSION_DYNAMIC_RB 5
27#define QUADD_IO_VERSION_RB_MAX_FILL_COUNT 6 27#define QUADD_IO_VERSION_RB_MAX_FILL_COUNT 6
28#define QUADD_IO_VERSION_MOD_STATE_STATUS_FIELD 7 28#define QUADD_IO_VERSION_MOD_STATE_STATUS_FIELD 7
29#define QUADD_IO_VERSION_BT_KERNEL_CTX 8 29#define QUADD_IO_VERSION_BT_KERNEL_CTX 8
30#define QUADD_IO_VERSION_GET_MMAP 9 30#define QUADD_IO_VERSION_GET_MMAP 9
31#define QUADD_IO_VERSION_BT_UNWIND_TABLES 10 31#define QUADD_IO_VERSION_BT_UNWIND_TABLES 10
32#define QUADD_IO_VERSION_UNWIND_MIXED 11 32#define QUADD_IO_VERSION_UNWIND_MIXED 11
33#define QUADD_IO_VERSION_EXTABLES_MMAP 12 33#define QUADD_IO_VERSION_EXTABLES_MMAP 12
34#define QUADD_IO_VERSION_ARCH_TIMER_OPT 13 34#define QUADD_IO_VERSION_ARCH_TIMER_OPT 13
35#define QUADD_IO_VERSION_DATA_MMAP 14 35#define QUADD_IO_VERSION_DATA_MMAP 14
36#define QUADD_IO_VERSION_BT_LOWER_BOUND 15 36#define QUADD_IO_VERSION_BT_LOWER_BOUND 15
37#define QUADD_IO_VERSION_STACK_OFFSET 16 37#define QUADD_IO_VERSION_STACK_OFFSET 16
38#define QUADD_IO_VERSION_SECTIONS_INFO 17 38#define QUADD_IO_VERSION_SECTIONS_INFO 17
39#define QUADD_IO_VERSION_UNW_METHODS_OPT 18 39#define QUADD_IO_VERSION_UNW_METHODS_OPT 18
40#define QUADD_IO_VERSION_PER_CPU_SETUP 19 40#define QUADD_IO_VERSION_PER_CPU_SETUP 19
41#define QUADD_IO_VERSION_TRACE_ALL_TASKS 20 41#define QUADD_IO_VERSION_TRACE_ALL_TASKS 20
42#define QUADD_IO_VERSION_CB_POWER_OF_2 21 42#define QUADD_IO_VERSION_CB_POWER_OF_2 21
43#define QUADD_IO_VERSION_RAW_EVENTS 22 43#define QUADD_IO_VERSION_RAW_EVENTS 22
44#define QUADD_IO_VERSION_SAMPLING_MODE 23 44#define QUADD_IO_VERSION_SAMPLING_MODE 23
45#define QUADD_IO_VERSION_FORCE_ARCH_TIMER 24 45#define QUADD_IO_VERSION_FORCE_ARCH_TIMER 24
46#define QUADD_IO_VERSION_SAMPLE_ALL_TASKS 25 46#define QUADD_IO_VERSION_SAMPLE_ALL_TASKS 25
47#define QUADD_IO_VERSION_EXTABLES_PID 26 47#define QUADD_IO_VERSION_EXTABLES_PID 26
48 48
49#define QUADD_SAMPLE_VERSION_THUMB_MODE_FLAG 17 49#define QUADD_SAMPLE_VERSION_THUMB_MODE_FLAG 17
50#define QUADD_SAMPLE_VERSION_GROUP_SAMPLES 18 50#define QUADD_SAMPLE_VERSION_GROUP_SAMPLES 18
51#define QUADD_SAMPLE_VERSION_THREAD_STATE_FLD 19 51#define QUADD_SAMPLE_VERSION_THREAD_STATE_FLD 19
52#define QUADD_SAMPLE_VERSION_BT_UNWIND_TABLES 22 52#define QUADD_SAMPLE_VERSION_BT_UNWIND_TABLES 22
53#define QUADD_SAMPLE_VERSION_SUPPORT_IP64 23 53#define QUADD_SAMPLE_VERSION_SUPPORT_IP64 23
54#define QUADD_SAMPLE_VERSION_SPECIAL_MMAP 24 54#define QUADD_SAMPLE_VERSION_SPECIAL_MMAP 24
55#define QUADD_SAMPLE_VERSION_UNWIND_MIXED 25 55#define QUADD_SAMPLE_VERSION_UNWIND_MIXED 25
56#define QUADD_SAMPLE_VERSION_UNW_ENTRY_TYPE 26 56#define QUADD_SAMPLE_VERSION_UNW_ENTRY_TYPE 26
57#define QUADD_SAMPLE_VERSION_USE_ARCH_TIMER 27 57#define QUADD_SAMPLE_VERSION_USE_ARCH_TIMER 27
58#define QUADD_SAMPLE_VERSION_SCHED_SAMPLES 28 58#define QUADD_SAMPLE_VERSION_SCHED_SAMPLES 28
59#define QUADD_SAMPLE_VERSION_HDR_UNW_METHOD 29 59#define QUADD_SAMPLE_VERSION_HDR_UNW_METHOD 29
60#define QUADD_SAMPLE_VERSION_HDR_ARCH_TIMER 30 60#define QUADD_SAMPLE_VERSION_HDR_ARCH_TIMER 30
61#define QUADD_SAMPLE_VERSION_STACK_OFFSET 31 61#define QUADD_SAMPLE_VERSION_STACK_OFFSET 31
62#define QUADD_SAMPLE_VERSION_SCHED_TASK_STATE 32 62#define QUADD_SAMPLE_VERSION_SCHED_TASK_STATE 32
63#define QUADD_SAMPLE_VERSION_URCS 33 63#define QUADD_SAMPLE_VERSION_URCS 33
64#define QUADD_SAMPLE_VERSION_HOTPLUG 34 64#define QUADD_SAMPLE_VERSION_HOTPLUG 34
65#define QUADD_SAMPLE_VERSION_PER_CPU_SETUP 35 65#define QUADD_SAMPLE_VERSION_PER_CPU_SETUP 35
66#define QUADD_SAMPLE_VERSION_REPORT_TGID 36 66#define QUADD_SAMPLE_VERSION_REPORT_TGID 36
67#define QUADD_SAMPLE_VERSION_MMAP_TS 37 67#define QUADD_SAMPLE_VERSION_MMAP_TS 37
68#define QUADD_SAMPLE_VERSION_RAW_EVENTS 38 68#define QUADD_SAMPLE_VERSION_RAW_EVENTS 38
69#define QUADD_SAMPLE_VERSION_OVERHEAD_INFO 39 69#define QUADD_SAMPLE_VERSION_OVERHEAD_INFO 39
70#define QUADD_SAMPLE_VERSION_REPORT_VPID 40 70#define QUADD_SAMPLE_VERSION_REPORT_VPID 40
71#define QUADD_SAMPLE_VERSION_SCHED_REPORT_VPID 41 71#define QUADD_SAMPLE_VERSION_SCHED_REPORT_VPID 41
72#define QUADD_SAMPLE_VERSION_SAMPLING_MODE 42 72#define QUADD_SAMPLE_VERSION_SAMPLING_MODE 42
73#define QUADD_SAMPLE_VERSION_SAMPLE_ALL_TASKS 43 73#define QUADD_SAMPLE_VERSION_SAMPLE_ALL_TASKS 43
74#define QUADD_SAMPLE_VERSION_KTHREAD_TSK_FLAG 44 74#define QUADD_SAMPLE_VERSION_KTHREAD_TSK_FLAG 44
75#define QUADD_SAMPLE_VERSION_MMAP_CPUID 45 75#define QUADD_SAMPLE_VERSION_MMAP_CPUID 45
76#define QUADD_SAMPLE_VERSION_PCLK_SEND_CHANGES 46 76#define QUADD_SAMPLE_VERSION_PCLK_SEND_CHANGES 46
77 77#define QUADD_SAMPLE_VERSION_COMM_SAMPLES 47
78#define QUADD_MMAP_HEADER_VERSION 1 78
79 79#define QUADD_MMAP_HEADER_VERSION 1
80#define QUADD_MAX_COUNTERS 32 80
81#define QUADD_MAX_PROCESS 64 81#define QUADD_MAX_COUNTERS 32
82 82#define QUADD_MAX_PROCESS 64
83#define QUADD_DEVICE_NAME "quadd" 83
84#define QUADD_AUTH_DEVICE_NAME "quadd_auth" 84#define QUADD_DEVICE_NAME "quadd"
85 85#define QUADD_AUTH_DEVICE_NAME "quadd_auth"
86#define QUADD_MOD_DEVICE_NAME "quadd_mod" 86
87#define QUADD_MOD_AUTH_DEVICE_NAME "quadd_mod_auth" 87#define QUADD_MOD_DEVICE_NAME "quadd_mod"
88#define QUADD_MOD_AUTH_DEVICE_NAME "quadd_mod_auth"
88 89
89#define QUADD_IOCTL 100 90#define QUADD_IOCTL 100
90 91
@@ -345,6 +346,17 @@ enum {
345 QM_DEBUG_SAMPLE_TYPE_SOURCE_STOP, 346 QM_DEBUG_SAMPLE_TYPE_SOURCE_STOP,
346}; 347};
347 348
349#define QUADD_COMM_FLAG_EXEC (1U << 0)
350
351struct quadd_comm_data {
352 __u32 pid;
353 __u32 tgid;
354 __u64 time;
355
356 __u16 length;
357 __u32 flags;
358};
359
348struct quadd_debug_data { 360struct quadd_debug_data {
349 __u8 type; 361 __u8 type;
350 362
@@ -414,6 +426,7 @@ struct quadd_record_data {
414 struct quadd_power_rate_data power_rate; 426 struct quadd_power_rate_data power_rate;
415 struct quadd_hotplug_data hotplug; 427 struct quadd_hotplug_data hotplug;
416 struct quadd_sched_data sched; 428 struct quadd_sched_data sched;
429 struct quadd_comm_data comm;
417 struct quadd_additional_sample additional_sample; 430 struct quadd_additional_sample additional_sample;
418 }; 431 };
419} __aligned(4); 432} __aligned(4);
@@ -457,34 +470,34 @@ struct quadd_event {
457}; 470};
458 471
459struct quadd_parameters { 472struct quadd_parameters {
460 __u32 freq; 473 __u32 freq;
461 __u32 ma_freq; 474 __u32 ma_freq;
462 __u32 power_rate_freq; 475 __u32 power_rate_freq;
463 476
464 __u64 backtrace:1, 477 __u64 backtrace:1,
465 use_freq:1, 478 use_freq:1,
466 system_wide:1, 479 system_wide:1,
467 debug_samples:1, 480 debug_samples:1,
468 trace_all_tasks:1; 481 trace_all_tasks:1;
469 482
470 __u32 pids[QUADD_MAX_PROCESS]; 483 __u32 pids[QUADD_MAX_PROCESS];
471 __u32 nr_pids; 484 __u32 nr_pids;
472 485
473 __u8 package_name[QUADD_MAX_PACKAGE_NAME]; 486 __u8 package_name[QUADD_MAX_PACKAGE_NAME];
474 487
475 struct quadd_event events[QUADD_MAX_COUNTERS]; 488 struct quadd_event events[QUADD_MAX_COUNTERS];
476 __u32 nr_events; 489 __u32 nr_events;
477 490
478 __u32 reserved[16]; /* reserved fields for future extensions */ 491 __u32 reserved[16]; /* reserved fields for future extensions */
479}; 492};
480 493
481struct quadd_pmu_setup_for_cpu { 494struct quadd_pmu_setup_for_cpu {
482 __u32 cpuid; 495 __u32 cpuid;
483 496
484 struct quadd_event events[QUADD_MAX_COUNTERS]; 497 struct quadd_event events[QUADD_MAX_COUNTERS];
485 __u32 nr_events; 498 __u32 nr_events;
486 499
487 __u32 reserved[16]; 500 __u32 reserved[16];
488}; 501};
489 502
490struct quadd_events_cap { 503struct quadd_events_cap {