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


Groups > linux.kernel > #1199972

Re: [tip:perf/core] perf/x86: Add an MSR PMU driver

From Andy Lutomirski <luto@amacapital.net>
Newsgroups linux.kernel
Subject Re: [tip:perf/core] perf/x86: Add an MSR PMU driver
Date 2015-08-04 17:00 +0200
Message-ID <pTLRa-5hl-43@gated-at.bofh.it> (permalink)
References <pOsm6-7eJ-19@gated-at.bofh.it> <pTGoq-60Z-37@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Aug 4, 2015 at 2:01 AM, tip-bot for Andy Lutomirski
<tipbot@zytor.com> wrote:
> Commit-ID:  b7b7c7821d932ba18ef6c8eafc8536066b4c2ef4
> Gitweb:     http://git.kernel.org/tip/b7b7c7821d932ba18ef6c8eafc8536066b4c2ef4
> Author:     Andy Lutomirski <luto@kernel.org>

I think I'm slightly late to the party reviewing what appears to be my
own code :)

> --- /dev/null
> +++ b/arch/x86/kernel/cpu/perf_event_msr.c
> @@ -0,0 +1,242 @@
> +#include <linux/perf_event.h>
> +
> +enum perf_msr_id {
> +       PERF_MSR_TSC                    = 0,
> +       PERF_MSR_APERF                  = 1,
> +       PERF_MSR_MPERF                  = 2,
> +       PERF_MSR_PPERF                  = 3,
> +       PERF_MSR_SMI                    = 4,
> +
> +       PERF_MSR_EVENT_MAX,
> +};
> +
> +struct perf_msr {
> +       int     id;
> +       u64     msr;
> +};
> +
> +static struct perf_msr msr[] = {
> +       { PERF_MSR_TSC, 0 },
> +       { PERF_MSR_APERF, MSR_IA32_APERF },
> +       { PERF_MSR_MPERF, MSR_IA32_MPERF },
> +       { PERF_MSR_PPERF, MSR_PPERF },
> +       { PERF_MSR_SMI, MSR_SMI_COUNT },
> +};

I think this could be easier to work with if it were [PERF_MSR_TSC] =
{...}, etc.  No big deal, though, until the list gets long.  However,
it might make fixing the apparent issue below easier...

> +static int msr_event_init(struct perf_event *event)
> +{
> +       u64 cfg = event->attr.config;

...

> +       event->hw.event_base = msr[cfg].msr;

Shouldn't this verify that the fancy enumeration code actually
believes that msr[cfg] exists on this system?  Otherwise we might have
a very short wait until the perf fuzzer oopses this thing :)

--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[tip:perf/core] perf/x86: Add an MSR PMU driver tip-bot for Andy Lutomirski <tipbot@zytor.com> - 2015-08-04 11:10 +0200
  Re: [tip:perf/core] perf/x86: Add an MSR PMU driver Andy Lutomirski <luto@amacapital.net> - 2015-08-04 17:00 +0200
    RE: [tip:perf/core] perf/x86: Add an MSR PMU driver "Liang, Kan" <kan.liang@intel.com> - 2015-08-04 17:10 +0200
      Re: [tip:perf/core] perf/x86: Add an MSR PMU driver Andy Lutomirski <luto@amacapital.net> - 2015-08-04 20:10 +0200
        RE: [tip:perf/core] perf/x86: Add an MSR PMU driver "Liang, Kan" <kan.liang@intel.com> - 2015-08-04 20:20 +0200
          Re: [tip:perf/core] perf/x86: Add an MSR PMU driver Andy Lutomirski <luto@amacapital.net> - 2015-08-04 20:20 +0200
            RE: [tip:perf/core] perf/x86: Add an MSR PMU driver "Liang, Kan" <kan.liang@intel.com> - 2015-08-04 23:00 +0200
              Re: [tip:perf/core] perf/x86: Add an MSR PMU driver Peter Zijlstra <peterz@infradead.org> - 2015-08-06 17:30 +0200
                Re: [tip:perf/core] perf/x86: Add an MSR PMU driver Andy Lutomirski <luto@amacapital.net> - 2015-08-06 17:40 +0200
                Re: [tip:perf/core] perf/x86: Add an MSR PMU driver Peter Zijlstra <peterz@infradead.org> - 2015-08-06 18:00 +0200
                Re: [tip:perf/core] perf/x86: Add an MSR PMU driver Peter Zijlstra <peterz@infradead.org> - 2015-08-07 10:40 +0200
                Re: [tip:perf/core] perf/x86: Add an MSR PMU driver Andy Lutomirski <luto@amacapital.net> - 2015-08-10 04:20 +0200
                RE: [tip:perf/core] perf/x86: Add an MSR PMU driver "Liang, Kan" <kan.liang@intel.com> - 2015-08-10 16:10 +0200
                Re: [tip:perf/core] perf/x86: Add an MSR PMU driver Peter Zijlstra <peterz@infradead.org> - 2015-08-10 16:30 +0200
                RE: [tip:perf/core] perf/x86: Add an MSR PMU driver "Liang, Kan" <kan.liang@intel.com> - 2015-08-06 19:50 +0200
  Re: [tip:perf/core] perf/x86: Add an MSR PMU driver Jiri Olsa <jolsa@redhat.com> - 2015-08-10 13:20 +0200
    Re: [tip:perf/core] perf/x86: Add an MSR PMU driver Peter Zijlstra <peterz@infradead.org> - 2015-08-10 13:50 +0200

csiph-web