diff options
author | Mao Han <han_mao@c-sky.com> | 2019-06-04 06:54:49 -0400 |
---|---|---|
committer | Guo Ren <ren_guo@c-sky.com> | 2019-07-19 02:21:36 -0400 |
commit | d41435d9b2b3f8fb58dc1258220401ad16aa8a19 (patch) | |
tree | 540a4403883432901eb55b4ee166b281addeaa53 /arch/csky | |
parent | f622fbf205966a8e911f81a00db17997dd171404 (diff) |
csky: Fix perf record in kernel/user space
csky_pmu_event_init is called several times during the perf record
initialzation. After configure the event counter in either kernel
space or user space, csky_pmu_event_init is called twice with no
attr specified. Configuration will be overwritten with sampling in
both kernel space and user space. --all-kernel/--all-user is
useless without this patch applied.
Signed-off-by: Mao Han <han_mao@c-sky.com>
Signed-off-by: Guo Ren <guoren@kernel.org>
Diffstat (limited to 'arch/csky')
-rw-r--r-- | arch/csky/kernel/perf_event.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/arch/csky/kernel/perf_event.c b/arch/csky/kernel/perf_event.c index 7873306dec89..a61183a20829 100644 --- a/arch/csky/kernel/perf_event.c +++ b/arch/csky/kernel/perf_event.c | |||
@@ -922,15 +922,6 @@ static int csky_pmu_event_init(struct perf_event *event) | |||
922 | struct hw_perf_event *hwc = &event->hw; | 922 | struct hw_perf_event *hwc = &event->hw; |
923 | int ret; | 923 | int ret; |
924 | 924 | ||
925 | if (event->attr.exclude_user) | ||
926 | csky_pmu.hpcr = BIT(2); | ||
927 | else if (event->attr.exclude_kernel) | ||
928 | csky_pmu.hpcr = BIT(3); | ||
929 | else | ||
930 | csky_pmu.hpcr = BIT(2) | BIT(3); | ||
931 | |||
932 | csky_pmu.hpcr |= BIT(1) | BIT(0); | ||
933 | |||
934 | switch (event->attr.type) { | 925 | switch (event->attr.type) { |
935 | case PERF_TYPE_HARDWARE: | 926 | case PERF_TYPE_HARDWARE: |
936 | if (event->attr.config >= PERF_COUNT_HW_MAX) | 927 | if (event->attr.config >= PERF_COUNT_HW_MAX) |
@@ -939,21 +930,32 @@ static int csky_pmu_event_init(struct perf_event *event) | |||
939 | if (ret == HW_OP_UNSUPPORTED) | 930 | if (ret == HW_OP_UNSUPPORTED) |
940 | return -ENOENT; | 931 | return -ENOENT; |
941 | hwc->idx = ret; | 932 | hwc->idx = ret; |
942 | return 0; | 933 | break; |
943 | case PERF_TYPE_HW_CACHE: | 934 | case PERF_TYPE_HW_CACHE: |
944 | ret = csky_pmu_cache_event(event->attr.config); | 935 | ret = csky_pmu_cache_event(event->attr.config); |
945 | if (ret == CACHE_OP_UNSUPPORTED) | 936 | if (ret == CACHE_OP_UNSUPPORTED) |
946 | return -ENOENT; | 937 | return -ENOENT; |
947 | hwc->idx = ret; | 938 | hwc->idx = ret; |
948 | return 0; | 939 | break; |
949 | case PERF_TYPE_RAW: | 940 | case PERF_TYPE_RAW: |
950 | if (hw_raw_read_mapping[event->attr.config] == NULL) | 941 | if (hw_raw_read_mapping[event->attr.config] == NULL) |
951 | return -ENOENT; | 942 | return -ENOENT; |
952 | hwc->idx = event->attr.config; | 943 | hwc->idx = event->attr.config; |
953 | return 0; | 944 | break; |
954 | default: | 945 | default: |
955 | return -ENOENT; | 946 | return -ENOENT; |
956 | } | 947 | } |
948 | |||
949 | if (event->attr.exclude_user) | ||
950 | csky_pmu.hpcr = BIT(2); | ||
951 | else if (event->attr.exclude_kernel) | ||
952 | csky_pmu.hpcr = BIT(3); | ||
953 | else | ||
954 | csky_pmu.hpcr = BIT(2) | BIT(3); | ||
955 | |||
956 | csky_pmu.hpcr |= BIT(1) | BIT(0); | ||
957 | |||
958 | return 0; | ||
957 | } | 959 | } |
958 | 960 | ||
959 | /* starts all counters */ | 961 | /* starts all counters */ |