Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
4788b02a
Commit
4788b02a
authored
Jan 14, 2003
by
Falk Hüffner
Committed by
Richard Henderson
Jan 14, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[OPROF] Support EV67 ProfileMe.
parent
7a238a51
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
301 additions
and
16 deletions
+301
-16
arch/alpha/oprofile/Makefile
arch/alpha/oprofile/Makefile
+4
-2
arch/alpha/oprofile/common.c
arch/alpha/oprofile/common.c
+28
-14
arch/alpha/oprofile/op_impl.h
arch/alpha/oprofile/op_impl.h
+6
-0
arch/alpha/oprofile/op_model_ev67.c
arch/alpha/oprofile/op_model_ev67.c
+261
-0
include/asm-alpha/system.h
include/asm-alpha/system.h
+1
-0
include/linux/oprofile.h
include/linux/oprofile.h
+1
-0
No files found.
arch/alpha/oprofile/Makefile
View file @
4788b02a
...
...
@@ -8,7 +8,9 @@ DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \
oprofile-y
:=
$(DRIVER_OBJS)
common.o
oprofile-$(CONFIG_ALPHA_GENERIC)
+=
op_model_ev4.o
\
op_model_ev5.o
\
op_model_ev6.o
op_model_ev6.o
\
op_model_ev67.o
oprofile-$(CONFIG_ALPHA_EV4)
+=
op_model_ev4.o
oprofile-$(CONFIG_ALPHA_EV5)
+=
op_model_ev5.o
oprofile-$(CONFIG_ALPHA_EV6)
+=
op_model_ev6.o
oprofile-$(CONFIG_ALPHA_EV6)
+=
op_model_ev6.o
\
op_model_ev67.o
arch/alpha/oprofile/common.c
View file @
4788b02a
...
...
@@ -20,13 +20,14 @@ extern struct op_axp_model op_model_ev4 __attribute__((weak));
extern
struct
op_axp_model
op_model_ev5
__attribute__
((
weak
));
extern
struct
op_axp_model
op_model_pca56
__attribute__
((
weak
));
extern
struct
op_axp_model
op_model_ev6
__attribute__
((
weak
));
extern
struct
op_axp_model
op_model_ev67
__attribute__
((
weak
));
static
struct
op_axp_model
*
model
;
extern
void
(
*
perf_irq
)(
unsigned
long
,
struct
pt_regs
*
);
static
void
(
*
save_perf_irq
)(
unsigned
long
,
struct
pt_regs
*
);
static
struct
op_counter_config
ctr
[
3
];
static
struct
op_counter_config
ctr
[
20
];
static
struct
op_system_config
sys
;
static
struct
op_register_config
reg
;
...
...
@@ -35,14 +36,17 @@ static struct op_register_config reg;
static
void
op_handle_interrupt
(
unsigned
long
which
,
struct
pt_regs
*
regs
)
{
/* EV4 can't properly disable counters individually.
Discard "disabled" events now. */
if
(
!
ctr
[
which
].
enabled
)
return
;
/* Record the sample. */
oprofile_add_sample
(
regs
->
pc
,
which
,
smp_processor_id
());
if
(
model
->
handle_interrupt
)
{
model
->
handle_interrupt
(
which
,
regs
,
ctr
);
}
else
{
/* EV4 can't properly disable counters individually.
Discard "disabled" events now. */
if
(
!
ctr
[
which
].
enabled
)
return
;
/* Record the sample. */
oprofile_add_sample
(
regs
->
pc
,
which
,
smp_processor_id
());
}
/* If the user has selected an interrupt frequency that is
not exactly the width of the counter, write a new value
into the counter such that it'll overflow after N more
...
...
@@ -117,15 +121,18 @@ op_axp_create_files(struct super_block * sb, struct dentry * root)
for
(
i
=
0
;
i
<
model
->
num_counters
;
++
i
)
{
struct
dentry
*
dir
;
char
buf
[
2
];
char
buf
[
3
];
buf
[
0
]
=
i
+
'0'
;
buf
[
1
]
=
0
;
snprintf
(
buf
,
sizeof
buf
,
"%d"
,
i
);
dir
=
oprofilefs_mkdir
(
sb
,
root
,
buf
);
oprofilefs_create_ulong
(
sb
,
dir
,
"enabled"
,
&
ctr
[
i
].
enabled
);
oprofilefs_create_ulong
(
sb
,
dir
,
"event"
,
&
ctr
[
i
].
event
);
oprofilefs_create_ulong
(
sb
,
dir
,
"count"
,
&
ctr
[
i
].
count
);
/* Dummies. */
oprofilefs_create_ulong
(
sb
,
dir
,
"kernel"
,
&
ctr
[
i
].
kernel
);
oprofilefs_create_ulong
(
sb
,
dir
,
"user"
,
&
ctr
[
i
].
user
);
oprofilefs_create_ulong
(
sb
,
dir
,
"unit_mask"
,
&
ctr
[
i
].
unit_mask
);
}
if
(
model
->
can_set_proc_mode
)
{
...
...
@@ -171,8 +178,15 @@ oprofile_arch_init(struct oprofile_operations **ops, enum oprofile_cpu *cpu)
}
break
;
case
IMPLVER_EV6
:
lmodel
=
&
op_model_ev6
;
vername
=
"EV6"
;
/* 21264A supports ProfileMe.
Recognize the chip by the presence of the CIX insns. */
if
(
!
amask
(
AMASK_CIX
))
{
lmodel
=
&
op_model_ev67
;
vername
=
"EV67"
;
}
else
{
lmodel
=
&
op_model_ev6
;
vername
=
"EV6"
;
}
break
;
}
...
...
arch/alpha/oprofile/op_impl.h
View file @
4788b02a
...
...
@@ -15,6 +15,10 @@ struct op_counter_config {
unsigned
long
enabled
;
unsigned
long
event
;
unsigned
long
count
;
/* Dummies because I am too lazy to hack the userspace tools. */
unsigned
long
kernel
;
unsigned
long
user
;
unsigned
long
unit_mask
;
};
/* System-wide configuration as set via oprofilefs. */
...
...
@@ -41,6 +45,8 @@ struct op_axp_model {
struct
op_system_config
*
);
void
(
*
cpu_setup
)
(
void
*
);
void
(
*
reset_ctr
)
(
struct
op_register_config
*
,
unsigned
long
);
void
(
*
handle_interrupt
)
(
unsigned
long
,
struct
pt_regs
*
,
struct
op_counter_config
*
);
enum
oprofile_cpu
cpu
;
unsigned
char
num_counters
;
unsigned
char
can_set_proc_mode
;
...
...
arch/alpha/oprofile/op_model_ev67.c
0 → 100644
View file @
4788b02a
/**
* @file arch/alpha/oprofile/op_model_ev67.c
*
* @remark Copyright 2002 OProfile authors
* @remark Read the file COPYING
*
* @author Richard Henderson <rth@twiddle.net>
* @author Falk Hueffner <falk@debian.org>
*/
#include <linux/oprofile.h>
#include <linux/init.h>
#include <linux/smp.h>
#include <asm/ptrace.h>
#include <asm/system.h>
#include "op_impl.h"
/* Compute all of the registers in preparation for enabling profiling. */
static
void
ev67_reg_setup
(
struct
op_register_config
*
reg
,
struct
op_counter_config
*
ctr
,
struct
op_system_config
*
sys
)
{
unsigned
long
ctl
,
reset
,
need_reset
,
i
;
/* Select desired events. */
ctl
=
1UL
<<
4
;
/* Enable ProfileMe mode. */
/* The event numbers are chosen so we can use them directly if
PCTR1 is enabled. */
if
(
ctr
[
1
].
enabled
)
{
ctl
|=
(
ctr
[
1
].
event
&
3
)
<<
2
;
}
else
{
if
(
ctr
[
0
].
event
==
0
)
/* cycles */
ctl
|=
1UL
<<
2
;
}
reg
->
mux_select
=
ctl
;
/* Select logging options. */
/* ??? Need to come up with some mechanism to trace only
selected processes. EV67 does not have a mechanism to
select kernel or user mode only. For now, enable always. */
reg
->
proc_mode
=
0
;
/* EV67 cannot change the width of the counters as with the
other implementations. But fortunately, we can write to
the counters and set the value such that it will overflow
at the right time. */
reset
=
need_reset
=
0
;
for
(
i
=
0
;
i
<
2
;
++
i
)
{
unsigned
long
count
=
ctr
[
i
].
count
;
if
(
!
ctr
[
i
].
enabled
)
continue
;
if
(
count
>
0x100000
)
count
=
0x100000
;
ctr
[
i
].
count
=
count
;
reset
|=
(
0x100000
-
count
)
<<
(
i
?
6
:
28
);
if
(
count
!=
0x100000
)
need_reset
|=
1
<<
i
;
}
reg
->
reset_values
=
reset
;
reg
->
need_reset
=
need_reset
;
}
/* Program all of the registers in preparation for enabling profiling. */
static
void
ev67_cpu_setup
(
void
*
x
)
{
struct
op_register_config
*
reg
=
x
;
wrperfmon
(
2
,
reg
->
mux_select
);
wrperfmon
(
3
,
reg
->
proc_mode
);
wrperfmon
(
6
,
reg
->
reset_values
|
3
);
}
/* CTR is a counter for which the user has requested an interrupt count
in between one of the widths selectable in hardware. Reset the count
for CTR to the value stored in REG->RESET_VALUES. */
static
void
ev67_reset_ctr
(
struct
op_register_config
*
reg
,
unsigned
long
ctr
)
{
wrperfmon
(
6
,
reg
->
reset_values
|
(
1
<<
ctr
));
}
/* ProfileMe conditions which will show up as counters. We can also
detect the following, but it seems unlikely that anybody is
interested in counting them:
* Reset
* MT_FPCR (write to floating point control register)
* Arithmetic trap
* Dstream Fault
* Machine Check (ECC fault, etc.)
* OPCDEC (illegal opcode)
* Floating point disabled
* Differentiate between DTB single/double misses and 3 or 4 level
page tables
* Istream access violation
* Interrupt
* Icache Parity Error.
* Instruction killed (nop, trapb)
Unfortunately, there seems to be no way to detect Dcache and Bcache
misses; the latter could be approximated by making the counter
count Bcache misses, but that is not precise.
We model this as 20 counters:
* PCTR0
* PCTR1
* 9 ProfileMe events, induced by PCTR0
* 9 ProfileMe events, induced by PCTR1
*/
enum
profileme_counters
{
PM_STALLED
,
/* Stalled for at least one cycle
between the fetch and map stages */
PM_TAKEN
,
/* Conditional branch taken */
PM_MISPREDICT
,
/* Branch caused mispredict trap */
PM_ITB_MISS
,
/* ITB miss */
PM_DTB_MISS
,
/* DTB miss */
PM_REPLAY
,
/* Replay trap */
PM_LOAD_STORE
,
/* Load-store order trap */
PM_ICACHE_MISS
,
/* Icache miss */
PM_UNALIGNED
,
/* Unaligned Load/Store */
PM_NUM_COUNTERS
};
static
void
op_add_pm
(
unsigned
long
pc
,
unsigned
long
counter
,
struct
op_counter_config
*
ctr
,
unsigned
long
event
)
{
unsigned
long
fake_counter
=
2
+
event
;
if
(
counter
==
1
)
fake_counter
+=
PM_NUM_COUNTERS
;
if
(
ctr
[
fake_counter
].
enabled
)
oprofile_add_sample
(
pc
,
fake_counter
,
smp_processor_id
());
}
static
void
ev67_handle_interrupt
(
unsigned
long
which
,
struct
pt_regs
*
regs
,
struct
op_counter_config
*
ctr
)
{
unsigned
long
pmpc
,
pctr_ctl
;
int
mispredict
=
0
;
union
{
unsigned
long
v
;
struct
{
unsigned
reserved
:
30
;
/* 0-29 */
unsigned
overcount
:
3
;
/* 30-32 */
unsigned
icache_miss
:
1
;
/* 33 */
unsigned
trap_type
:
4
;
/* 34-37 */
unsigned
load_store
:
1
;
/* 38 */
unsigned
trap
:
1
;
/* 39 */
unsigned
mispredict
:
1
;
/* 40 */
}
fields
;
}
i_stat
;
enum
trap_types
{
TRAP_REPLAY
,
TRAP_INVALID0
,
TRAP_DTB_DOUBLE_MISS_3
,
TRAP_DTB_DOUBLE_MISS_4
,
TRAP_FP_DISABLED
,
TRAP_UNALIGNED
,
TRAP_DTB_SINGLE_MISS
,
TRAP_DSTREAM_FAULT
,
TRAP_OPCDEC
,
TRAP_INVALID1
,
TRAP_MACHINE_CHECK
,
TRAP_INVALID2
,
TRAP_ARITHMETIC
,
TRAP_INVALID3
,
TRAP_MT_FPCR
,
TRAP_RESET
};
pmpc
=
wrperfmon
(
9
,
0
);
/* ??? Don't know how to handle physical-mode PALcode address. */
if
(
pmpc
&
1
)
return
;
pmpc
&=
~
2
;
/* clear reserved bit */
i_stat
.
v
=
wrperfmon
(
8
,
0
);
if
(
i_stat
.
fields
.
trap
)
{
switch
(
i_stat
.
fields
.
trap_type
)
{
case
TRAP_INVALID1
:
case
TRAP_INVALID2
:
case
TRAP_INVALID3
:
/* Pipeline redirection ocurred. PMPC points
to PALcode. Recognize ITB miss by PALcode
offset address, and get actual PC from
EXC_ADDR. */
oprofile_add_sample
(
regs
->
pc
,
which
,
smp_processor_id
());
if
((
pmpc
&
((
1
<<
15
)
-
1
))
==
581
)
op_add_pm
(
regs
->
pc
,
which
,
ctr
,
PM_ITB_MISS
);
/* Most other bit and counter values will be
those for the first instruction in the
fault handler, so we're done. */
return
;
case
TRAP_REPLAY
:
if
(
i_stat
.
fields
.
load_store
)
op_add_pm
(
pmpc
,
which
,
ctr
,
PM_LOAD_STORE
);
else
op_add_pm
(
pmpc
,
which
,
ctr
,
PM_REPLAY
);
break
;
case
TRAP_DTB_DOUBLE_MISS_3
:
case
TRAP_DTB_DOUBLE_MISS_4
:
case
TRAP_DTB_SINGLE_MISS
:
op_add_pm
(
pmpc
,
which
,
ctr
,
PM_DTB_MISS
);
break
;
case
TRAP_UNALIGNED
:
op_add_pm
(
pmpc
,
which
,
ctr
,
PM_UNALIGNED
);
break
;
case
TRAP_INVALID0
:
case
TRAP_FP_DISABLED
:
case
TRAP_DSTREAM_FAULT
:
case
TRAP_OPCDEC
:
case
TRAP_MACHINE_CHECK
:
case
TRAP_ARITHMETIC
:
case
TRAP_MT_FPCR
:
case
TRAP_RESET
:
break
;
}
/* ??? JSR/JMP/RET/COR or HW_JSR/HW_JMP/HW_RET/HW_COR
mispredicts do not set this bit but can be
recognized by the presence of one of these
instructions at the PMPC location with bit 39
set. */
if
(
i_stat
.
fields
.
mispredict
)
{
mispredict
=
1
;
op_add_pm
(
pmpc
,
which
,
ctr
,
PM_MISPREDICT
);
}
}
oprofile_add_sample
(
pmpc
,
which
,
smp_processor_id
());
pctr_ctl
=
wrperfmon
(
5
,
0
);
if
(
pctr_ctl
&
(
1UL
<<
27
))
op_add_pm
(
pmpc
,
which
,
ctr
,
PM_STALLED
);
/* Unfortunately, TAK is undefined on mispredicted branches.
??? It is also undefined for non-cbranch insns, should
check that. */
if
(
!
mispredict
&&
pctr_ctl
&
(
1UL
<<
0
))
op_add_pm
(
pmpc
,
which
,
ctr
,
PM_TAKEN
);
}
struct
op_axp_model
op_model_ev67
=
{
.
reg_setup
=
ev67_reg_setup
,
.
cpu_setup
=
ev67_cpu_setup
,
.
reset_ctr
=
ev67_reset_ctr
,
.
handle_interrupt
=
ev67_handle_interrupt
,
.
cpu
=
OPROFILE_CPU_AXP_EV67
,
.
num_counters
=
20
,
.
can_set_proc_mode
=
0
,
};
include/asm-alpha/system.h
View file @
4788b02a
...
...
@@ -206,6 +206,7 @@ enum implver_enum {
enum
amask_enum
{
AMASK_BWX
=
(
1UL
<<
0
),
AMASK_FIX
=
(
1UL
<<
1
),
AMASK_CIX
=
(
1UL
<<
2
),
AMASK_MAX
=
(
1UL
<<
8
),
AMASK_PRECISE_TRAP
=
(
1UL
<<
9
),
};
...
...
include/linux/oprofile.h
View file @
4788b02a
...
...
@@ -37,6 +37,7 @@ enum oprofile_cpu {
OPROFILE_CPU_AXP_EV5
,
OPROFILE_CPU_AXP_PCA56
,
OPROFILE_CPU_AXP_EV6
,
OPROFILE_CPU_AXP_EV67
,
};
/* Operations structure to be filled in */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment