[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <37D7C6CF3E00A74B8858931C1DB2F077058A7665@SHSMSX103.ccr.corp.intel.com>
Date: Mon, 21 Mar 2016 14:19:27 +0000
From: "Liang, Kan" <kan.liang@...el.com>
To: Thomas Gleixner <tglx@...utronix.de>,
LKML <linux-kernel@...r.kernel.org>
CC: Peter Zijlstra <peterz@...radead.org>,
"x86@...nel.org" <x86@...nel.org>,
Stephane Eranian <eranian@...gle.com>,
Borislav Petkov <bp@...e.de>,
"Andi Kleen (ak@...ux.intel.com)" <ak@...ux.intel.com>
Subject: RE: [patch 2/4] x86/perf/intel/cstate: Sanitize probing
> /*
> * Probe the cstate events and insert the available one into sysfs attrs
> - * Return false if there is no available events.
> + * Return false if there are no available events.
> */
> -static bool cstate_probe_msr(struct perf_cstate_msr *msr,
> - struct attribute **events_attrs,
> - int max_event_nr)
> +static bool __init cstate_probe_msr(const unsigned long evmsk,
> + struct perf_cstate_msr *msr,
> + struct attribute **attrs)
> {
> - int i, j = 0;
> + bool found = false;
> + unsigned int bit;
> u64 val;
>
> - /* Probe the cstate events. */
> - for (i = 0; i < max_event_nr; i++) {
> - if (!msr[i].test(i) || rdmsrl_safe(msr[i].msr, &val))
> - msr[i].attr = NULL;
> - }
I think we need to update msr[i].attr as well.
Because in cstate_pmu_event_init we still need it to do check.
Thanks,
Kan
> -
> - /* List remaining events in the sysfs attrs. */
> - for (i = 0; i < max_event_nr; i++) {
> - if (msr[i].attr)
> - events_attrs[j++] = &msr[i].attr->attr.attr;
> + for_each_set_bit(bit, &evmsk, sizeof(evmsk) * BITS_PER_BYTE) {
> + /* Verify whether the MSR is accessible */
> + if (!rdmsrl_safe(msr[bit].msr, &val)) {
> + *attrs++ = &msr[bit].attr->attr.attr;
> + found = true;
> + }
> }
> - events_attrs[j] = NULL;
> -
> - return (j > 0) ? true : false;
> + *attrs = NULL;
> + return found;
> }
>
Powered by blists - more mailing lists