aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-top.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-top.c')
-rw-r--r--tools/perf/builtin-top.c44
1 files changed, 9 insertions, 35 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 7a3c0c7aad3d..e0a374d0e43a 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -929,55 +929,28 @@ static int symbol_filter(struct map *map, struct symbol *sym)
929static void event__process_sample(const event_t *self, int counter) 929static void event__process_sample(const event_t *self, int counter)
930{ 930{
931 u64 ip = self->ip.ip; 931 u64 ip = self->ip.ip;
932 struct map *map;
933 struct sym_entry *syme; 932 struct sym_entry *syme;
934 struct symbol *sym; 933 struct addr_location al;
935 u8 origin = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; 934 u8 origin = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
936 935
937 switch (origin) { 936 switch (origin) {
938 case PERF_RECORD_MISC_USER: { 937 case PERF_RECORD_MISC_USER:
939 struct thread *thread;
940
941 if (hide_user_symbols) 938 if (hide_user_symbols)
942 return; 939 return;
943 940 break;
944 thread = threads__findnew(self->ip.pid);
945 if (thread == NULL)
946 return;
947
948 map = thread__find_map(thread, MAP__FUNCTION, ip);
949 if (map != NULL) {
950 ip = map->map_ip(map, ip);
951 sym = map__find_symbol(map, ip, symbol_filter);
952 if (sym == NULL)
953 return;
954 userspace_samples++;
955 break;
956 }
957 }
958 /*
959 * If this is outside of all known maps,
960 * and is a negative address, try to look it
961 * up in the kernel dso, as it might be a
962 * vsyscall or vdso (which executes in user-mode).
963 */
964 if ((long long)ip >= 0)
965 return;
966 /* Fall thru */
967 case PERF_RECORD_MISC_KERNEL: 941 case PERF_RECORD_MISC_KERNEL:
968 if (hide_kernel_symbols) 942 if (hide_kernel_symbols)
969 return; 943 return;
970
971 sym = kernel_maps__find_function(ip, &map, symbol_filter);
972 if (sym == NULL)
973 return;
974 break; 944 break;
975 default: 945 default:
976 return; 946 return;
977 } 947 }
978 948
979 syme = symbol__priv(sym); 949 if (event__preprocess_sample(self, &al, symbol_filter) < 0 ||
950 al.sym == NULL)
951 return;
980 952
953 syme = symbol__priv(al.sym);
981 if (!syme->skip) { 954 if (!syme->skip) {
982 syme->count[counter]++; 955 syme->count[counter]++;
983 syme->origin = origin; 956 syme->origin = origin;
@@ -986,8 +959,9 @@ static void event__process_sample(const event_t *self, int counter)
986 if (list_empty(&syme->node) || !syme->node.next) 959 if (list_empty(&syme->node) || !syme->node.next)
987 __list_insert_active_sym(syme); 960 __list_insert_active_sym(syme);
988 pthread_mutex_unlock(&active_symbols_lock); 961 pthread_mutex_unlock(&active_symbols_lock);
962 if (origin == PERF_RECORD_MISC_USER)
963 ++userspace_samples;
989 ++samples; 964 ++samples;
990 return;
991 } 965 }
992} 966}
993 967