diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-06-10 14:15:41 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-06-10 14:15:41 -0400 |
commit | 7fcbc230c6f0ee96d397e30d061ef4995879b835 (patch) | |
tree | 38184f592766a629e8854ddb89ac6862bc80c2ef | |
parent | 02b07bde619e179bf7ac0e073d28e2e038dfab77 (diff) | |
parent | 62a92c8f553e49270a0ee391b8733da71ab0aebc (diff) |
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes from Ingo Molnar:
"A handful of tooling fixes, two PMU driver fixes and a cleanup of
redundant code that addresses a security analyzer false positive"
* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
perf/core: Remove a redundant check
perf/x86/intel/uncore: Remove SBOX support for Broadwell server
perf ctf: Convert invalid chars in a string before set value
perf record: Fix crash when kptr is restricted
perf symbols: Check kptr_restrict for root
perf/x86/intel/rapl: Fix pmus free during cleanup
-rw-r--r-- | arch/x86/events/intel/rapl.c | 2 | ||||
-rw-r--r-- | arch/x86/events/intel/uncore_snbep.c | 21 | ||||
-rw-r--r-- | kernel/events/core.c | 6 | ||||
-rw-r--r-- | tools/perf/util/data-convert-bt.c | 41 | ||||
-rw-r--r-- | tools/perf/util/event.c | 2 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 16 |
6 files changed, 52 insertions, 36 deletions
diff --git a/arch/x86/events/intel/rapl.c b/arch/x86/events/intel/rapl.c index 99c4bab123cd..e30eef4f29a6 100644 --- a/arch/x86/events/intel/rapl.c +++ b/arch/x86/events/intel/rapl.c | |||
@@ -714,7 +714,7 @@ static void cleanup_rapl_pmus(void) | |||
714 | int i; | 714 | int i; |
715 | 715 | ||
716 | for (i = 0; i < rapl_pmus->maxpkg; i++) | 716 | for (i = 0; i < rapl_pmus->maxpkg; i++) |
717 | kfree(rapl_pmus->pmus + i); | 717 | kfree(rapl_pmus->pmus[i]); |
718 | kfree(rapl_pmus); | 718 | kfree(rapl_pmus); |
719 | } | 719 | } |
720 | 720 | ||
diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index b2625867ebd1..874e8bd64d1d 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c | |||
@@ -2868,27 +2868,10 @@ static struct intel_uncore_type bdx_uncore_cbox = { | |||
2868 | .format_group = &hswep_uncore_cbox_format_group, | 2868 | .format_group = &hswep_uncore_cbox_format_group, |
2869 | }; | 2869 | }; |
2870 | 2870 | ||
2871 | static struct intel_uncore_type bdx_uncore_sbox = { | ||
2872 | .name = "sbox", | ||
2873 | .num_counters = 4, | ||
2874 | .num_boxes = 4, | ||
2875 | .perf_ctr_bits = 48, | ||
2876 | .event_ctl = HSWEP_S0_MSR_PMON_CTL0, | ||
2877 | .perf_ctr = HSWEP_S0_MSR_PMON_CTR0, | ||
2878 | .event_mask = HSWEP_S_MSR_PMON_RAW_EVENT_MASK, | ||
2879 | .box_ctl = HSWEP_S0_MSR_PMON_BOX_CTL, | ||
2880 | .msr_offset = HSWEP_SBOX_MSR_OFFSET, | ||
2881 | .ops = &hswep_uncore_sbox_msr_ops, | ||
2882 | .format_group = &hswep_uncore_sbox_format_group, | ||
2883 | }; | ||
2884 | |||
2885 | #define BDX_MSR_UNCORE_SBOX 3 | ||
2886 | |||
2887 | static struct intel_uncore_type *bdx_msr_uncores[] = { | 2871 | static struct intel_uncore_type *bdx_msr_uncores[] = { |
2888 | &bdx_uncore_ubox, | 2872 | &bdx_uncore_ubox, |
2889 | &bdx_uncore_cbox, | 2873 | &bdx_uncore_cbox, |
2890 | &hswep_uncore_pcu, | 2874 | &hswep_uncore_pcu, |
2891 | &bdx_uncore_sbox, | ||
2892 | NULL, | 2875 | NULL, |
2893 | }; | 2876 | }; |
2894 | 2877 | ||
@@ -2897,10 +2880,6 @@ void bdx_uncore_cpu_init(void) | |||
2897 | if (bdx_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores) | 2880 | if (bdx_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores) |
2898 | bdx_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores; | 2881 | bdx_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores; |
2899 | uncore_msr_uncores = bdx_msr_uncores; | 2882 | uncore_msr_uncores = bdx_msr_uncores; |
2900 | |||
2901 | /* BDX-DE doesn't have SBOX */ | ||
2902 | if (boot_cpu_data.x86_model == 86) | ||
2903 | uncore_msr_uncores[BDX_MSR_UNCORE_SBOX] = NULL; | ||
2904 | } | 2883 | } |
2905 | 2884 | ||
2906 | static struct intel_uncore_type bdx_uncore_ha = { | 2885 | static struct intel_uncore_type bdx_uncore_ha = { |
diff --git a/kernel/events/core.c b/kernel/events/core.c index 274450efea90..9c51ec3f0f44 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -3862,10 +3862,8 @@ static void _free_event(struct perf_event *event) | |||
3862 | if (event->ctx) | 3862 | if (event->ctx) |
3863 | put_ctx(event->ctx); | 3863 | put_ctx(event->ctx); |
3864 | 3864 | ||
3865 | if (event->pmu) { | 3865 | exclusive_event_destroy(event); |
3866 | exclusive_event_destroy(event); | 3866 | module_put(event->pmu->module); |
3867 | module_put(event->pmu->module); | ||
3868 | } | ||
3869 | 3867 | ||
3870 | call_rcu(&event->rcu_head, free_event_rcu); | 3868 | call_rcu(&event->rcu_head, free_event_rcu); |
3871 | } | 3869 | } |
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c index bbf69d248ec5..9f53020c3269 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c | |||
@@ -204,6 +204,44 @@ static unsigned long long adjust_signedness(unsigned long long value_int, int si | |||
204 | return (value_int & value_mask) | ~value_mask; | 204 | return (value_int & value_mask) | ~value_mask; |
205 | } | 205 | } |
206 | 206 | ||
207 | static int string_set_value(struct bt_ctf_field *field, const char *string) | ||
208 | { | ||
209 | char *buffer = NULL; | ||
210 | size_t len = strlen(string), i, p; | ||
211 | int err; | ||
212 | |||
213 | for (i = p = 0; i < len; i++, p++) { | ||
214 | if (isprint(string[i])) { | ||
215 | if (!buffer) | ||
216 | continue; | ||
217 | buffer[p] = string[i]; | ||
218 | } else { | ||
219 | char numstr[5]; | ||
220 | |||
221 | snprintf(numstr, sizeof(numstr), "\\x%02x", | ||
222 | (unsigned int)(string[i]) & 0xff); | ||
223 | |||
224 | if (!buffer) { | ||
225 | buffer = zalloc(i + (len - i) * 4 + 2); | ||
226 | if (!buffer) { | ||
227 | pr_err("failed to set unprintable string '%s'\n", string); | ||
228 | return bt_ctf_field_string_set_value(field, "UNPRINTABLE-STRING"); | ||
229 | } | ||
230 | if (i > 0) | ||
231 | strncpy(buffer, string, i); | ||
232 | } | ||
233 | strncat(buffer + p, numstr, 4); | ||
234 | p += 3; | ||
235 | } | ||
236 | } | ||
237 | |||
238 | if (!buffer) | ||
239 | return bt_ctf_field_string_set_value(field, string); | ||
240 | err = bt_ctf_field_string_set_value(field, buffer); | ||
241 | free(buffer); | ||
242 | return err; | ||
243 | } | ||
244 | |||
207 | static int add_tracepoint_field_value(struct ctf_writer *cw, | 245 | static int add_tracepoint_field_value(struct ctf_writer *cw, |
208 | struct bt_ctf_event_class *event_class, | 246 | struct bt_ctf_event_class *event_class, |
209 | struct bt_ctf_event *event, | 247 | struct bt_ctf_event *event, |
@@ -270,8 +308,7 @@ static int add_tracepoint_field_value(struct ctf_writer *cw, | |||
270 | } | 308 | } |
271 | 309 | ||
272 | if (flags & FIELD_IS_STRING) | 310 | if (flags & FIELD_IS_STRING) |
273 | ret = bt_ctf_field_string_set_value(field, | 311 | ret = string_set_value(field, data + offset + i * len); |
274 | data + offset + i * len); | ||
275 | else { | 312 | else { |
276 | unsigned long long value_int; | 313 | unsigned long long value_int; |
277 | 314 | ||
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index f6fcc6832949..9b141f12329e 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -673,6 +673,8 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, | |||
673 | int err; | 673 | int err; |
674 | union perf_event *event; | 674 | union perf_event *event; |
675 | 675 | ||
676 | if (symbol_conf.kptr_restrict) | ||
677 | return -1; | ||
676 | if (map == NULL) | 678 | if (map == NULL) |
677 | return -1; | 679 | return -1; |
678 | 680 | ||
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 20f9cb32b703..54c4ff2b1cee 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -1933,17 +1933,17 @@ int setup_intlist(struct intlist **list, const char *list_str, | |||
1933 | static bool symbol__read_kptr_restrict(void) | 1933 | static bool symbol__read_kptr_restrict(void) |
1934 | { | 1934 | { |
1935 | bool value = false; | 1935 | bool value = false; |
1936 | FILE *fp = fopen("/proc/sys/kernel/kptr_restrict", "r"); | ||
1936 | 1937 | ||
1937 | if (geteuid() != 0) { | 1938 | if (fp != NULL) { |
1938 | FILE *fp = fopen("/proc/sys/kernel/kptr_restrict", "r"); | 1939 | char line[8]; |
1939 | if (fp != NULL) { | ||
1940 | char line[8]; | ||
1941 | 1940 | ||
1942 | if (fgets(line, sizeof(line), fp) != NULL) | 1941 | if (fgets(line, sizeof(line), fp) != NULL) |
1943 | value = atoi(line) != 0; | 1942 | value = (geteuid() != 0) ? |
1943 | (atoi(line) != 0) : | ||
1944 | (atoi(line) == 2); | ||
1944 | 1945 | ||
1945 | fclose(fp); | 1946 | fclose(fp); |
1946 | } | ||
1947 | } | 1947 | } |
1948 | 1948 | ||
1949 | return value; | 1949 | return value; |