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
5d890d80
Commit
5d890d80
authored
2 years ago
by
FKHals
Browse files
Options
Downloads
Patches
Plain Diff
[DO NOT MERGE] Intermediate commit
parent
20c76ea2
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/fork.c
+13
-0
13 additions, 0 deletions
kernel/fork.c
pb_utils/pb_submitter/test_prog.c
+36
-11
36 additions, 11 deletions
pb_utils/pb_submitter/test_prog.c
with
49 additions
and
11 deletions
kernel/fork.c
+
13
−
0
View file @
5d890d80
...
@@ -98,6 +98,8 @@
...
@@ -98,6 +98,8 @@
#include
<trace/events/sched.h>
#include
<trace/events/sched.h>
#include
"sched/perf_error_detection.h"
#define CREATE_TRACE_POINTS
#define CREATE_TRACE_POINTS
#include
<trace/events/task.h>
#include
<trace/events/task.h>
...
@@ -2069,6 +2071,17 @@ long _do_fork(unsigned long clone_flags,
...
@@ -2069,6 +2071,17 @@ long _do_fork(unsigned long clone_flags,
}
}
put_pid
(
pid
);
put_pid
(
pid
);
/*
struct rq* rq = this_rq();
struct pb_rq *pb = &(rq->pb);
if (pb && pb->is_initialized) {
u64 perf_counter;
u64 read_error = get_perf_counter(pb->pevent, &perf_counter);
if (read_error) {
printk(KERN_WARNING "FORK: FETCHING PERFORMANCE COUNTER IN PB SCHEDULER FAILED WITH %llu\n", read_error);
}
printk("FORK: PERFORMANCE COUNTER: %llu", perf_counter);
}*/
}
else
{
}
else
{
nr
=
PTR_ERR
(
p
);
nr
=
PTR_ERR
(
p
);
}
}
...
...
This diff is collapsed.
Click to expand it.
pb_utils/pb_submitter/test_prog.c
+
36
−
11
View file @
5d890d80
#include
<stdio.h>
#include
<stdio.h>
#include
<unistd.h>
#include
<unistd.h>
#define NUM_CHILDS 1
int
main
(
void
)
int
main
(
void
)
{
{
int
i
;
int
i
d
;
int
j
;
int
j
;
pid_t
child_pid
,
wpid
;
int
status
=
0
;
// parent code (before child processes start)
{
// Make sure program is not finished before pb scheduler takes control
sleep
(
1
);
printf
(
"=========================================================
\n
"
);
printf
(
"I am the parent=%d and i am going to do some forking...
\n
"
,
getpid
());
}
// Make sure program is not finished before pb scheduler takes control
for
(
id
=
0
;
id
<
NUM_CHILDS
;
id
++
)
{
sleep
(
1
);
if
((
child_pid
=
fork
())
==
0
)
{
// child code
{
printf
(
"I am the child, return from fork=%d with parent=%d
\n
"
,
getpid
(),
getppid
());
// this outer for loop is around 8 instructions per iteration
// this for loop results in 4 cpu instructions per iteration
for
(
i
=
0
;
i
<
100
;
i
++
)
{
// nop, add, compare, jmp
// this for loop results in 4 cpu instructions per iteration
for
(
j
=
0
;
j
<
100000
;
j
++
){
// nop, add, compare, jmp
__asm__
volatile
(
"nop"
);
for
(
j
=
0
;
j
<
100000
;
j
++
){
}
__asm__
volatile
(
"nop"
);
printf
(
"Child %d exiting
\n
"
,
getpid
());
}
}
}
}
// barrier: let the father wait for all the child processes
while
((
wpid
=
wait
(
&
status
))
>
0
)
{};
// parent code (after all child processes end)
{
printf
(
"Parent exiting!
\n
"
);
// check if program runs && syscall to switch tasks
// check if program runs && syscall to switch tasks
printf
(
"run
#%d
completed
\n
"
,
i
);
-
printf
(
"run completed
\n
"
);
usleep
(
1
);
-
usleep
(
1
);
}
}
printf
(
"main end
\n
"
);
printf
(
"main end
\n
"
);
...
...
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