Skip to content
Snippets Groups Projects
Commit 6ecdbb4e authored by fu5520tp's avatar fu5520tp
Browse files

cleanup mod_gen folder, modify build file and add to readme

parent 4b94c0a0
No related branches found
No related tags found
No related merge requests found
build/
mod_gen/mods
mod_gen_new/test
\ No newline at end of file
obj-m += measure.o
all:
make -C /home/kelvin/git/master_thesis_linux/ M=$(PWD) modules
clean:
make -C /home/kelvin/git/master_thesis_linux/ M=$(PWD) clean
#!/bin/bash
#make
mkdir -p mnt
sudo mount -o loop ../build/qemu-image.img ./mnt
sudo cp ./mods/plan_same_v.ko ./mnt/root
sudo cp ./mods/random_v.ko ./mnt/root
sudo umount ./mnt
echo "All done. Run ./run_qemu.sh now"
if [ ! -d "/mnt/pb_utils/mod_gen" ]; then
echo "are you running this in chroot or the build system?"
exit 1
fi
cd /mnt/pb_utils/mod_gen/
rm -rf mods
./plan_to_module.pl
cd mods && make
echo "################################################"
echo "modules created and copied to /root"
echo "use 'insmod <file' to run within the test system"
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/kthread.h>
#include <../kernel/sched/sched.h>
MODULE_LICENSE("GPL");
static int __init pb_client_init(void)
{
struct rq *rq;
rq = this_rq();
set_pb_measure_on(&rq->pb);
return 0;
}
static void __exit pb_client_cleanup(void)
{
struct rq *rq;
rq = this_rq();
set_pb_measure_off(&rq->pb);
}
module_init(pb_client_init);
module_exit(pb_client_cleanup);
#!/usr/bin/perl
use Plan;
my $argc = @ARGV;
my $dmesg_log = $ARGV[0];
my $last_time = 0;
my $last_nr = 0;
my @results;
open (FILE, $dmesg_log);
while (<FILE>)
{
unless (/^.*(EXEC|IDLE),(START|STOP),\d*,\d*.*/)
{
next;
}
chomp;
($dirty_mode, $state, $entry, $time) = split(/,/);
$mode = "";
if ($dirty_mode =~ /.*(EXEC|IDLE).*/)
{
$mode = $1;
}
if ( $state eq "START" )
{
$last_time = $time;
$last_nr = $entry;
}
if ( $state eq "STOP" )
{
$result = $time - $last_time;
push(@results, { mode => $mode, nr => $last_nr, time => $result });
}
}
close (FILE);
if ( $argc > 1 )
{
my $plan_csv = $ARGV[1];
print_compared_result ($plan_csv, @results);
}
else
{
print_simple_result (@results);
}
sub print_simple_result
{
my (@results) = @_;
foreach (@results)
{
print ($_->{mode}.'['.$_->{nr}.']'.': '.$_->{time}."\n");
}
}
sub print_compared_result
{
my ($plan_csv_file, @results) = @_;
my @expected_results = parse_plan_csv($plan_csv_file);
push(@results, {mode => 'IDLE', nr => $results[-1]{nr}, time => 0});
for (my $i=0; $i <= $#results; $i++)
{
my $expected = $expected_results[$i]->{time};
my $actual = $results[$i]->{time};
my $diff = abs($expected - $actual);
print ($results[$i]->{mode}.'['.$results[$i]->{nr}.']'.' actual: '.$actual.', expected: '.$expected.', diff: '.$diff."\n");
}
}
......@@ -2,6 +2,10 @@
[% END %]
all:
make -C [% linux_src_dir %] M=$(PWD) modules
[% FOREACH module_name IN module_names %]cp [% module_name %].ko /root
[% END %]
clean:
make -C [% linux_src_dir %] M=$(PWD) clean
[% FOREACH module_name IN module_names %]rm /root/[% module_name %].ko
[% END %]
......@@ -27,7 +27,7 @@ static void init_rq(struct rq *rq)
{
struct pb_rq *pb_rq = &rq->pb;
struct task_struct *proxy_task;
int i;
proxy_task = kthread_create(loop_thread_func, NULL, "PB proxy thread");
proxy_task->sched_class = &pb_sched_class;
set_pb_plan_size(pb_rq, [% plan_size %]);
......
......@@ -20,6 +20,12 @@ cd /mnt
./build
```
## chroot into debian rootfs to build test modules
run `./chroot_image.sh`, this drops you in a shell on the created debian and run
```bash
/mnt/pb_utils/mod_gen/build.sh
```
# run the build kernel with the created rootfs
run `./run_qemu.sh`
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment