linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [V5 0/4] perf: New conditional branch filter
@ 2014-03-07  9:06 Anshuman Khandual
  2014-03-07  9:06 ` [V5 1/4] perf: Add PERF_SAMPLE_BRANCH_COND Anshuman Khandual
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Anshuman Khandual @ 2014-03-07  9:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Anshuman Khandual, Stephane Eranian, Andi Kleen, Ingo Molnar,
	Benjamin Herrenschmidt, Michael Ellerman, Peter Zijlstra

Hello Arnaldo,

	I had posted the V5 version of PowerPC SW branch filter enablement
patchset last month. Please find the patchset here at

	https://lkml.org/lkml/2014/2/5/79

These following patches (2,4,5,6 patches from the original V5 version patchset)
are the ones which change code in the generic kernel, perf tool and X86 perf.
Basically this patchset adds one more branch filter for "conditional" branches.
In X86 code, this new filter has been implemented with the help of availble SW
filter X86_BR_JCC and LBR_JCC. We had some discussions in this regard before.
Please review these changes and if it's okay, please merge them. Other patches
in the series are powerpc specific and are being reviewed by Benjamin Herrenschmidt
and Michael Ellerman. Let me know if you need more information.

[1] https://lkml.org/lkml/2013/5/22/51
[2] https://lkml.org/lkml/2013/8/30/10
[3] https://lkml.org/lkml/2013/10/16/75
[4] https://lkml.org/lkml/2013/12/4/168
[5] https://lkml.org/lkml/2014/2/5/79

c: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Stephane Eranian <eranian@google.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Michael Ellerman <michael@ellerman.id.au>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>

Anshuman Khandual (4):
  perf: Add PERF_SAMPLE_BRANCH_COND
  perf, tool: Conditional branch filter 'cond' added to perf record
  x86, perf: Add conditional branch filtering support
  perf, documentation: Description for conditional branch filter

 arch/x86/kernel/cpu/perf_event_intel_lbr.c | 5 +++++
 include/uapi/linux/perf_event.h            | 3 ++-
 tools/perf/Documentation/perf-record.txt   | 3 ++-
 tools/perf/builtin-record.c                | 1 +
 4 files changed, 10 insertions(+), 2 deletions(-)

-- 
1.7.11.7


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [V5 1/4] perf: Add PERF_SAMPLE_BRANCH_COND
  2014-03-07  9:06 [V5 0/4] perf: New conditional branch filter Anshuman Khandual
@ 2014-03-07  9:06 ` Anshuman Khandual
  2014-03-07  9:06 ` [V5 2/4] perf, tool: Conditional branch filter 'cond' added to perf record Anshuman Khandual
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Anshuman Khandual @ 2014-03-07  9:06 UTC (permalink / raw)
  To: linux-kernel; +Cc: Anshuman Khandual

This patch introduces new branch filter PERF_SAMPLE_BRANCH_COND which
will extend the existing perf ABI. Various architectures can provide
this functionality with either with HW filtering support (if present)
or with SW filtering of captured branch instructions.

Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
Reviewed-by: Stephane Eranian <eranian@google.com>
---
 include/uapi/linux/perf_event.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index 853bc1c..696f69b4 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -163,8 +163,9 @@ enum perf_branch_sample_type {
 	PERF_SAMPLE_BRANCH_ABORT_TX	= 1U << 7, /* transaction aborts */
 	PERF_SAMPLE_BRANCH_IN_TX	= 1U << 8, /* in transaction */
 	PERF_SAMPLE_BRANCH_NO_TX	= 1U << 9, /* not in transaction */
+	PERF_SAMPLE_BRANCH_COND		= 1U << 10, /* conditional branches */
 
-	PERF_SAMPLE_BRANCH_MAX		= 1U << 10, /* non-ABI */
+	PERF_SAMPLE_BRANCH_MAX		= 1U << 11, /* non-ABI */
 };
 
 #define PERF_SAMPLE_BRANCH_PLM_ALL \
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [V5 2/4] perf, tool: Conditional branch filter 'cond' added to perf record
  2014-03-07  9:06 [V5 0/4] perf: New conditional branch filter Anshuman Khandual
  2014-03-07  9:06 ` [V5 1/4] perf: Add PERF_SAMPLE_BRANCH_COND Anshuman Khandual
@ 2014-03-07  9:06 ` Anshuman Khandual
  2014-03-07  9:06 ` [V5 3/4] x86, perf: Add conditional branch filtering support Anshuman Khandual
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Anshuman Khandual @ 2014-03-07  9:06 UTC (permalink / raw)
  To: linux-kernel; +Cc: Anshuman Khandual

Adding perf record support for new branch stack filter criteria
PERF_SAMPLE_BRANCH_COND.

Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
Reviewed-by: Stephane Eranian <eranian@google.com>
---
 tools/perf/builtin-record.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 3c394bf..eb74bcd 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -589,6 +589,7 @@ static const struct branch_mode branch_modes[] = {
 	BRANCH_OPT("abort_tx", PERF_SAMPLE_BRANCH_ABORT_TX),
 	BRANCH_OPT("in_tx", PERF_SAMPLE_BRANCH_IN_TX),
 	BRANCH_OPT("no_tx", PERF_SAMPLE_BRANCH_NO_TX),
+	BRANCH_OPT("cond", PERF_SAMPLE_BRANCH_COND),
 	BRANCH_END
 };
 
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [V5 3/4] x86, perf: Add conditional branch filtering support
  2014-03-07  9:06 [V5 0/4] perf: New conditional branch filter Anshuman Khandual
  2014-03-07  9:06 ` [V5 1/4] perf: Add PERF_SAMPLE_BRANCH_COND Anshuman Khandual
  2014-03-07  9:06 ` [V5 2/4] perf, tool: Conditional branch filter 'cond' added to perf record Anshuman Khandual
@ 2014-03-07  9:06 ` Anshuman Khandual
  2014-03-07  9:06 ` [V5 4/4] perf, documentation: Description for conditional branch filter Anshuman Khandual
  2014-03-25 14:52 ` [V5 0/4] perf: New " Anshuman Khandual
  4 siblings, 0 replies; 10+ messages in thread
From: Anshuman Khandual @ 2014-03-07  9:06 UTC (permalink / raw)
  To: linux-kernel; +Cc: Anshuman Khandual

This patch adds conditional branch filtering support,
enabling it for PERF_SAMPLE_BRANCH_COND in perf branch
stack sampling framework by utilizing an available
software filter X86_BR_JCC.

Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
Reviewed-by: Stephane Eranian <eranian@google.com>
---
 arch/x86/kernel/cpu/perf_event_intel_lbr.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_lbr.c b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
index d82d155..9dd2459 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_lbr.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
@@ -384,6 +384,9 @@ static void intel_pmu_setup_sw_lbr_filter(struct perf_event *event)
 	if (br_type & PERF_SAMPLE_BRANCH_NO_TX)
 		mask |= X86_BR_NO_TX;
 
+	if (br_type & PERF_SAMPLE_BRANCH_COND)
+		mask |= X86_BR_JCC;
+
 	/*
 	 * stash actual user request into reg, it may
 	 * be used by fixup code for some CPU
@@ -678,6 +681,7 @@ static const int nhm_lbr_sel_map[PERF_SAMPLE_BRANCH_MAX] = {
 	 * NHM/WSM erratum: must include IND_JMP to capture IND_CALL
 	 */
 	[PERF_SAMPLE_BRANCH_IND_CALL] = LBR_IND_CALL | LBR_IND_JMP,
+	[PERF_SAMPLE_BRANCH_COND]     = LBR_JCC,
 };
 
 static const int snb_lbr_sel_map[PERF_SAMPLE_BRANCH_MAX] = {
@@ -689,6 +693,7 @@ static const int snb_lbr_sel_map[PERF_SAMPLE_BRANCH_MAX] = {
 	[PERF_SAMPLE_BRANCH_ANY_CALL]	= LBR_REL_CALL | LBR_IND_CALL
 					| LBR_FAR,
 	[PERF_SAMPLE_BRANCH_IND_CALL]	= LBR_IND_CALL,
+	[PERF_SAMPLE_BRANCH_COND]       = LBR_JCC,
 };
 
 /* core */
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [V5 4/4] perf, documentation: Description for conditional branch filter
  2014-03-07  9:06 [V5 0/4] perf: New conditional branch filter Anshuman Khandual
                   ` (2 preceding siblings ...)
  2014-03-07  9:06 ` [V5 3/4] x86, perf: Add conditional branch filtering support Anshuman Khandual
@ 2014-03-07  9:06 ` Anshuman Khandual
  2014-03-25 14:52 ` [V5 0/4] perf: New " Anshuman Khandual
  4 siblings, 0 replies; 10+ messages in thread
From: Anshuman Khandual @ 2014-03-07  9:06 UTC (permalink / raw)
  To: linux-kernel; +Cc: Anshuman Khandual

Adding documentation support for conditional branch filter.

Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
Reviewed-by: Stephane Eranian <eranian@google.com>
---
 tools/perf/Documentation/perf-record.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index c71b0f3..d460049 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -184,9 +184,10 @@ following filters are defined:
 	- in_tx: only when the target is in a hardware transaction
 	- no_tx: only when the target is not in a hardware transaction
 	- abort_tx: only when the target is a hardware transaction abort
+	- cond: conditional branches
 
 +
-The option requires at least one branch type among any, any_call, any_ret, ind_call.
+The option requires at least one branch type among any, any_call, any_ret, ind_call, cond.
 The privilege levels may be omitted, in which case, the privilege levels of the associated
 event are applied to the branch filter. Both kernel (k) and hypervisor (hv) privilege
 levels are subject to permissions.  When sampling on multiple events, branch stack sampling
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [V5 0/4] perf: New conditional branch filter
  2014-03-07  9:06 [V5 0/4] perf: New conditional branch filter Anshuman Khandual
                   ` (3 preceding siblings ...)
  2014-03-07  9:06 ` [V5 4/4] perf, documentation: Description for conditional branch filter Anshuman Khandual
@ 2014-03-25 14:52 ` Anshuman Khandual
  2014-03-25 16:16   ` Andi Kleen
  2014-03-25 20:16   ` Andi Kleen
  4 siblings, 2 replies; 10+ messages in thread
From: Anshuman Khandual @ 2014-03-25 14:52 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-kernel, Stephane Eranian, Andi Kleen, Ingo Molnar,
	Benjamin Herrenschmidt, Michael Ellerman, Peter Zijlstra,
	Arnaldo Carvalho de Melo

On 03/07/2014 02:36 PM, Anshuman Khandual wrote:
> Hello Arnaldo,
> 
> 	I had posted the V5 version of PowerPC SW branch filter enablement
> patchset last month. Please find the patchset here at
> 
> 	https://lkml.org/lkml/2014/2/5/79
> 
> These following patches (2,4,5,6 patches from the original V5 version patchset)
> are the ones which change code in the generic kernel, perf tool and X86 perf.
> Basically this patchset adds one more branch filter for "conditional" branches.
> In X86 code, this new filter has been implemented with the help of availble SW
> filter X86_BR_JCC and LBR_JCC. We had some discussions in this regard before.
> Please review these changes and if it's okay, please merge them. Other patches
> in the series are powerpc specific and are being reviewed by Benjamin Herrenschmidt
> and Michael Ellerman. Let me know if you need more information.
> 
> [1] https://lkml.org/lkml/2013/5/22/51
> [2] https://lkml.org/lkml/2013/8/30/10
> [3] https://lkml.org/lkml/2013/10/16/75
> [4] https://lkml.org/lkml/2013/12/4/168
> [5] https://lkml.org/lkml/2014/2/5/79

Hey Arnaldo,

Do you have any comments or suggestions on this ? Have not received any
response on these proposed patch series yet. Thank you.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [V5 0/4] perf: New conditional branch filter
  2014-03-25 14:52 ` [V5 0/4] perf: New " Anshuman Khandual
@ 2014-03-25 16:16   ` Andi Kleen
  2014-04-07  8:20     ` Anshuman Khandual
  2014-03-25 20:16   ` Andi Kleen
  1 sibling, 1 reply; 10+ messages in thread
From: Andi Kleen @ 2014-03-25 16:16 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-kernel, Stephane Eranian, Ingo Molnar,
	Benjamin Herrenschmidt, Michael Ellerman, Peter Zijlstra,
	Arnaldo Carvalho de Melo

> Hey Arnaldo,
> 
> Do you have any comments or suggestions on this ? Have not received any
> response on these proposed patch series yet. Thank you.

I read it earlier and it looks good to me.

-Andi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [V5 0/4] perf: New conditional branch filter
  2014-03-25 14:52 ` [V5 0/4] perf: New " Anshuman Khandual
  2014-03-25 16:16   ` Andi Kleen
@ 2014-03-25 20:16   ` Andi Kleen
  1 sibling, 0 replies; 10+ messages in thread
From: Andi Kleen @ 2014-03-25 20:16 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-kernel, Stephane Eranian, Ingo Molnar,
	Benjamin Herrenschmidt, Michael Ellerman, Peter Zijlstra,
	Arnaldo Carvalho de Melo

> Do you have any comments or suggestions on this ? Have not received any
> response on these proposed patch series yet. Thank you.

Also BTW I'm also at least three patchkits behind on perf tools merges,
some of them several weeks old.

Perhaps we need a staging tree somewhere to collect all the patches
until they can actually get processed.

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [V5 0/4] perf: New conditional branch filter
  2014-03-25 16:16   ` Andi Kleen
@ 2014-04-07  8:20     ` Anshuman Khandual
  2014-04-07 12:18       ` Andi Kleen
  0 siblings, 1 reply; 10+ messages in thread
From: Anshuman Khandual @ 2014-04-07  8:20 UTC (permalink / raw)
  To: Andi Kleen
  Cc: linux-kernel, Stephane Eranian, Ingo Molnar,
	Benjamin Herrenschmidt, Michael Ellerman, Peter Zijlstra,
	Arnaldo Carvalho de Melo

On 03/25/2014 09:46 PM, Andi Kleen wrote:
>> Hey Arnaldo,
>>
>> Do you have any comments or suggestions on this ? Have not received any
>> response on these proposed patch series yet. Thank you.
> 
> I read it earlier and it looks good to me.

Hey Andi,

Can I add your "Reviewed-by" or "Acked-by" to all these four patches ?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [V5 0/4] perf: New conditional branch filter
  2014-04-07  8:20     ` Anshuman Khandual
@ 2014-04-07 12:18       ` Andi Kleen
  0 siblings, 0 replies; 10+ messages in thread
From: Andi Kleen @ 2014-04-07 12:18 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: linux-kernel, Stephane Eranian, Ingo Molnar,
	Benjamin Herrenschmidt, Michael Ellerman, Peter Zijlstra,
	Arnaldo Carvalho de Melo

On Mon, Apr 07, 2014 at 01:50:26PM +0530, Anshuman Khandual wrote:
> On 03/25/2014 09:46 PM, Andi Kleen wrote:
> >> Hey Arnaldo,
> >>
> >> Do you have any comments or suggestions on this ? Have not received any
> >> response on these proposed patch series yet. Thank you.
> > 
> > I read it earlier and it looks good to me.
> 
> Hey Andi,
> 
> Can I add your "Reviewed-by" or "Acked-by" to all these four patches ?

Ok for me.

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-04-07 12:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-07  9:06 [V5 0/4] perf: New conditional branch filter Anshuman Khandual
2014-03-07  9:06 ` [V5 1/4] perf: Add PERF_SAMPLE_BRANCH_COND Anshuman Khandual
2014-03-07  9:06 ` [V5 2/4] perf, tool: Conditional branch filter 'cond' added to perf record Anshuman Khandual
2014-03-07  9:06 ` [V5 3/4] x86, perf: Add conditional branch filtering support Anshuman Khandual
2014-03-07  9:06 ` [V5 4/4] perf, documentation: Description for conditional branch filter Anshuman Khandual
2014-03-25 14:52 ` [V5 0/4] perf: New " Anshuman Khandual
2014-03-25 16:16   ` Andi Kleen
2014-04-07  8:20     ` Anshuman Khandual
2014-04-07 12:18       ` Andi Kleen
2014-03-25 20:16   ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).