Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Kernel Program Behaviour Models
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
felixkhals
Kernel Program Behaviour Models
Commits
d4b2e4c8
Commit
d4b2e4c8
authored
2 years ago
by
fu5520tp
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup Performance Counter creation
parent
38e1bec6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
kernel/sched/pb.c
+9
-15
9 additions, 15 deletions
kernel/sched/pb.c
kernel/sched/perf_error_detection.c
+17
-25
17 additions, 25 deletions
kernel/sched/perf_error_detection.c
with
26 additions
and
40 deletions
kernel/sched/pb.c
+
9
−
15
View file @
d4b2e4c8
...
...
@@ -300,6 +300,11 @@ EXPORT_SYMBOL(pb_sched_class);
///////////////////// ProcFS Ausgabe ///////////////////////////////////
static
struct
plan_entry
dummy_plan
=
{
.
n_instr
=
20000
,
.
task_id
=
0xCAFE
,
.
task_struct
=
NULL
,
};
static
int
show_pbsched
(
struct
seq_file
*
seq
,
void
*
v
)
{
...
...
@@ -322,11 +327,7 @@ static int show_pbsched(struct seq_file *seq, void *v)
rq
=
cpu_rq
(
cpu
);
pb
=
&
(
rq
->
pb
);
//raw_spin_lock_irqsave(&rq->lock, flags);
perf_init_res
=
init_perf_event
(
&
pb
->
plan
[
pb
->
c_entry
],
&
event
);
printk
(
KERN_WARNING
"Hi! %d
\n
"
,
perf_init_res
);
perf_init_res
=
init_perf_event
(
&
dummy_plan
,
&
event
);
switch
(
pb
->
mode
)
{
case
PB_DISABLED_MODE
:
mode
=
'D'
;
break
;
...
...
@@ -335,12 +336,9 @@ static int show_pbsched(struct seq_file *seq, void *v)
default:
mode
=
'U'
;
break
;
}
perf_counter
=
__perf_event_count
(
event
);
printk
(
KERN_WARNING
"Hi! hier kommts %llu
\n
"
,
perf_counter
);
read_error
=
get_perf_counter
(
event
,
&
perf_counter
);
printk
(
KERN_WARNING
"
Hi! yo hier kommts
%llu
\n
"
,
perf_counter
);
printk
(
KERN_WARNING
"
get_perf_counter:
%llu
\n
"
,
perf_counter
);
terminate_perf_event
(
event
);
...
...
@@ -348,18 +346,14 @@ static int show_pbsched(struct seq_file *seq, void *v)
printk
(
KERN_WARNING
"Hi! FETCHING PERFORMANCE COUNTER IN PB SCHEDULER FAILED WITH %llu
\n
"
,
read_error
);
}
//raw_spin_unlock_irqrestore(&rq->lock, flags);
/* runqueue-specific stats */
seq_printf
(
seq
,
"cpu%d %c %u %llu
%llu
%llu
\n
"
,
"cpu%d %c %u %llu %llu
\n
"
,
cpu
,
mode
,
pb
->
c_entry
,
pb
->
count_pb_cycles
,
pb
->
count_admin_cycles
,
perf_counter
pb
->
count_admin_cycles
);
}
return
0
;
...
...
This diff is collapsed.
Click to expand it.
kernel/sched/perf_error_detection.c
+
17
−
25
View file @
d4b2e4c8
...
...
@@ -10,39 +10,34 @@
*/
static
struct
perf_event_attr
wd_hw_attr
=
{
.
type
=
PERF_TYPE_HARDWARE
,
.
config
=
PERF_COUNT_HW_INSTRUCTIONS
,
.
size
=
sizeof
(
struct
perf_event_attr
),
.
pinned
=
1
,
.
disabled
=
0
,
.
sample_period
=
1000000
,
//.exclude_kernel = 0,
.
exclude_hv
=
1
,
// excluding events that happen in the hypervisor
};
/*
* initialize perf event for new task
*/
int
init_perf_event
(
struct
plan_entry
*
plan_entry
,
struct
perf_event
**
pevent
){
struct
perf_event_attr
pe
;
//
memset(&pe, 0, sizeof(struct perf_event_attr));
memset
(
&
pe
,
0
,
sizeof
(
struct
perf_event_attr
));
pe
.
type
=
PERF_TYPE_HARDWARE
;
pe
.
size
=
sizeof
(
struct
perf_event_attr
);
pe
.
config
=
PERF_COUNT_HW_INSTRUCTIONS
;
pe
.
sample_period
=
10000000
;
pe
.
sample_period
=
plan_entry
->
n_instr
;
pe
.
disabled
=
0
;
// start the counter as soon as we're in userland
pe
.
pinned
=
1
;
// ?
pe
.
exclude_kernel
=
1
;
pe
.
exclude_hv
=
1
;
pe
.
precise_ip
=
2
;
// 2 SAMPLE_IP requested to have 0 skid.
pe
.
exclude_kernel
=
0
;
//////////////// DAS HABEN WIR AUS DAMIT WIR MIT KERNEL THREADS ARBEITEN KÖNNEN
pe
.
exclude_hv
=
1
;
// excluding events that happen in the hypervisor
// this throws exceptions on my system
//pe.precise_ip = 2; // 2 SAMPLE_IP requested to have 0 skid.
/* Not needed on 3.2? */
pe
.
wakeup_events
=
1
;
// pe.wakeup_events = 1;
printk
(
KERN_ALERT
"DEBUG: Passed %s %d
\n
"
,
__FUNCTION__
,
__LINE__
);
// cpu = -1 -> cpu independent (assumed to be regulated by plan)
*
pevent
=
perf_event_create
(
&
pe
,
0
,
plan_entry
->
task_struct
);
printk
(
KERN_ALERT
"DEBUG: Passed %s %d
\n
"
,
__FUNCTION__
,
__LINE__
);
if
(
IS_ERR
(
pevent
))
{
printk
(
KERN_WARNING
"PB ERROR INITIALISING PERF EVENT
\n
"
);
...
...
@@ -78,24 +73,21 @@ void overflow_handler(
struct
pb_rq
*
pb_rq
;
int
cpu
;
/* Ensure the watchdog never gets throttled */
event
->
hw
.
interrupts
=
0
;
cpu
=
0
;
cpu
=
smp_processor_id
();
pb_rq
=
&
cpu_rq
(
cpu
)
->
pb
;
if
(
pb_rq
->
is_initialized
)
printk
(
KERN_WARNING
"PB TASK %llu RAN TOO LONG
\n
"
,
pb_rq
->
plan
[
pb_rq
->
c_entry
].
task_id
);
printk
(
KERN_WARNING
"
OH:
PB TASK %llu RAN TOO LONG
\n
"
,
pb_rq
->
plan
[
pb_rq
->
c_entry
].
task_id
);
else
printk
(
KERN_WARNING
"PB TASK RAN TOO LONG
\n
"
);
printk
(
KERN_WARNING
"
OH:
PB TASK RAN TOO LONG
\n
"
);
}
struct
perf_event
*
perf_event_create
(
struct
perf_event_attr
*
hw_event_uptr
,
int
cpu
,
struct
task_struct
*
task_struct
)
{
return
perf_event_create_kernel_counter
(
&
wd_hw_at
tr
,
hw_event_up
tr
,
cpu
,
task_struct
,
/* per CPU */
task_struct
,
&
overflow_handler
,
NULL
/* What's meant by context? 'oprofile' uses NULL */
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment