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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
felixkhals
Kernel Program Behaviour Models
Commits
a1d9464b
Commit
a1d9464b
authored
Sep 15, 2022
by
mandersch
Browse files
Options
Downloads
Patches
Plain Diff
Update module generation, add comments on structs, fix set_pb_pln_entry function
parent
8f28145e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
kernel/sched/pb.c
+3
-2
3 additions, 2 deletions
kernel/sched/pb.c
kernel/sched/sched.h
+9
-10
9 additions, 10 deletions
kernel/sched/sched.h
pb_utils/mod_gen/tmpl/module.tt
+1
-1
1 addition, 1 deletion
pb_utils/mod_gen/tmpl/module.tt
with
13 additions
and
13 deletions
kernel/sched/pb.c
+
3
−
2
View file @
a1d9464b
...
@@ -86,13 +86,14 @@ int pb_submit_plan(struct rq *rq)
...
@@ -86,13 +86,14 @@ int pb_submit_plan(struct rq *rq)
* Must be volatile to ensure correct initialization order
* Must be volatile to ensure correct initialization order
*/
*/
volatile
struct
pb_rq
*
pb
=
(
volatile
struct
pb_rq
*
)(
&
(
rq
->
pb
));
volatile
struct
pb_rq
*
pb
=
(
volatile
struct
pb_rq
*
)(
&
(
rq
->
pb
));
int
perf_init_res
;
int
i
=
0
;
int
i
=
0
;
if
(
pb
->
mode
!=
PB_DISABLED_MODE
)
{
if
(
pb
->
mode
!=
PB_DISABLED_MODE
)
{
return
-
1
;
return
-
1
;
}
}
int
perf_init_res
=
init_perf_event
(
&
pb
->
plan
[
i
],
&
pb
->
pevent
);
perf_init_res
=
init_perf_event
(
&
pb
->
plan
[
i
],
&
pb
->
pevent
);
if
(
perf_init_res
<
0
)
{
if
(
perf_init_res
<
0
)
{
//initialization error detection/handling could happen here
//initialization error detection/handling could happen here
printk
(
KERN_WARNING
"PB INIT,%u: FAILED OPEN PERF EVENT
\n
"
,
i
);
printk
(
KERN_WARNING
"PB INIT,%u: FAILED OPEN PERF EVENT
\n
"
,
i
);
...
@@ -129,7 +130,7 @@ EXPORT_SYMBOL(set_pb_plan_size);
...
@@ -129,7 +130,7 @@ EXPORT_SYMBOL(set_pb_plan_size);
void
set_pb_plan_entry
(
struct
pb_rq
*
pb_rq
,
unsigned
int
i
,
u64
n_instr
,
u64
task_id
,
struct
task_struct
*
task_struct
)
void
set_pb_plan_entry
(
struct
pb_rq
*
pb_rq
,
unsigned
int
i
,
u64
n_instr
,
u64
task_id
,
struct
task_struct
*
task_struct
)
{
{
pb_rq
->
plan
[
i
].
n_instr
=
n_instr
;
pb_rq
->
plan
[
i
].
n_instr
=
n_instr
;
pb_rq
->
plan
[
i
].
task_id
=
i
;
pb_rq
->
plan
[
i
].
task_id
=
task_id
;
pb_rq
->
plan
[
i
].
task_struct
=
task_struct
;
pb_rq
->
plan
[
i
].
task_struct
=
task_struct
;
}
}
EXPORT_SYMBOL
(
set_pb_plan_entry
);
EXPORT_SYMBOL
(
set_pb_plan_entry
);
...
...
This diff is collapsed.
Click to expand it.
kernel/sched/sched.h
+
9
−
10
View file @
a1d9464b
...
@@ -526,7 +526,7 @@ enum pb_mode
...
@@ -526,7 +526,7 @@ enum pb_mode
struct
plan_entry
struct
plan_entry
{
{
u64
n_instr
;
// number of instructions in the entry
u64
n_instr
;
// number of instructions in the entry
u64
task_id
;
u64
task_id
;
// identifier of the plan entry
struct
task_struct
*
task_struct
;
// linux task struct
struct
task_struct
*
task_struct
;
// linux task struct
u64
n_instr_counted
;
// number of instructions we counted for the entry
u64
n_instr_counted
;
// number of instructions we counted for the entry
};
};
...
@@ -541,9 +541,9 @@ struct pb_init_struct
...
@@ -541,9 +541,9 @@ struct pb_init_struct
};
};
struct
pb_plan
{
struct
pb_plan
{
pid_t
pid
;
pid_t
pid
;
// process_id of the prgramm tp execute with the plan
uint64_t
*
inst_cnt
;
uint64_t
*
inst_cnt
;
// array of estimated instructions for each task
size_t
num_tasks
;
size_t
num_tasks
;
// number of tasks in the plan
};
};
struct
pb_rq
struct
pb_rq
...
@@ -559,9 +559,9 @@ struct pb_rq
...
@@ -559,9 +559,9 @@ struct pb_rq
u64
n_admin_cycles
;
// amount of timer ticks before PB tasks are allowed to run
u64
n_admin_cycles
;
// amount of timer ticks before PB tasks are allowed to run
u64
count_admin_cycles
;
// current timer tick count for admin tasks
u64
count_admin_cycles
;
// current timer tick count for admin tasks
enum
pb_mode
mode
;
enum
pb_mode
mode
;
// current scheduler mode
u64
total_instr
;
u64
total_instr
;
// total counted instructions for current plan
struct
perf_event
*
pevent
;
// linux perf handle
struct
perf_event
*
pevent
;
// linux perf handle
...
@@ -570,10 +570,9 @@ struct pb_rq
...
@@ -570,10 +570,9 @@ struct pb_rq
* this variable must be initialized last
* this variable must be initialized last
*/
*/
volatile
int
is_initialized
;
volatile
int
is_initialized
;
// volatile int need_mode_change;
volatile
int
is_preempted
;
// flag determining whether the last task has been prematurely preempted during last mode switch
volatile
int
is_preempted
;
volatile
int
is_in_critical
;
// flag determining whether the scheduler is in the critical section in pick_next_task_pb
volatile
int
is_in_critical
;
raw_spinlock_t
*
pb_lock
;
// spinlock used to deactivate interrupts especially when handling perf-events
raw_spinlock_t
*
pb_lock
;
};
};
int
pb_submit_plan
(
struct
rq
*
rq
);
int
pb_submit_plan
(
struct
rq
*
rq
);
...
...
This diff is collapsed.
Click to expand it.
pb_utils/mod_gen/tmpl/module.tt
+
1
−
1
View file @
a1d9464b
...
@@ -31,7 +31,7 @@ static void init_rq(struct rq *rq)
...
@@ -31,7 +31,7 @@ static void init_rq(struct rq *rq)
proxy_task = kthread_create(loop_thread_func, NULL, "PB proxy thread");
proxy_task = kthread_create(loop_thread_func, NULL, "PB proxy thread");
proxy_task->sched_class = &pb_sched_class;
proxy_task->sched_class = &pb_sched_class;
set_pb_plan_size(pb_rq, [% plan_size %]);
set_pb_plan_size(pb_rq, [% plan_size %]);
[% FOREACH entry IN plan %]set_pb_plan_entry(pb_rq, [%entry.index%], [%entry.exec_t%], [%entry.i
dle_t
%], proxy_task);
[% FOREACH entry IN plan %]set_pb_plan_entry(pb_rq, [%entry.index%], [%entry.exec_t%], [%entry.i
ndex
%], proxy_task);
[% END %]
[% END %]
pb_submit_plan(rq);
pb_submit_plan(rq);
...
...
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