Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754212AbdCMTW3 (ORCPT ); Mon, 13 Mar 2017 15:22:29 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:50486 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752834AbdCMTV7 (ORCPT ); Mon, 13 Mar 2017 15:21:59 -0400 Date: Mon, 13 Mar 2017 12:21:51 -0700 From: Sukadev Bhattiprolu To: Madhavan Srinivasan Cc: peterz@infradead.org, mpe@ellerman.id.au, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Benjamin Herrenschmidt , Paul Mackerras , Thomas Gleixner , Sebastian Andrzej Siewior , Anna-Maria Gleixner , Daniel Axtens Subject: Re: [PATCH v2 2/6] powerpc/perf: Export memory hierarchy info to user space References: <1488796993-25495-1-git-send-email-maddy@linux.vnet.ibm.com> <1488796993-25495-3-git-send-email-maddy@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1488796993-25495-3-git-send-email-maddy@linux.vnet.ibm.com> X-Operating-System: Linux 2.0.32 on an i486 User-Agent: Mutt/1.7.1 (2016-10-04) X-TM-AS-GCONF: 00 x-cbid: 17031319-0044-0000-0000-000002CDF8A4 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006776; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000206; SDB=6.00833335; UDB=6.00409123; IPR=6.00610993; BA=6.00005207; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014633; XFM=3.00000013; UTC=2017-03-13 19:21:56 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17031319-0045-0000-0000-000006FC15D9 Message-Id: <20170313192151.GA3420@us.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-03-13_13:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703130150 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2008 Lines: 57 Madhavan Srinivasan [maddy@linux.vnet.ibm.com] wrote: > The LDST field and DATA_SRC in SIER identifies the memory hierarchy level > (eg: L1, L2 etc), from which a data-cache miss for a marked instruction > was satisfied. Use the 'perf_mem_data_src' object to export this > hierarchy level to user space. > > diff --git a/arch/powerpc/include/asm/perf_event_server.h b/arch/powerpc/include/asm/perf_event_server.h > int isa207_get_constraint(u64 event, unsigned long *maskp, unsigned long *valp) > { > unsigned int unit, pmc, cache, ebb; > diff --git a/arch/powerpc/perf/isa207-common.h b/arch/powerpc/perf/isa207-common.h > index cf9bd8990159..982542cce991 100644 > --- a/arch/powerpc/perf/isa207-common.h > +++ b/arch/powerpc/perf/isa207-common.h > @@ -259,6 +259,19 @@ > #define MAX_ALT 2 > #define MAX_PMU_COUNTERS 6 > > +#define ISA207_SIER_TYPE_SHIFT 15 > +#define ISA207_SIER_TYPE_MASK (0x7ull << ISA207_SIER_TYPE_SHIFT) > + > +#define ISA207_SIER_LDST_SHIFT 1 > +#define ISA207_SIER_LDST_MASK (0x7ull << ISA207_SIER_LDST_SHIFT) > + > +#define ISA207_SIER_DATA_SRC_SHIFT 53 > +#define ISA207_SIER_DATA_SRC_MASK (0x7ull << ISA207_SIER_DATA_SRC_SHIFT) > + > +#define P(a, b) PERF_MEM_S(a, b) Madhavan, Peter, Can we see if we can get the kernel to set 'perf_mem_data_src.val' in endian-nuetral format? With something like (untested) in include/uapi/linux/perf_event.h #define PERF_MEM_OP_NBITS PERF_MEM_LVL_SHIFT #define PERF_MEM_LVL_NBITS PERF_MEM_SNOOP_SHIFT #define PERF_MEM_SNOOP_NBITS PERF_MEM_LOCK_SHIFT #define PERF_MEM_TLB_NBITS PERF_MEM_TLB_SHIFT and here in arch/powerpc/perf/isa207-common.h #define PERF_MEM_S_BE_SHIFT(a) \ (63 - PERF_MEM_##a##_NBITS - PERF_MEM_##a##_SHIFT) #define PERF_MEM_S_BE(a, s) \ (((__u64)PERF_MEM_##a##_##s) << PERF_MEM_S_BE_SHIFT(a)) #define P(a, b) PERF_MEM_S_BE(a, b) Basically, have PERF_MEM_OP_NA be the right most bit and PERF_MEM_TLB_OS the left most bit in perf_mem_data_src.val regardless of the endianness? Sukadev