2011-08-30 20:41:05 -03:00
# include <linux/bitops.h>
# include <linux/types.h>
# include <linux/slab.h>
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
2011-08-30 20:41:05 -03:00
# include <asm/perf_event.h>
# include "perf_event.h"
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
/* The size of a BTS record in bytes: */
# define BTS_RECORD_SIZE 24
# define BTS_BUFFER_SIZE (PAGE_SIZE << 4)
# define PEBS_BUFFER_SIZE PAGE_SIZE
/*
* pebs_record_32 for p4 and core not supported
struct pebs_record_32 {
u32 flags , ip ;
u32 ax , bc , cx , dx ;
u32 si , di , bp , sp ;
} ;
*/
struct pebs_record_core {
u64 flags , ip ;
u64 ax , bx , cx , dx ;
u64 si , di , bp , sp ;
u64 r8 , r9 , r10 , r11 ;
u64 r12 , r13 , r14 , r15 ;
} ;
struct pebs_record_nhm {
u64 flags , ip ;
u64 ax , bx , cx , dx ;
u64 si , di , bp , sp ;
u64 r8 , r9 , r10 , r11 ;
u64 r12 , r13 , r14 , r15 ;
u64 status , dla , dse , lat ;
} ;
2011-08-30 20:41:05 -03:00
void init_debug_store_on_cpu ( int cpu )
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
{
struct debug_store * ds = per_cpu ( cpu_hw_events , cpu ) . ds ;
if ( ! ds )
return ;
wrmsr_on_cpu ( cpu , MSR_IA32_DS_AREA ,
( u32 ) ( ( u64 ) ( unsigned long ) ds ) ,
( u32 ) ( ( u64 ) ( unsigned long ) ds > > 32 ) ) ;
}
2011-08-30 20:41:05 -03:00
void fini_debug_store_on_cpu ( int cpu )
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
{
if ( ! per_cpu ( cpu_hw_events , cpu ) . ds )
return ;
wrmsr_on_cpu ( cpu , MSR_IA32_DS_AREA , 0 , 0 ) ;
}
2010-10-19 14:15:04 +02:00
static int alloc_pebs_buffer ( int cpu )
{
struct debug_store * ds = per_cpu ( cpu_hw_events , cpu ) . ds ;
2010-10-19 14:55:33 +02:00
int node = cpu_to_node ( cpu ) ;
2010-10-19 14:15:04 +02:00
int max , thresh = 1 ; /* always use a single PEBS record */
void * buffer ;
if ( ! x86_pmu . pebs )
return 0 ;
2010-10-19 14:55:33 +02:00
buffer = kmalloc_node ( PEBS_BUFFER_SIZE , GFP_KERNEL | __GFP_ZERO , node ) ;
2010-10-19 14:15:04 +02:00
if ( unlikely ( ! buffer ) )
return - ENOMEM ;
max = PEBS_BUFFER_SIZE / x86_pmu . pebs_record_size ;
ds - > pebs_buffer_base = ( u64 ) ( unsigned long ) buffer ;
ds - > pebs_index = ds - > pebs_buffer_base ;
ds - > pebs_absolute_maximum = ds - > pebs_buffer_base +
max * x86_pmu . pebs_record_size ;
ds - > pebs_interrupt_threshold = ds - > pebs_buffer_base +
thresh * x86_pmu . pebs_record_size ;
return 0 ;
}
2010-10-19 14:08:29 +02:00
static void release_pebs_buffer ( int cpu )
{
struct debug_store * ds = per_cpu ( cpu_hw_events , cpu ) . ds ;
if ( ! ds | | ! x86_pmu . pebs )
return ;
kfree ( ( void * ) ( unsigned long ) ds - > pebs_buffer_base ) ;
ds - > pebs_buffer_base = 0 ;
}
2010-10-19 14:15:04 +02:00
static int alloc_bts_buffer ( int cpu )
{
struct debug_store * ds = per_cpu ( cpu_hw_events , cpu ) . ds ;
2010-10-19 14:55:33 +02:00
int node = cpu_to_node ( cpu ) ;
2010-10-19 14:15:04 +02:00
int max , thresh ;
void * buffer ;
if ( ! x86_pmu . bts )
return 0 ;
2010-10-19 14:55:33 +02:00
buffer = kmalloc_node ( BTS_BUFFER_SIZE , GFP_KERNEL | __GFP_ZERO , node ) ;
2010-10-19 14:15:04 +02:00
if ( unlikely ( ! buffer ) )
return - ENOMEM ;
max = BTS_BUFFER_SIZE / BTS_RECORD_SIZE ;
thresh = max / 16 ;
ds - > bts_buffer_base = ( u64 ) ( unsigned long ) buffer ;
ds - > bts_index = ds - > bts_buffer_base ;
ds - > bts_absolute_maximum = ds - > bts_buffer_base +
max * BTS_RECORD_SIZE ;
ds - > bts_interrupt_threshold = ds - > bts_absolute_maximum -
thresh * BTS_RECORD_SIZE ;
return 0 ;
}
2010-10-19 14:08:29 +02:00
static void release_bts_buffer ( int cpu )
{
struct debug_store * ds = per_cpu ( cpu_hw_events , cpu ) . ds ;
if ( ! ds | | ! x86_pmu . bts )
return ;
kfree ( ( void * ) ( unsigned long ) ds - > bts_buffer_base ) ;
ds - > bts_buffer_base = 0 ;
}
2010-10-19 14:37:23 +02:00
static int alloc_ds_buffer ( int cpu )
{
2010-10-19 14:55:33 +02:00
int node = cpu_to_node ( cpu ) ;
2010-10-19 14:37:23 +02:00
struct debug_store * ds ;
2010-10-19 14:55:33 +02:00
ds = kmalloc_node ( sizeof ( * ds ) , GFP_KERNEL | __GFP_ZERO , node ) ;
2010-10-19 14:37:23 +02:00
if ( unlikely ( ! ds ) )
return - ENOMEM ;
per_cpu ( cpu_hw_events , cpu ) . ds = ds ;
return 0 ;
}
static void release_ds_buffer ( int cpu )
{
struct debug_store * ds = per_cpu ( cpu_hw_events , cpu ) . ds ;
if ( ! ds )
return ;
per_cpu ( cpu_hw_events , cpu ) . ds = NULL ;
kfree ( ds ) ;
}
2011-08-30 20:41:05 -03:00
void release_ds_buffers ( void )
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
{
int cpu ;
if ( ! x86_pmu . bts & & ! x86_pmu . pebs )
return ;
get_online_cpus ( ) ;
for_each_online_cpu ( cpu )
fini_debug_store_on_cpu ( cpu ) ;
for_each_possible_cpu ( cpu ) {
2010-10-19 14:08:29 +02:00
release_pebs_buffer ( cpu ) ;
release_bts_buffer ( cpu ) ;
2010-10-19 14:37:23 +02:00
release_ds_buffer ( cpu ) ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
}
put_online_cpus ( ) ;
}
2011-08-30 20:41:05 -03:00
void reserve_ds_buffers ( void )
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
{
2010-10-19 14:22:50 +02:00
int bts_err = 0 , pebs_err = 0 ;
int cpu ;
x86_pmu . bts_active = 0 ;
x86_pmu . pebs_active = 0 ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
if ( ! x86_pmu . bts & & ! x86_pmu . pebs )
2010-10-19 14:50:02 +02:00
return ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
2010-10-19 14:22:50 +02:00
if ( ! x86_pmu . bts )
bts_err = 1 ;
if ( ! x86_pmu . pebs )
pebs_err = 1 ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
get_online_cpus ( ) ;
for_each_possible_cpu ( cpu ) {
2010-10-19 14:22:50 +02:00
if ( alloc_ds_buffer ( cpu ) ) {
bts_err = 1 ;
pebs_err = 1 ;
}
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
2010-10-19 14:22:50 +02:00
if ( ! bts_err & & alloc_bts_buffer ( cpu ) )
bts_err = 1 ;
if ( ! pebs_err & & alloc_pebs_buffer ( cpu ) )
pebs_err = 1 ;
2010-10-19 14:15:04 +02:00
2010-10-19 14:22:50 +02:00
if ( bts_err & & pebs_err )
2010-10-19 14:15:04 +02:00
break ;
2010-10-19 14:22:50 +02:00
}
if ( bts_err ) {
for_each_possible_cpu ( cpu )
release_bts_buffer ( cpu ) ;
}
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
2010-10-19 14:22:50 +02:00
if ( pebs_err ) {
for_each_possible_cpu ( cpu )
release_pebs_buffer ( cpu ) ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
}
2010-10-19 14:22:50 +02:00
if ( bts_err & & pebs_err ) {
for_each_possible_cpu ( cpu )
release_ds_buffer ( cpu ) ;
} else {
if ( x86_pmu . bts & & ! bts_err )
x86_pmu . bts_active = 1 ;
if ( x86_pmu . pebs & & ! pebs_err )
x86_pmu . pebs_active = 1 ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
for_each_online_cpu ( cpu )
init_debug_store_on_cpu ( cpu ) ;
}
put_online_cpus ( ) ;
}
/*
* BTS
*/
2011-08-30 20:41:05 -03:00
struct event_constraint bts_constraint =
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
EVENT_CONSTRAINT ( 0 , 1ULL < < X86_PMC_IDX_FIXED_BTS , 0 ) ;
2011-08-30 20:41:05 -03:00
void intel_pmu_enable_bts ( u64 config )
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
{
unsigned long debugctlmsr ;
debugctlmsr = get_debugctlmsr ( ) ;
2010-03-25 14:51:49 +01:00
debugctlmsr | = DEBUGCTLMSR_TR ;
debugctlmsr | = DEBUGCTLMSR_BTS ;
debugctlmsr | = DEBUGCTLMSR_BTINT ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
if ( ! ( config & ARCH_PERFMON_EVENTSEL_OS ) )
2010-03-25 14:51:49 +01:00
debugctlmsr | = DEBUGCTLMSR_BTS_OFF_OS ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
if ( ! ( config & ARCH_PERFMON_EVENTSEL_USR ) )
2010-03-25 14:51:49 +01:00
debugctlmsr | = DEBUGCTLMSR_BTS_OFF_USR ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
update_debugctlmsr ( debugctlmsr ) ;
}
2011-08-30 20:41:05 -03:00
void intel_pmu_disable_bts ( void )
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
{
struct cpu_hw_events * cpuc = & __get_cpu_var ( cpu_hw_events ) ;
unsigned long debugctlmsr ;
if ( ! cpuc - > ds )
return ;
debugctlmsr = get_debugctlmsr ( ) ;
debugctlmsr & =
2010-03-25 14:51:49 +01:00
~ ( DEBUGCTLMSR_TR | DEBUGCTLMSR_BTS | DEBUGCTLMSR_BTINT |
DEBUGCTLMSR_BTS_OFF_OS | DEBUGCTLMSR_BTS_OFF_USR ) ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
update_debugctlmsr ( debugctlmsr ) ;
}
2011-08-30 20:41:05 -03:00
int intel_pmu_drain_bts_buffer ( void )
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
{
struct cpu_hw_events * cpuc = & __get_cpu_var ( cpu_hw_events ) ;
struct debug_store * ds = cpuc - > ds ;
struct bts_record {
u64 from ;
u64 to ;
u64 flags ;
} ;
struct perf_event * event = cpuc - > events [ X86_PMC_IDX_FIXED_BTS ] ;
struct bts_record * at , * top ;
struct perf_output_handle handle ;
struct perf_event_header header ;
struct perf_sample_data data ;
struct pt_regs regs ;
if ( ! event )
2010-09-10 13:28:01 +02:00
return 0 ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
2010-10-19 14:22:50 +02:00
if ( ! x86_pmu . bts_active )
2010-09-10 13:28:01 +02:00
return 0 ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
at = ( struct bts_record * ) ( unsigned long ) ds - > bts_buffer_base ;
top = ( struct bts_record * ) ( unsigned long ) ds - > bts_index ;
if ( top < = at )
2010-09-10 13:28:01 +02:00
return 0 ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
ds - > bts_index = ds - > bts_buffer_base ;
perf_sample_data_init ( & data , 0 ) ;
data . period = event - > hw . last_period ;
regs . ip = 0 ;
/*
* Prepare a generic sample , i . e . fill in the invariant fields .
* We will overwrite the from and to address before we output
* the sample .
*/
perf_prepare_sample ( & header , & data , event , & regs ) ;
2011-06-27 16:47:16 +02:00
if ( perf_output_begin ( & handle , event , header . size * ( top - at ) ) )
2010-09-10 13:28:01 +02:00
return 1 ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
for ( ; at < top ; at + + ) {
data . ip = at - > from ;
data . addr = at - > to ;
perf_output_sample ( & handle , & header , & data , event ) ;
}
perf_output_end ( & handle ) ;
/* There's new data available. */
event - > hw . interrupts + + ;
event - > pending_kill = POLL_IN ;
2010-09-10 13:28:01 +02:00
return 1 ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
}
/*
* PEBS
*/
2011-08-30 20:41:05 -03:00
struct event_constraint intel_core2_pebs_event_constraints [ ] = {
2011-03-09 23:21:29 +08:00
INTEL_UEVENT_CONSTRAINT ( 0x00c0 , 0x1 ) , /* INST_RETIRED.ANY */
INTEL_UEVENT_CONSTRAINT ( 0xfec1 , 0x1 ) , /* X87_OPS_RETIRED.ANY */
INTEL_UEVENT_CONSTRAINT ( 0x00c5 , 0x1 ) , /* BR_INST_RETIRED.MISPRED */
INTEL_UEVENT_CONSTRAINT ( 0x1fc7 , 0x1 ) , /* SIMD_INST_RETURED.ANY */
INTEL_EVENT_CONSTRAINT ( 0xcb , 0x1 ) , /* MEM_LOAD_RETIRED.* */
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
EVENT_CONSTRAINT_END
} ;
2011-08-30 20:41:05 -03:00
struct event_constraint intel_atom_pebs_event_constraints [ ] = {
2011-03-09 23:21:29 +08:00
INTEL_UEVENT_CONSTRAINT ( 0x00c0 , 0x1 ) , /* INST_RETIRED.ANY */
INTEL_UEVENT_CONSTRAINT ( 0x00c5 , 0x1 ) , /* MISPREDICTED_BRANCH_RETIRED */
INTEL_EVENT_CONSTRAINT ( 0xcb , 0x1 ) , /* MEM_LOAD_RETIRED.* */
2011-03-02 17:05:01 +02:00
EVENT_CONSTRAINT_END
} ;
2011-08-30 20:41:05 -03:00
struct event_constraint intel_nehalem_pebs_event_constraints [ ] = {
2011-03-09 23:21:29 +08:00
INTEL_EVENT_CONSTRAINT ( 0x0b , 0xf ) , /* MEM_INST_RETIRED.* */
INTEL_EVENT_CONSTRAINT ( 0x0f , 0xf ) , /* MEM_UNCORE_RETIRED.* */
INTEL_UEVENT_CONSTRAINT ( 0x010c , 0xf ) , /* MEM_STORE_RETIRED.DTLB_MISS */
INTEL_EVENT_CONSTRAINT ( 0xc0 , 0xf ) , /* INST_RETIRED.ANY */
INTEL_EVENT_CONSTRAINT ( 0xc2 , 0xf ) , /* UOPS_RETIRED.* */
INTEL_EVENT_CONSTRAINT ( 0xc4 , 0xf ) , /* BR_INST_RETIRED.* */
INTEL_UEVENT_CONSTRAINT ( 0x02c5 , 0xf ) , /* BR_MISP_RETIRED.NEAR_CALL */
INTEL_EVENT_CONSTRAINT ( 0xc7 , 0xf ) , /* SSEX_UOPS_RETIRED.* */
INTEL_UEVENT_CONSTRAINT ( 0x20c8 , 0xf ) , /* ITLB_MISS_RETIRED */
INTEL_EVENT_CONSTRAINT ( 0xcb , 0xf ) , /* MEM_LOAD_RETIRED.* */
INTEL_EVENT_CONSTRAINT ( 0xf7 , 0xf ) , /* FP_ASSIST.* */
2011-03-02 17:05:01 +02:00
EVENT_CONSTRAINT_END
} ;
2011-08-30 20:41:05 -03:00
struct event_constraint intel_westmere_pebs_event_constraints [ ] = {
2011-03-09 23:21:29 +08:00
INTEL_EVENT_CONSTRAINT ( 0x0b , 0xf ) , /* MEM_INST_RETIRED.* */
INTEL_EVENT_CONSTRAINT ( 0x0f , 0xf ) , /* MEM_UNCORE_RETIRED.* */
INTEL_UEVENT_CONSTRAINT ( 0x010c , 0xf ) , /* MEM_STORE_RETIRED.DTLB_MISS */
INTEL_EVENT_CONSTRAINT ( 0xc0 , 0xf ) , /* INSTR_RETIRED.* */
INTEL_EVENT_CONSTRAINT ( 0xc2 , 0xf ) , /* UOPS_RETIRED.* */
INTEL_EVENT_CONSTRAINT ( 0xc4 , 0xf ) , /* BR_INST_RETIRED.* */
INTEL_EVENT_CONSTRAINT ( 0xc5 , 0xf ) , /* BR_MISP_RETIRED.* */
INTEL_EVENT_CONSTRAINT ( 0xc7 , 0xf ) , /* SSEX_UOPS_RETIRED.* */
INTEL_UEVENT_CONSTRAINT ( 0x20c8 , 0xf ) , /* ITLB_MISS_RETIRED */
INTEL_EVENT_CONSTRAINT ( 0xcb , 0xf ) , /* MEM_LOAD_RETIRED.* */
INTEL_EVENT_CONSTRAINT ( 0xf7 , 0xf ) , /* FP_ASSIST.* */
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
EVENT_CONSTRAINT_END
} ;
2011-08-30 20:41:05 -03:00
struct event_constraint intel_snb_pebs_event_constraints [ ] = {
2011-03-09 23:21:29 +08:00
INTEL_UEVENT_CONSTRAINT ( 0x01c0 , 0x2 ) , /* INST_RETIRED.PRECDIST */
INTEL_UEVENT_CONSTRAINT ( 0x01c2 , 0xf ) , /* UOPS_RETIRED.ALL */
INTEL_UEVENT_CONSTRAINT ( 0x02c2 , 0xf ) , /* UOPS_RETIRED.RETIRE_SLOTS */
INTEL_EVENT_CONSTRAINT ( 0xc4 , 0xf ) , /* BR_INST_RETIRED.* */
INTEL_EVENT_CONSTRAINT ( 0xc5 , 0xf ) , /* BR_MISP_RETIRED.* */
INTEL_EVENT_CONSTRAINT ( 0xcd , 0x8 ) , /* MEM_TRANS_RETIRED.* */
INTEL_UEVENT_CONSTRAINT ( 0x11d0 , 0xf ) , /* MEM_UOP_RETIRED.STLB_MISS_LOADS */
INTEL_UEVENT_CONSTRAINT ( 0x12d0 , 0xf ) , /* MEM_UOP_RETIRED.STLB_MISS_STORES */
INTEL_UEVENT_CONSTRAINT ( 0x21d0 , 0xf ) , /* MEM_UOP_RETIRED.LOCK_LOADS */
INTEL_UEVENT_CONSTRAINT ( 0x22d0 , 0xf ) , /* MEM_UOP_RETIRED.LOCK_STORES */
INTEL_UEVENT_CONSTRAINT ( 0x41d0 , 0xf ) , /* MEM_UOP_RETIRED.SPLIT_LOADS */
INTEL_UEVENT_CONSTRAINT ( 0x42d0 , 0xf ) , /* MEM_UOP_RETIRED.SPLIT_STORES */
INTEL_UEVENT_CONSTRAINT ( 0x81d0 , 0xf ) , /* MEM_UOP_RETIRED.ANY_LOADS */
INTEL_UEVENT_CONSTRAINT ( 0x82d0 , 0xf ) , /* MEM_UOP_RETIRED.ANY_STORES */
INTEL_EVENT_CONSTRAINT ( 0xd1 , 0xf ) , /* MEM_LOAD_UOPS_RETIRED.* */
INTEL_EVENT_CONSTRAINT ( 0xd2 , 0xf ) , /* MEM_LOAD_UOPS_LLC_HIT_RETIRED.* */
INTEL_UEVENT_CONSTRAINT ( 0x02d4 , 0xf ) , /* MEM_LOAD_UOPS_MISC_RETIRED.LLC_MISS */
2011-03-02 21:27:04 +08:00
EVENT_CONSTRAINT_END
} ;
2011-08-30 20:41:05 -03:00
struct event_constraint * intel_pebs_constraints ( struct perf_event * event )
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
{
struct event_constraint * c ;
2010-04-08 23:03:20 +02:00
if ( ! event - > attr . precise_ip )
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
return NULL ;
if ( x86_pmu . pebs_constraints ) {
for_each_event_constraint ( c , x86_pmu . pebs_constraints ) {
if ( ( event - > hw . config & c - > cmask ) = = c - > code )
return c ;
}
}
return & emptyconstraint ;
}
2011-08-30 20:41:05 -03:00
void intel_pmu_pebs_enable ( struct perf_event * event )
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
{
struct cpu_hw_events * cpuc = & __get_cpu_var ( cpu_hw_events ) ;
2010-03-03 13:12:23 +01:00
struct hw_perf_event * hwc = & event - > hw ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
hwc - > config & = ~ ARCH_PERFMON_EVENTSEL_INT ;
2010-03-06 19:49:06 +01:00
cpuc - > pebs_enabled | = 1ULL < < hwc - > idx ;
2010-03-03 13:12:23 +01:00
2010-04-08 23:03:20 +02:00
if ( x86_pmu . intel_cap . pebs_trap & & event - > attr . precise_ip > 1 )
2010-03-03 17:07:40 +01:00
intel_pmu_lbr_enable ( event ) ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
}
2011-08-30 20:41:05 -03:00
void intel_pmu_pebs_disable ( struct perf_event * event )
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
{
struct cpu_hw_events * cpuc = & __get_cpu_var ( cpu_hw_events ) ;
2010-03-03 13:12:23 +01:00
struct hw_perf_event * hwc = & event - > hw ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
2010-03-06 19:49:06 +01:00
cpuc - > pebs_enabled & = ~ ( 1ULL < < hwc - > idx ) ;
2010-03-06 13:47:07 +01:00
if ( cpuc - > enabled )
2010-03-06 19:49:06 +01:00
wrmsrl ( MSR_IA32_PEBS_ENABLE , cpuc - > pebs_enabled ) ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
hwc - > config | = ARCH_PERFMON_EVENTSEL_INT ;
2010-03-03 13:12:23 +01:00
2010-04-08 23:03:20 +02:00
if ( x86_pmu . intel_cap . pebs_trap & & event - > attr . precise_ip > 1 )
2010-03-03 17:07:40 +01:00
intel_pmu_lbr_disable ( event ) ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
}
2011-08-30 20:41:05 -03:00
void intel_pmu_pebs_enable_all ( void )
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
{
struct cpu_hw_events * cpuc = & __get_cpu_var ( cpu_hw_events ) ;
if ( cpuc - > pebs_enabled )
wrmsrl ( MSR_IA32_PEBS_ENABLE , cpuc - > pebs_enabled ) ;
}
2011-08-30 20:41:05 -03:00
void intel_pmu_pebs_disable_all ( void )
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
{
struct cpu_hw_events * cpuc = & __get_cpu_var ( cpu_hw_events ) ;
if ( cpuc - > pebs_enabled )
wrmsrl ( MSR_IA32_PEBS_ENABLE , 0 ) ;
}
2010-03-03 13:12:23 +01:00
# include <asm/insn.h>
static inline bool kernel_ip ( unsigned long ip )
{
# ifdef CONFIG_X86_32
return ip > PAGE_OFFSET ;
# else
return ( long ) ip < 0 ;
# endif
}
static int intel_pmu_pebs_fixup_ip ( struct pt_regs * regs )
{
struct cpu_hw_events * cpuc = & __get_cpu_var ( cpu_hw_events ) ;
unsigned long from = cpuc - > lbr_entries [ 0 ] . from ;
unsigned long old_to , to = cpuc - > lbr_entries [ 0 ] . to ;
unsigned long ip = regs - > ip ;
2011-10-07 13:36:40 +02:00
int is_64bit = 0 ;
2010-03-03 13:12:23 +01:00
2010-03-03 17:07:40 +01:00
/*
* We don ' t need to fixup if the PEBS assist is fault like
*/
if ( ! x86_pmu . intel_cap . pebs_trap )
return 1 ;
2010-03-05 16:29:14 +01:00
/*
* No LBR entry , no basic block , no rewinding
*/
2010-03-03 13:12:23 +01:00
if ( ! cpuc - > lbr_stack . nr | | ! from | | ! to )
return 0 ;
2010-03-05 16:29:14 +01:00
/*
* Basic blocks should never cross user / kernel boundaries
*/
if ( kernel_ip ( ip ) ! = kernel_ip ( to ) )
return 0 ;
/*
* unsigned math , either ip is before the start ( impossible ) or
* the basic block is larger than 1 page ( sanity )
*/
if ( ( ip - to ) > PAGE_SIZE )
2010-03-03 13:12:23 +01:00
return 0 ;
/*
* We sampled a branch insn , rewind using the LBR stack
*/
if ( ip = = to ) {
regs - > ip = from ;
return 1 ;
}
do {
struct insn insn ;
u8 buf [ MAX_INSN_SIZE ] ;
void * kaddr ;
old_to = to ;
if ( ! kernel_ip ( ip ) ) {
2010-03-05 16:29:14 +01:00
int bytes , size = MAX_INSN_SIZE ;
2010-03-03 13:12:23 +01:00
bytes = copy_from_user_nmi ( buf , ( void __user * ) to , size ) ;
if ( bytes ! = size )
return 0 ;
kaddr = buf ;
} else
kaddr = ( void * ) to ;
2011-10-07 13:36:40 +02:00
# ifdef CONFIG_X86_64
is_64bit = kernel_ip ( to ) | | ! test_thread_flag ( TIF_IA32 ) ;
# endif
insn_init ( & insn , kaddr , is_64bit ) ;
2010-03-03 13:12:23 +01:00
insn_get_length ( & insn ) ;
to + = insn . length ;
} while ( to < ip ) ;
if ( to = = ip ) {
regs - > ip = old_to ;
return 1 ;
}
2010-03-05 16:29:14 +01:00
/*
* Even though we decoded the basic block , the instruction stream
* never matched the given IP , either the TO or the IP got corrupted .
*/
2010-03-03 13:12:23 +01:00
return 0 ;
}
2010-04-08 23:03:20 +02:00
static void __intel_pmu_pebs_event ( struct perf_event * event ,
struct pt_regs * iregs , void * __pebs )
{
/*
* We cast to pebs_record_core since that is a subset of
* both formats and we don ' t use the other fields in this
* routine .
*/
struct pebs_record_core * pebs = __pebs ;
struct perf_sample_data data ;
struct pt_regs regs ;
if ( ! intel_pmu_save_and_restart ( event ) )
return ;
perf_sample_data_init ( & data , 0 ) ;
data . period = event - > hw . last_period ;
/*
* We use the interrupt regs as a base because the PEBS record
* does not contain a full regs set , specifically it seems to
* lack segment descriptors , which get used by things like
* user_mode ( ) .
*
* In the simple case fix up only the IP and BP , SP regs , for
* PERF_SAMPLE_IP and PERF_SAMPLE_CALLCHAIN to function properly .
* A possible PERF_SAMPLE_REGS will have to transfer all regs .
*/
regs = * iregs ;
regs . ip = pebs - > ip ;
regs . bp = pebs - > bp ;
regs . sp = pebs - > sp ;
2010-04-08 23:03:20 +02:00
if ( event - > attr . precise_ip > 1 & & intel_pmu_pebs_fixup_ip ( & regs ) )
2010-04-08 23:03:20 +02:00
regs . flags | = PERF_EFLAGS_EXACT ;
else
regs . flags & = ~ PERF_EFLAGS_EXACT ;
2011-06-27 14:41:57 +02:00
if ( perf_event_overflow ( event , & data , & regs ) )
perf: Rework the PMU methods
Replace pmu::{enable,disable,start,stop,unthrottle} with
pmu::{add,del,start,stop}, all of which take a flags argument.
The new interface extends the capability to stop a counter while
keeping it scheduled on the PMU. We replace the throttled state with
the generic stopped state.
This also allows us to efficiently stop/start counters over certain
code paths (like IRQ handlers).
It also allows scheduling a counter without it starting, allowing for
a generic frozen state (useful for rotating stopped counters).
The stopped state is implemented in two different ways, depending on
how the architecture implemented the throttled state:
1) We disable the counter:
a) the pmu has per-counter enable bits, we flip that
b) we program a NOP event, preserving the counter state
2) We store the counter state and ignore all read/overflow events
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: paulus <paulus@samba.org>
Cc: stephane eranian <eranian@googlemail.com>
Cc: Robert Richter <robert.richter@amd.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Lin Ming <ming.m.lin@intel.com>
Cc: Yanmin <yanmin_zhang@linux.intel.com>
Cc: Deng-Cheng Zhu <dengcheng.zhu@gmail.com>
Cc: David Miller <davem@davemloft.net>
Cc: Michael Cree <mcree@orcon.net.nz>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-06-16 14:37:10 +02:00
x86_pmu_stop ( event , 0 ) ;
2010-04-08 23:03:20 +02:00
}
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
static void intel_pmu_drain_pebs_core ( struct pt_regs * iregs )
{
struct cpu_hw_events * cpuc = & __get_cpu_var ( cpu_hw_events ) ;
struct debug_store * ds = cpuc - > ds ;
struct perf_event * event = cpuc - > events [ 0 ] ; /* PMC0 only */
struct pebs_record_core * at , * top ;
int n ;
2010-10-19 14:22:50 +02:00
if ( ! x86_pmu . pebs_active )
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
return ;
at = ( struct pebs_record_core * ) ( unsigned long ) ds - > pebs_buffer_base ;
top = ( struct pebs_record_core * ) ( unsigned long ) ds - > pebs_index ;
2010-03-09 11:41:02 +01:00
/*
* Whatever else happens , drain the thing
*/
ds - > pebs_index = ds - > pebs_buffer_base ;
if ( ! test_bit ( 0 , cpuc - > active_mask ) )
2010-03-06 13:26:11 +01:00
return ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
2010-03-09 11:41:02 +01:00
WARN_ON_ONCE ( ! event ) ;
2010-04-08 23:03:20 +02:00
if ( ! event - > attr . precise_ip )
2010-03-09 11:41:02 +01:00
return ;
n = top - at ;
if ( n < = 0 )
return ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
2010-03-09 11:41:02 +01:00
/*
* Should not happen , we program the threshold at 1 and do not
* set a reset value .
*/
WARN_ON_ONCE ( n > 1 ) ;
at + = n - 1 ;
2010-04-08 23:03:20 +02:00
__intel_pmu_pebs_event ( event , iregs , at ) ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
}
static void intel_pmu_drain_pebs_nhm ( struct pt_regs * iregs )
{
struct cpu_hw_events * cpuc = & __get_cpu_var ( cpu_hw_events ) ;
struct debug_store * ds = cpuc - > ds ;
struct pebs_record_nhm * at , * top ;
struct perf_event * event = NULL ;
2010-03-06 18:57:38 +01:00
u64 status = 0 ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
int bit , n ;
2010-10-19 14:22:50 +02:00
if ( ! x86_pmu . pebs_active )
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
return ;
at = ( struct pebs_record_nhm * ) ( unsigned long ) ds - > pebs_buffer_base ;
top = ( struct pebs_record_nhm * ) ( unsigned long ) ds - > pebs_index ;
ds - > pebs_index = ds - > pebs_buffer_base ;
n = top - at ;
2010-03-09 11:41:02 +01:00
if ( n < = 0 )
return ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
/*
* Should not happen , we program the threshold at 1 and do not
* set a reset value .
*/
WARN_ON_ONCE ( n > MAX_PEBS_EVENTS ) ;
for ( ; at < top ; at + + ) {
2010-04-08 13:36:36 +02:00
for_each_set_bit ( bit , ( unsigned long * ) & at - > status , MAX_PEBS_EVENTS ) {
2010-03-06 18:57:38 +01:00
event = cpuc - > events [ bit ] ;
if ( ! test_bit ( bit , cpuc - > active_mask ) )
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
continue ;
2010-03-06 18:57:38 +01:00
WARN_ON_ONCE ( ! event ) ;
2010-04-08 23:03:20 +02:00
if ( ! event - > attr . precise_ip )
2010-03-06 18:57:38 +01:00
continue ;
if ( __test_and_set_bit ( bit , ( unsigned long * ) & status ) )
continue ;
break ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
}
2010-03-06 18:57:38 +01:00
if ( ! event | | bit > = MAX_PEBS_EVENTS )
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
continue ;
2010-04-08 23:03:20 +02:00
__intel_pmu_pebs_event ( event , iregs , at ) ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
}
}
/*
* BTS , PEBS probe and setup
*/
2011-08-30 20:41:05 -03:00
void intel_ds_init ( void )
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
{
/*
* No support for 32 bit formats
*/
if ( ! boot_cpu_has ( X86_FEATURE_DTES64 ) )
return ;
x86_pmu . bts = boot_cpu_has ( X86_FEATURE_BTS ) ;
x86_pmu . pebs = boot_cpu_has ( X86_FEATURE_PEBS ) ;
if ( x86_pmu . pebs ) {
2010-03-03 17:07:40 +01:00
char pebs_type = x86_pmu . intel_cap . pebs_trap ? ' + ' : ' - ' ;
int format = x86_pmu . intel_cap . pebs_format ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
switch ( format ) {
case 0 :
2010-03-03 17:07:40 +01:00
printk ( KERN_CONT " PEBS fmt0%c, " , pebs_type ) ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
x86_pmu . pebs_record_size = sizeof ( struct pebs_record_core ) ;
x86_pmu . drain_pebs = intel_pmu_drain_pebs_core ;
break ;
case 1 :
2010-03-03 17:07:40 +01:00
printk ( KERN_CONT " PEBS fmt1%c, " , pebs_type ) ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
x86_pmu . pebs_record_size = sizeof ( struct pebs_record_nhm ) ;
x86_pmu . drain_pebs = intel_pmu_drain_pebs_nhm ;
break ;
default :
2010-03-03 17:07:40 +01:00
printk ( KERN_CONT " no PEBS fmt%d%c, " , format , pebs_type ) ;
perf, x86: Add PEBS infrastructure
This patch implements support for Intel Precise Event Based Sampling,
which is an alternative counter mode in which the counter triggers a
hardware assist to collect information on events. The hardware assist
takes a trap like snapshot of a subset of the machine registers.
This data is written to the Intel Debug-Store, which can be programmed
with a data threshold at which to raise a PMI.
With the PEBS hardware assist being trap like, the reported IP is always
one instruction after the actual instruction that triggered the event.
This implements a simple PEBS model that always takes a single PEBS event
at a time. This is done so that the interaction with the rest of the
system is as expected (freq adjust, period randomization, lbr,
callchains, etc.).
It adds an ABI element: perf_event_attr::precise, which indicates that we
wish to use this (constrained, but precise) mode.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: paulus@samba.org
Cc: eranian@google.com
Cc: robert.richter@amd.com
Cc: fweisbec@gmail.com
LKML-Reference: <20100304140100.392111285@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2010-03-02 19:52:12 +01:00
x86_pmu . pebs = 0 ;
}
}
}