diff options
-rw-r--r-- | fs/exec.c | 6 | ||||
-rw-r--r-- | include/linux/perf_event.h | 4 | ||||
-rw-r--r-- | include/linux/sched.h | 6 | ||||
-rw-r--r-- | include/uapi/linux/perf_event.h | 9 | ||||
-rw-r--r-- | kernel/events/core.c | 4 |
5 files changed, 19 insertions, 10 deletions
@@ -1046,13 +1046,13 @@ EXPORT_SYMBOL_GPL(get_task_comm); | |||
1046 | * so that a new one can be started | 1046 | * so that a new one can be started |
1047 | */ | 1047 | */ |
1048 | 1048 | ||
1049 | void set_task_comm(struct task_struct *tsk, const char *buf) | 1049 | void __set_task_comm(struct task_struct *tsk, const char *buf, bool exec) |
1050 | { | 1050 | { |
1051 | task_lock(tsk); | 1051 | task_lock(tsk); |
1052 | trace_task_rename(tsk, buf); | 1052 | trace_task_rename(tsk, buf); |
1053 | strlcpy(tsk->comm, buf, sizeof(tsk->comm)); | 1053 | strlcpy(tsk->comm, buf, sizeof(tsk->comm)); |
1054 | task_unlock(tsk); | 1054 | task_unlock(tsk); |
1055 | perf_event_comm(tsk); | 1055 | perf_event_comm(tsk, exec); |
1056 | } | 1056 | } |
1057 | 1057 | ||
1058 | int flush_old_exec(struct linux_binprm * bprm) | 1058 | int flush_old_exec(struct linux_binprm * bprm) |
@@ -1111,7 +1111,7 @@ void setup_new_exec(struct linux_binprm * bprm) | |||
1111 | set_dumpable(current->mm, suid_dumpable); | 1111 | set_dumpable(current->mm, suid_dumpable); |
1112 | 1112 | ||
1113 | perf_event_exec(); | 1113 | perf_event_exec(); |
1114 | set_task_comm(current, kbasename(bprm->filename)); | 1114 | __set_task_comm(current, kbasename(bprm->filename), true); |
1115 | 1115 | ||
1116 | /* Set the new mm task size. We have to do that late because it may | 1116 | /* Set the new mm task size. We have to do that late because it may |
1117 | * depend on TIF_32BIT which is only updated in flush_thread() on | 1117 | * depend on TIF_32BIT which is only updated in flush_thread() on |
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index b4c1d4685bf0..707617a8c0f6 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h | |||
@@ -707,7 +707,7 @@ extern int perf_register_guest_info_callbacks(struct perf_guest_info_callbacks * | |||
707 | extern int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks); | 707 | extern int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks); |
708 | 708 | ||
709 | extern void perf_event_exec(void); | 709 | extern void perf_event_exec(void); |
710 | extern void perf_event_comm(struct task_struct *tsk); | 710 | extern void perf_event_comm(struct task_struct *tsk, bool exec); |
711 | extern void perf_event_fork(struct task_struct *tsk); | 711 | extern void perf_event_fork(struct task_struct *tsk); |
712 | 712 | ||
713 | /* Callchains */ | 713 | /* Callchains */ |
@@ -815,7 +815,7 @@ static inline int perf_unregister_guest_info_callbacks | |||
815 | 815 | ||
816 | static inline void perf_event_mmap(struct vm_area_struct *vma) { } | 816 | static inline void perf_event_mmap(struct vm_area_struct *vma) { } |
817 | static inline void perf_event_exec(void) { } | 817 | static inline void perf_event_exec(void) { } |
818 | static inline void perf_event_comm(struct task_struct *tsk) { } | 818 | static inline void perf_event_comm(struct task_struct *tsk, bool exec) { } |
819 | static inline void perf_event_fork(struct task_struct *tsk) { } | 819 | static inline void perf_event_fork(struct task_struct *tsk) { } |
820 | static inline void perf_event_init(void) { } | 820 | static inline void perf_event_init(void) { } |
821 | static inline int perf_swevent_get_recursion_context(void) { return -1; } | 821 | static inline int perf_swevent_get_recursion_context(void) { return -1; } |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 221b2bde3723..ad86e1d7dbc2 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -2379,7 +2379,11 @@ extern long do_fork(unsigned long, unsigned long, unsigned long, int __user *, i | |||
2379 | struct task_struct *fork_idle(int); | 2379 | struct task_struct *fork_idle(int); |
2380 | extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); | 2380 | extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); |
2381 | 2381 | ||
2382 | extern void set_task_comm(struct task_struct *tsk, const char *from); | 2382 | extern void __set_task_comm(struct task_struct *tsk, const char *from, bool exec); |
2383 | static inline void set_task_comm(struct task_struct *tsk, const char *from) | ||
2384 | { | ||
2385 | __set_task_comm(tsk, from, false); | ||
2386 | } | ||
2383 | extern char *get_task_comm(char *to, struct task_struct *tsk); | 2387 | extern char *get_task_comm(char *to, struct task_struct *tsk); |
2384 | 2388 | ||
2385 | #ifdef CONFIG_SMP | 2389 | #ifdef CONFIG_SMP |
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h index d9cd853818ad..5312fae47218 100644 --- a/include/uapi/linux/perf_event.h +++ b/include/uapi/linux/perf_event.h | |||
@@ -302,8 +302,8 @@ struct perf_event_attr { | |||
302 | exclude_callchain_kernel : 1, /* exclude kernel callchains */ | 302 | exclude_callchain_kernel : 1, /* exclude kernel callchains */ |
303 | exclude_callchain_user : 1, /* exclude user callchains */ | 303 | exclude_callchain_user : 1, /* exclude user callchains */ |
304 | mmap2 : 1, /* include mmap with inode data */ | 304 | mmap2 : 1, /* include mmap with inode data */ |
305 | 305 | comm_exec : 1, /* flag comm events that are due to an exec */ | |
306 | __reserved_1 : 40; | 306 | __reserved_1 : 39; |
307 | 307 | ||
308 | union { | 308 | union { |
309 | __u32 wakeup_events; /* wakeup every n events */ | 309 | __u32 wakeup_events; /* wakeup every n events */ |
@@ -502,7 +502,12 @@ struct perf_event_mmap_page { | |||
502 | #define PERF_RECORD_MISC_GUEST_KERNEL (4 << 0) | 502 | #define PERF_RECORD_MISC_GUEST_KERNEL (4 << 0) |
503 | #define PERF_RECORD_MISC_GUEST_USER (5 << 0) | 503 | #define PERF_RECORD_MISC_GUEST_USER (5 << 0) |
504 | 504 | ||
505 | /* | ||
506 | * PERF_RECORD_MISC_MMAP_DATA and PERF_RECORD_MISC_COMM_EXEC are used on | ||
507 | * different events so can reuse the same bit position. | ||
508 | */ | ||
505 | #define PERF_RECORD_MISC_MMAP_DATA (1 << 13) | 509 | #define PERF_RECORD_MISC_MMAP_DATA (1 << 13) |
510 | #define PERF_RECORD_MISC_COMM_EXEC (1 << 13) | ||
506 | /* | 511 | /* |
507 | * Indicates that the content of PERF_SAMPLE_IP points to | 512 | * Indicates that the content of PERF_SAMPLE_IP points to |
508 | * the actual instruction that triggered the event. See also | 513 | * the actual instruction that triggered the event. See also |
diff --git a/kernel/events/core.c b/kernel/events/core.c index 8fac2056d51e..7da5e561e89a 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -5090,7 +5090,7 @@ static void perf_event_comm_event(struct perf_comm_event *comm_event) | |||
5090 | NULL); | 5090 | NULL); |
5091 | } | 5091 | } |
5092 | 5092 | ||
5093 | void perf_event_comm(struct task_struct *task) | 5093 | void perf_event_comm(struct task_struct *task, bool exec) |
5094 | { | 5094 | { |
5095 | struct perf_comm_event comm_event; | 5095 | struct perf_comm_event comm_event; |
5096 | 5096 | ||
@@ -5104,7 +5104,7 @@ void perf_event_comm(struct task_struct *task) | |||
5104 | .event_id = { | 5104 | .event_id = { |
5105 | .header = { | 5105 | .header = { |
5106 | .type = PERF_RECORD_COMM, | 5106 | .type = PERF_RECORD_COMM, |
5107 | .misc = 0, | 5107 | .misc = exec ? PERF_RECORD_MISC_COMM_EXEC : 0, |
5108 | /* .size */ | 5108 | /* .size */ |
5109 | }, | 5109 | }, |
5110 | /* .pid */ | 5110 | /* .pid */ |