Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/perf: Export PERF_EVENT_CONFIG_EBB_SHIFT to userspace

We use bit 63 of the event code for userspace to request that the event
be counted using EBB (Event Based Branches). Export this value, making
it part of the API - though only on processors that support EBB.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Michael Ellerman and committed by
Benjamin Herrenschmidt
8d7c55d0 e8e813ed

+24 -9
+1 -5
arch/powerpc/include/asm/perf_event_server.h
··· 12 12 #include <linux/types.h> 13 13 #include <asm/hw_irq.h> 14 14 #include <linux/device.h> 15 + #include <uapi/asm/perf_event.h> 15 16 16 17 #define MAX_HWEVENTS 8 17 18 #define MAX_EVENT_ALTERNATIVES 8 ··· 69 68 #define PPMU_LIMITED_PMC_OK 1 /* can put this on a limited PMC */ 70 69 #define PPMU_LIMITED_PMC_REQD 2 /* have to put this on a limited PMC */ 71 70 #define PPMU_ONLY_COUNT_RUN 4 /* only counting in run state */ 72 - 73 - /* 74 - * We use the event config bit 63 as a flag to request EBB. 75 - */ 76 - #define EVENT_CONFIG_EBB_SHIFT 63 77 71 78 72 extern int register_power_pmu(struct power_pmu *); 79 73
+1
arch/powerpc/include/uapi/asm/Kbuild
··· 20 20 header-y += msgbuf.h 21 21 header-y += nvram.h 22 22 header-y += param.h 23 + header-y += perf_event.h 23 24 header-y += poll.h 24 25 header-y += posix_types.h 25 26 header-y += ps3fb.h
+18
arch/powerpc/include/uapi/asm/perf_event.h
··· 1 + /* 2 + * Copyright 2013 Michael Ellerman, IBM Corp. 3 + * 4 + * This program is free software; you can redistribute it and/or 5 + * modify it under the terms of the GNU General Public License 6 + * as published by the Free Software Foundation; version 2 of the 7 + * License. 8 + */ 9 + 10 + #ifndef _UAPI_ASM_POWERPC_PERF_EVENT_H 11 + #define _UAPI_ASM_POWERPC_PERF_EVENT_H 12 + 13 + /* 14 + * We use bit 63 of perf_event_attr.config as a flag to request EBB. 15 + */ 16 + #define PERF_EVENT_CONFIG_EBB_SHIFT 63 17 + 18 + #endif /* _UAPI_ASM_POWERPC_PERF_EVENT_H */
+1 -1
arch/powerpc/perf/core-book3s.c
··· 484 484 * use bit 63 of the event code for something else if they wish. 485 485 */ 486 486 return (ppmu->flags & PPMU_EBB) && 487 - ((event->attr.config >> EVENT_CONFIG_EBB_SHIFT) & 1); 487 + ((event->attr.config >> PERF_EVENT_CONFIG_EBB_SHIFT) & 1); 488 488 } 489 489 490 490 static int ebb_event_check(struct perf_event *event)
+3 -3
arch/powerpc/perf/power8-pmu.c
··· 118 118 (EVENT_UNIT_MASK << EVENT_UNIT_SHIFT) | \ 119 119 (EVENT_COMBINE_MASK << EVENT_COMBINE_SHIFT) | \ 120 120 (EVENT_MARKED_MASK << EVENT_MARKED_SHIFT) | \ 121 - (EVENT_EBB_MASK << EVENT_CONFIG_EBB_SHIFT) | \ 121 + (EVENT_EBB_MASK << PERF_EVENT_CONFIG_EBB_SHIFT) | \ 122 122 EVENT_PSEL_MASK) 123 123 124 124 /* MMCRA IFM bits - POWER8 */ ··· 233 233 pmc = (event >> EVENT_PMC_SHIFT) & EVENT_PMC_MASK; 234 234 unit = (event >> EVENT_UNIT_SHIFT) & EVENT_UNIT_MASK; 235 235 cache = (event >> EVENT_CACHE_SEL_SHIFT) & EVENT_CACHE_SEL_MASK; 236 - ebb = (event >> EVENT_CONFIG_EBB_SHIFT) & EVENT_EBB_MASK; 236 + ebb = (event >> PERF_EVENT_CONFIG_EBB_SHIFT) & EVENT_EBB_MASK; 237 237 238 238 /* Clear the EBB bit in the event, so event checks work below */ 239 - event &= ~(EVENT_EBB_MASK << EVENT_CONFIG_EBB_SHIFT); 239 + event &= ~(EVENT_EBB_MASK << PERF_EVENT_CONFIG_EBB_SHIFT); 240 240 241 241 if (pmc) { 242 242 if (pmc > 6)