-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsreadahead-patch
More file actions
109 lines (97 loc) · 2.34 KB
/
sreadahead-patch
File metadata and controls
109 lines (97 loc) · 2.34 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
Index: sreadahead.c
===================================================================
--- sreadahead.c (版本 38)
+++ sreadahead.c (工作副本)
@@ -54,6 +54,7 @@
#define PACK_PATH "/var/lib/sreadahead"
#define DEBUGFS_MNT "/var/lib/sreadahead/debugfs"
#define PACK_FILE "/var/lib/sreadahead/pack"
+#define LOG_FILE "/var/lib/sreadahead/trace"
#define MAXR 40000 /* trace file can be long */
#define MAXFL 128
@@ -391,6 +392,7 @@
static void trace_start(void)
{
+#if 0
int ret;
FILE *file;
char buf[4096];
@@ -423,6 +425,15 @@
perror("Unable to select open tracer\n");
exit(EXIT_FAILURE);
}
+ /*
+ file = fopen("tracing/iter_ctrl", "w");
+ if (!file) {
+ perror("Unable to select tracer\n");
+ exit(EXIT_FAILURE);
+ }
+ fprintf(file, "ftrace_printk");
+ fprintf(file, "noprint-parent");
+ fclose(file);*/
file = fopen("tracing/tracing_enabled", "w");
if (!file) {
@@ -443,7 +454,16 @@
chdir("/");
umount(DEBUGFS_MNT);
+#else
+ FILE *file;
+ file = fopen(LOG_FILE, "r");
+ if (!file)
+ system("modprobe openlog");
+ else
+ fclose(file);
+#endif
+
/* set this low, so we don't readahead way too much */
readahead_set_len(RA_SMALL);
}
@@ -466,7 +486,7 @@
/* return readahead size to normal */
readahead_set_len(RA_NORMAL);
-
+#if 0
/*
* by now the init process should have mounted debugfs on a logical
* location like /sys/kernel/debug, but if not then we temporarily
@@ -495,6 +515,10 @@
}
file = fopen("tracing/trace", "r");
+#else
+ system("rmmod openlog;mv /tmp/trace "LOG_FILE);
+ file = fopen(LOG_FILE, "r");
+#endif
if (!file) {
perror("Unable to open trace file\n");
exit(EXIT_FAILURE);
@@ -523,7 +547,12 @@
continue;
if (strncmp(filename, "/proc/", 6) == 0)
continue;
+ if (strncmp(filename, "/tmp/", 5) == 0)
+ continue;
+ if (atoi(len + 2) & O_WRONLY)
+ continue;
+
if (racount >= MAXR) {
perror("Max records exceeded!");
break;
@@ -557,10 +586,10 @@
first_ra = ra[0];
- chdir("/");
+ /*chdir("/");
if (unmount != 0) {
umount(DEBUGFS_MNT);
- }
+ }*/
/*
* sort and filter duplicates, and get memory blocks
Index: Makefile
===================================================================
--- Makefile (版本 38)
+++ Makefile (工作副本)
@@ -1,4 +1,4 @@
-CFLAGS ?= -Os -march=native -g
+CFLAGS ?= -Os -march=native
PROGS = sreadahead
VERSION = "1.0"