lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fdb736aa-3c2a-67d3-473f-b5a2a7d2c0e5@intel.com>
Date:   Mon, 17 Sep 2018 09:37:14 -0700
From:   Reinette Chatre <reinette.chatre@...el.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     tglx@...utronix.de, fenghua.yu@...el.com, tony.luck@...el.com,
        mingo@...hat.com, acme@...nel.org, gavin.hindman@...el.com,
        jithu.joseph@...el.com, dave.hansen@...el.com, hpa@...or.com,
        x86@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH V3 2/6] perf/core: Add helper to obtain performance
 counter index

Hi Peter,

On 9/17/2018 1:23 AM, Peter Zijlstra wrote:
> On Tue, Sep 11, 2018 at 10:14:33AM -0700, Reinette Chatre wrote:
>> diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
>> index 53c500f0ca79..c04dc666425c 100644
>> --- a/include/linux/perf_event.h
>> +++ b/include/linux/perf_event.h
>> @@ -1025,6 +1025,27 @@ static inline int in_software_context(struct perf_event *event)
>>  	return event->ctx->pmu->task_ctx_nr == perf_sw_context;
>>  }
>>  
>> +/**
>> + * perf_rdpmc_index - Return PMC counter used for event
>> + * @event: the perf_event to which the PMC counter was assigned
>> + *
>> + * The counter assigned to this performance event may change if interrupts
>> + * are enabled. This counter should thus never be used while interrupts are
>> + * enabled. Before this function is used to obtain the assigned counter the
>> + * event could be checked for validity using, for example,
>> + * perf_event_read_local(), within the same interrupt disabled section in
>> + * which this counter is planned to be used.
>> + *
>> + * Return: The index of the performance monitoring counter assigned to
>> + * @perf_event.
>> + */
>> +static inline int perf_rdpmc_index(struct perf_event *event)
>> +{
>> +	lockdep_assert_irqs_disabled();
>> +
>> +	return event->hw.event_base_rdpmc;
>> +}
> 
> I said arch/x86/include/asm/perf_events.h and call it:
> x86_perf_rdpmc_index().
> 
> This function is very much x86 specific.
> 

My response to your original request includes the reason why I made this
change instead. Since you did not reply I assumed that you agreed with
the conclusion and I proceeded with my proposal there:
http://lkml.kernel.org/r/f47a2146-2f1a-49fc-2306-3341154f1186@intel.com

The reason why I made this change is repeated in the cover letter of
this series:
http://lkml.kernel.org/r/cover.1536685533.git.reinette.chatre@intel.com

My original response is copied here for your convenience:
Hi Peter,

On 9/6/2018 7:47 AM, Peter Zijlstra wrote:
> On Thu, Aug 16, 2018 at 01:16:07PM -0700, Reinette Chatre wrote:
>
>> +static inline int x86_perf_rdpmc_ctr_get(struct perf_event *event)
>> +{
>> +	lockdep_assert_irqs_disabled();
>> +
>> +	return IS_ERR_OR_NULL(event) ? -1 : event->hw.event_base_rdpmc;
>> +}
>
> That should be in arch/x86/include/asm/perf_event.h if anywhere. Also,
> call the thing x86_perf_rdpmc_index(), that's consistent with the other
> naming.

Moving it to arch/x86/include/asm/perf_event.h is not trivial since this
file is not familiar with struct perf_event.

struct perf_event, struct hw_perf_event and its member event_base_rdpmc
are all defined in include/linux/perf_event.h - could this function
perhaps be moved there? If so, would perf_rdpmc_index() perhaps be a
better name to be consistent with the other naming?

>
> I don't think there's any point in testing for !event, this is an
> interface that mandates you know wth you're doing anyway.
>

I could add:
/* !CONFIG_PERF_EVENTS */
static inline int perf_rdpmc_index(struct perf_event *event)
{
        return -1;
}

Reinette

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ