-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprecise_allocer.c
More file actions
153 lines (130 loc) · 3.05 KB
/
precise_allocer.c
File metadata and controls
153 lines (130 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include <sys/time.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <string.h>
#include <assert.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/time.h>
#include <stdbool.h>
#include <math.h>
#include <sys/resource.h> // needed for getrusage
#include <unistd.h>
#include "alloc_time.h"
#include "log.h"
#include "file_manager.h"
#define NUMS 4096
#define MAX_ALLOC (60000)
/* MAX number of pages*/
#define MAX_LIMIT 100000000
#define PAGE_SIZE 4096
/*Enable this for ubuntu or other machines for verbose*/
#if 1
#ifdef DEBUG
#undef DEBUG
#endif
#else
#define DEBUG
#endif
static lt_t vector = 0; /* Vector of files*/
static lt_t ipfvt = 0; /* if(ipfvt){ then the file is series of IPFVT }*/
static lt_t time_g = 0; /* Decision on Time Granularity */
static u64 stma = 0; /* STMA reset length */
static u64 ltma = 0; /* LTMA reset length */
#define OPT "IvV:hS:L:"
static void usage()
{
printf("memgobble\n");
printf("memgobble [options]\n");
printf("List of options:\n");
printf("\t-h : Display usage\n");
printf("\t-v : Switch verbose off\n");
rintf("\t-V <File name> : Vector of localities\n");
printf("\t-I : Vector is IPFVT\n");
printf("\t if CUSTOM_LINUX_KERNEL defined, then\n");
printf("\t\t -S <STMA Count> : STMA Value\n");
printf("\t\t -L <LTMA Count> : LTMA Value\n");
printf("\t endif\n");
}
static void Init()
{
alloc_mgr_init();
file_mgr_set_file_cnt(FILE_MAX);
if(stma || ltma) {
reset_stma_ltma(stma, ltma);
}
}
int main(int argc, char** argv)
{
double wcet;
double start = 0;
int cur_job = 0;
int verbose = 1;
int vector = 0;
int c;
if(argc > 1) {
while((c = getopt(argc, argv, OPT)) != -1) {
switch(c) {
case 'v':
verbose = 0;
break;
case 'V': /* Vector of localities */
vector = 1;
if(locality_vector_init(optarg)) {
PR_ERROR("Please provide valid file\n");
}
break;
case 'I': /* Vector is IPFVT */
ipfvt = 1;
time_g = T_nanoSECS;
break;
case 'S':
stma = atoll(optarg);
break;
case 'L':
ltma = atoll(optarg);
break;
case 'h':
default:
usage();
exit(1);
break;
}
}
}
init();
start = time_mgr_wctime(time_g);
printf("\nFORMAT:\n");
printf("Metric: Pages of size 4k\n");
printf("<PID>, <PHASE CNT>, <DURATION>, <FILEMAPCNT>, <ANONMAPCNT>, <TOTAL CNT>, <MINFAULT>, <MAJFAULT>, <TOTALFAULT>, <RSS(pages)>\n");
do {
struct rusage res1;
if(vector) {
lt_t alloc_cnt = 0;
if(get_nxt_alloc(&alloc_cnt, &wcet_ms, ipfvt)) {
reset_max_alloc_per_phase(alloc_cnt);
}
else {
break;
}
}
getrusage(RUSAGE_SELF, &res1);
if (verbose) {
printf("%d, %d, %.4f%s, %ld, %ld, %ld, %ld, %ld, %ld, %ld\n",
getpid(),
cur_job,
(wctime(time_g) - start), TIME_TO_STRING(time_g),
file_cnt, anon_cnt,
file_cnt + anon_cnt,
res1.ru_minflt, res1.ru_majflt,
res1.ru_minflt + res1.ru_majflt,
(res1.ru_maxrss/4));
}
cur_job++;
} while (job(wcet_ms, time_g));
return 0;
}