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


Groups > linux.kernel > #1608732

Re: [PATCH v12 09/10] perf/amd/iommu: Introduce amd_iommu-specific struct in struct hw_perf_event

From Borislav Petkov <bp@alien8.de>
Newsgroups linux.kernel
Subject Re: [PATCH v12 09/10] perf/amd/iommu: Introduce amd_iommu-specific struct in struct hw_perf_event
Date 2017-03-24 19:00 +0100
Message-ID <toBFf-50v-3@gated-at.bofh.it> (permalink)
References <toBFf-50v-5@gated-at.bofh.it> <toBFf-50v-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Mar 22, 2017 at 02:02:41AM -0500, Suravee Suthikulpanit wrote:
> From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> 
> Current AMD IOMMU Perf PMU inappropriately uses hardware struct
> inside the union inside the struct hw_perf_event, mainly the use of
> extra_reg.
> 
> Instead, introduce amd_iommu-specific struct with required
> parameters to be programmed onto the IOMMU performance counter
> control register.
> 
> Also update the pasid field from 16 to 20 bits.
> 
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Borislav Petkov <bp@alien8.de>
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> ---
>  arch/x86/events/amd/iommu.c | 102 +++++++++++++++++++-------------------------
>  include/linux/perf_event.h  |   7 +++
>  2 files changed, 52 insertions(+), 57 deletions(-)
> 
> diff --git a/arch/x86/events/amd/iommu.c b/arch/x86/events/amd/iommu.c
> index 7ac8138..915a20c 100644
> --- a/arch/x86/events/amd/iommu.c
> +++ b/arch/x86/events/amd/iommu.c
> @@ -23,17 +23,16 @@
>  
>  #define COUNTER_SHIFT		16
>  
> -#define _GET_BANK(ev)       ((u8)(ev->hw.extra_reg.reg >> 8))
> -#define _GET_CNTR(ev)       ((u8)(ev->hw.extra_reg.reg))
> -
> -/* iommu pmu config masks */
> -#define _GET_CSOURCE(ev)    ((ev->hw.config & 0xFFULL))
> -#define _GET_DEVID(ev)      ((ev->hw.config >> 8)  & 0xFFFFULL)
> -#define _GET_PASID(ev)      ((ev->hw.config >> 24) & 0xFFFFULL)
> -#define _GET_DOMID(ev)      ((ev->hw.config >> 40) & 0xFFFFULL)
> -#define _GET_DEVID_MASK(ev) ((ev->hw.extra_reg.config)  & 0xFFFFULL)
> -#define _GET_PASID_MASK(ev) ((ev->hw.extra_reg.config >> 16) & 0xFFFFULL)
> -#define _GET_DOMID_MASK(ev) ((ev->hw.extra_reg.config >> 32) & 0xFFFFULL)
> +/* iommu pmu conf masks */
> +#define GET_CSOURCE(x)     (x->conf & 0xFFULL)

You need to prevent the macro arg from potentially wrong precedence
rules/multiple eval:

#define GET_CSOURCE(x)     ((x)->conf & 0xFFULL)
			    ^^^

I fixed them up when applying.

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

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


Thread

Re: [PATCH v12 09/10] perf/amd/iommu: Introduce amd_iommu-specific  struct in struct hw_perf_event Borislav Petkov <bp@alien8.de> - 2017-03-24 19:00 +0100

csiph-web