Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1476569 > unrolled thread

[PATCH] perf/x86/intel/cqm: Check cqm/mbm enabled state in event init

Started byJiri Olsa <jolsa@kernel.org>
First post2016-09-05 17:40 +0200
Last post2016-09-06 10:50 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] perf/x86/intel/cqm: Check cqm/mbm enabled state in event init Jiri Olsa <jolsa@kernel.org> - 2016-09-05 17:40 +0200
    Re: [PATCH] perf/x86/intel/cqm: Check cqm/mbm enabled state in event  init Peter Zijlstra <peterz@infradead.org> - 2016-09-06 10:20 +0200
    [tip:perf/urgent] perf/x86/intel/cqm: Check cqm/mbm enabled state  in event init tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-09-06 10:50 +0200

#1476569 — [PATCH] perf/x86/intel/cqm: Check cqm/mbm enabled state in event init

FromJiri Olsa <jolsa@kernel.org>
Date2016-09-05 17:40 +0200
Subject[PATCH] perf/x86/intel/cqm: Check cqm/mbm enabled state in event init
Message-ID<se4a6-5AV-11@gated-at.bofh.it>
Yanqiu Zhang reported kernel panic when using mbm event
on system where CQM is detected but without mbm event
support, like with perf:

  # perf stat -e 'intel_cqm/event=3/' -a

  BUG: unable to handle kernel NULL pointer dereference at 0000000000000020
  IP: [<ffffffff8100d64c>] update_sample+0xbc/0xe0
  ...
   <IRQ>
   [<ffffffff8100d688>] __intel_mbm_event_init+0x18/0x20
   [<ffffffff81113d6b>] flush_smp_call_function_queue+0x7b/0x160
   [<ffffffff81114853>] generic_smp_call_function_single_interrupt+0x13/0x60
   [<ffffffff81052017>] smp_call_function_interrupt+0x27/0x40
   [<ffffffff816fb06c>] call_function_interrupt+0x8c/0xa0
  ...

The reason is that we currently allow to init mbm event
even if mbm support is not detected.  Adding checks for
both cqm and mbm events and support into cqm's event_init.

Reported-by: Yanqiu Zhang <yanqzhan@redhat.com>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
---
 arch/x86/events/intel/cqm.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/x86/events/intel/cqm.c b/arch/x86/events/intel/cqm.c
index 783c49ddef29..8f82b02934fa 100644
--- a/arch/x86/events/intel/cqm.c
+++ b/arch/x86/events/intel/cqm.c
@@ -458,6 +458,11 @@ static void __intel_cqm_event_count(void *info);
 static void init_mbm_sample(u32 rmid, u32 evt_type);
 static void __intel_mbm_event_count(void *info);
 
+static bool is_cqm_event(int e)
+{
+	return (e == QOS_L3_OCCUP_EVENT_ID);
+}
+
 static bool is_mbm_event(int e)
 {
 	return (e >= QOS_MBM_TOTAL_EVENT_ID && e <= QOS_MBM_LOCAL_EVENT_ID);
@@ -1366,6 +1371,10 @@ static int intel_cqm_event_init(struct perf_event *event)
 	     (event->attr.config > QOS_MBM_LOCAL_EVENT_ID))
 		return -EINVAL;
 
+	if ((is_cqm_event(event->attr.config) && !cqm_enabled) ||
+	    (is_mbm_event(event->attr.config) && !mbm_enabled))
+		return -EINVAL;
+
 	/* unsupported modes and filters */
 	if (event->attr.exclude_user   ||
 	    event->attr.exclude_kernel ||
-- 
2.7.4

[toc] | [next] | [standalone]


#1477146 — Re: [PATCH] perf/x86/intel/cqm: Check cqm/mbm enabled state in event init

FromPeter Zijlstra <peterz@infradead.org>
Date2016-09-06 10:20 +0200
SubjectRe: [PATCH] perf/x86/intel/cqm: Check cqm/mbm enabled state in event init
Message-ID<sejLP-7Or-1@gated-at.bofh.it>
In reply to#1476569
On Mon, Sep 05, 2016 at 05:30:07PM +0200, Jiri Olsa wrote:
> Yanqiu Zhang reported kernel panic when using mbm event
> on system where CQM is detected but without mbm event
> support, like with perf:
> 
>   # perf stat -e 'intel_cqm/event=3/' -a
> 
>   BUG: unable to handle kernel NULL pointer dereference at 0000000000000020
>   IP: [<ffffffff8100d64c>] update_sample+0xbc/0xe0
>   ...
>    <IRQ>
>    [<ffffffff8100d688>] __intel_mbm_event_init+0x18/0x20
>    [<ffffffff81113d6b>] flush_smp_call_function_queue+0x7b/0x160
>    [<ffffffff81114853>] generic_smp_call_function_single_interrupt+0x13/0x60
>    [<ffffffff81052017>] smp_call_function_interrupt+0x27/0x40
>    [<ffffffff816fb06c>] call_function_interrupt+0x8c/0xa0
>   ...
> 
> The reason is that we currently allow to init mbm event
> even if mbm support is not detected.  Adding checks for
> both cqm and mbm events and support into cqm's event_init.
> 
> Reported-by: Yanqiu Zhang <yanqzhan@redhat.com>
> Signed-off-by: Jiri Olsa <jolsa@redhat.com>

Fixes: 33c3cc7acfd9 ("perf/x86/mbm: Add Intel Memory B/W Monitoring enumeration and init")

Cc: stable@vger.kernelo.org # 4.6+

[toc] | [prev] | [next] | [standalone]


#1477164 — [tip:perf/urgent] perf/x86/intel/cqm: Check cqm/mbm enabled state in event init

Fromtip-bot for Jiri Olsa <tipbot@zytor.com>
Date2016-09-06 10:50 +0200
Subject[tip:perf/urgent] perf/x86/intel/cqm: Check cqm/mbm enabled state in event init
Message-ID<sekeR-83f-5@gated-at.bofh.it>
In reply to#1476569
Commit-ID:  79d102cbfd2e9d94257fcc7c82807ef1cdf80322
Gitweb:     http://git.kernel.org/tip/79d102cbfd2e9d94257fcc7c82807ef1cdf80322
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 5 Sep 2016 17:30:07 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 6 Sep 2016 10:42:12 +0200

perf/x86/intel/cqm: Check cqm/mbm enabled state in event init

Yanqiu Zhang reported kernel panic when using mbm event
on system where CQM is detected but without mbm event
support, like with perf:

  # perf stat -e 'intel_cqm/event=3/' -a

  BUG: unable to handle kernel NULL pointer dereference at 0000000000000020
  IP: [<ffffffff8100d64c>] update_sample+0xbc/0xe0
  ...
   <IRQ>
   [<ffffffff8100d688>] __intel_mbm_event_init+0x18/0x20
   [<ffffffff81113d6b>] flush_smp_call_function_queue+0x7b/0x160
   [<ffffffff81114853>] generic_smp_call_function_single_interrupt+0x13/0x60
   [<ffffffff81052017>] smp_call_function_interrupt+0x27/0x40
   [<ffffffff816fb06c>] call_function_interrupt+0x8c/0xa0
  ...

The reason is that we currently allow to init mbm event
even if mbm support is not detected.  Adding checks for
both cqm and mbm events and support into cqm's event_init.

Fixes: 33c3cc7acfd9 ("perf/x86/mbm: Add Intel Memory B/W Monitoring enumeration and init")
Reported-by: Yanqiu Zhang <yanqzhan@redhat.com>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Vikas Shivappa <vikas.shivappa@linux.intel.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/1473089407-21857-1-git-send-email-jolsa@kernel.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/x86/events/intel/cqm.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/x86/events/intel/cqm.c b/arch/x86/events/intel/cqm.c
index 783c49d..8f82b02 100644
--- a/arch/x86/events/intel/cqm.c
+++ b/arch/x86/events/intel/cqm.c
@@ -458,6 +458,11 @@ static void __intel_cqm_event_count(void *info);
 static void init_mbm_sample(u32 rmid, u32 evt_type);
 static void __intel_mbm_event_count(void *info);
 
+static bool is_cqm_event(int e)
+{
+	return (e == QOS_L3_OCCUP_EVENT_ID);
+}
+
 static bool is_mbm_event(int e)
 {
 	return (e >= QOS_MBM_TOTAL_EVENT_ID && e <= QOS_MBM_LOCAL_EVENT_ID);
@@ -1366,6 +1371,10 @@ static int intel_cqm_event_init(struct perf_event *event)
 	     (event->attr.config > QOS_MBM_LOCAL_EVENT_ID))
 		return -EINVAL;
 
+	if ((is_cqm_event(event->attr.config) && !cqm_enabled) ||
+	    (is_mbm_event(event->attr.config) && !mbm_enabled))
+		return -EINVAL;
+
 	/* unsupported modes and filters */
 	if (event->attr.exclude_user   ||
 	    event->attr.exclude_kernel ||

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web