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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
From b176dda48436444f403443ae99379e11ad149104 Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Sat, 21 Feb 2015 01:13:16 +0100
Subject: [PATCH gnumach 3/3] xxx vm_page_queue_clean
---
linux/dev/glue/block.c | 2 +-
vm/memory_object.c | 4 ++--
vm/vm_debug.c | 2 +-
vm/vm_fault.c | 6 +++---
vm/vm_map.c | 2 +-
vm/vm_object.c | 4 ++--
vm/vm_pageout.c | 26 ++++++++++++++++++++------
xen/block.c | 2 +-
8 files changed, 31 insertions(+), 17 deletions(-)
diff --git a/linux/dev/glue/block.c b/linux/dev/glue/block.c
index da4ef38..3bd2c5b 100644
--- a/linux/dev/glue/block.c
+++ b/linux/dev/glue/block.c
@@ -1537,7 +1537,7 @@ device_read (void *d, ipc_port_t reply_port,
if (dirty)
{
PAGE_WAKEUP_DONE (m);
- m->dirty = TRUE;
+ vm_page_mark_dirty (m, TRUE);
vm_page_insert (m, object, o);
}
else
diff --git a/vm/memory_object.c b/vm/memory_object.c
index 097ed23..7a0dbb8 100644
--- a/vm/memory_object.c
+++ b/vm/memory_object.c
@@ -209,7 +209,7 @@ retry_lookup:
*/
data_m->busy = FALSE;
- data_m->dirty = FALSE;
+ vm_page_mark_dirty (data_m, FALSE);
pmap_clear_modify(data_m->phys_addr);
data_m->page_lock = lock_value;
@@ -555,7 +555,7 @@ memory_object_lock_result_t memory_object_lock_page(
*/
if (!m->dirty)
- m->dirty = pmap_is_modified(m->phys_addr);
+ vm_page_mark_dirty (m, pmap_is_modified(m->phys_addr));
if (m->dirty || (m->precious &&
should_return == MEMORY_OBJECT_RETURN_ALL)) {
diff --git a/vm/vm_debug.c b/vm/vm_debug.c
index 227090e..822ca86 100644
--- a/vm/vm_debug.c
+++ b/vm/vm_debug.c
@@ -352,7 +352,7 @@ mach_vm_object_pages(
if (((state & (VPI_STATE_NODATA|VPI_STATE_DIRTY)) == 0) &&
pmap_is_modified(p->phys_addr)) {
state |= VPI_STATE_DIRTY;
- p->dirty = TRUE;
+ vm_page_mark_dirty (p, TRUE);
}
vm_page_lock_queues();
diff --git a/vm/vm_fault.c b/vm/vm_fault.c
index 686156c..a48902a 100644
--- a/vm/vm_fault.c
+++ b/vm/vm_fault.c
@@ -978,7 +978,7 @@ vm_fault_return_t vm_fault_page(
vm_page_lock_queues();
pmap_page_protect(m->phys_addr, VM_PROT_NONE);
- copy_m->dirty = TRUE;
+ vm_page_mark_dirty (copy_m, TRUE);
vm_page_unlock_queues();
/*
@@ -1077,7 +1077,7 @@ vm_fault_return_t vm_fault_page(
*/
if (vm_fault_dirty_handling && (*protection & VM_PROT_WRITE))
- m->dirty = TRUE;
+ vm_page_mark_dirty (m, TRUE);
return(VM_FAULT_SUCCESS);
@@ -1957,7 +1957,7 @@ kern_return_t vm_fault_copy(
vm_page_zero_fill(dst_page);
else
vm_page_copy(src_page, dst_page);
- dst_page->dirty = TRUE;
+ vm_page_mark_dirty (dst_page, TRUE);
/*
* Unlock everything, and return
diff --git a/vm/vm_map.c b/vm/vm_map.c
index 6b13724..c229df5 100644
--- a/vm/vm_map.c
+++ b/vm/vm_map.c
@@ -2931,7 +2931,7 @@ insert_pages:
assert(!m->wanted);
m->busy = FALSE;
- m->dirty = TRUE;
+ vm_page_mark_dirty (m, TRUE);
vm_page_replace(m, object, old_last_offset + offset);
if (must_wire) {
vm_page_wire(m);
diff --git a/vm/vm_object.c b/vm/vm_object.c
index a96516c..f7d8fd2 100644
--- a/vm/vm_object.c
+++ b/vm/vm_object.c
@@ -587,7 +587,7 @@ void vm_object_terminate(
panic("vm_object_terminate.4 0x%x 0x%x", object, p);
if (!p->dirty)
- p->dirty = pmap_is_modified(p->phys_addr);
+ vm_page_mark_dirty (p, pmap_is_modified(p->phys_addr));
if (p->dirty || p->precious) {
p->busy = TRUE;
@@ -1089,7 +1089,7 @@ kern_return_t vm_object_copy_slowly(
*/
new_page->busy = FALSE;
- new_page->dirty = TRUE;
+ vm_page_mark_dirty (new_page, TRUE);
vm_object_lock(result_page->object);
PAGE_WAKEUP_DONE(result_page);
diff --git a/vm/vm_pageout.c b/vm/vm_pageout.c
index cee37ce..27193b0 100644
--- a/vm/vm_pageout.c
+++ b/vm/vm_pageout.c
@@ -293,7 +293,7 @@ vm_pageout_setup(
vm_page_insert(m, new_object, new_offset);
vm_page_unlock_queues();
- m->dirty = TRUE;
+ vm_page_mark_dirty (m, TRUE);
m->precious = FALSE;
m->page_lock = VM_PROT_NONE;
m->unlock_request = VM_PROT_NONE;
@@ -306,7 +306,7 @@ vm_pageout_setup(
vm_page_copy(m, new_m);
vm_object_lock(old_object);
- m->dirty = FALSE;
+ vm_page_mark_dirty (m, FALSE);
pmap_clear_modify(m->phys_addr);
/*
@@ -336,7 +336,7 @@ vm_pageout_setup(
* Use the new page below.
*/
m = new_m;
- m->dirty = TRUE;
+ vm_page_mark_dirty (m, TRUE);
assert(!m->precious);
PAGE_WAKEUP_DONE(m);
}
@@ -681,7 +681,21 @@ void vm_pageout_scan(void)
/*NOTREACHED*/
}
- // xxx try to drop a clean page here
+ /* Try to evict a clean page first. */
+ simple_lock (&vm_page_queue_clean);
+ m = (vm_page_t) queue_first (&vm_page_queue_clean);
+ while (1) {
+ if (!m->active && m->external) {
+ simple_unlock (&vm_page_queue_clean);
+ printf ("evicting page from clean list!!!\n");
+ goto got_one;
+ }
+
+ m = (vm_page_t) queue_next (&m->cleanq);
+ if (!m)
+ break;
+ }
+ simple_unlock (&vm_page_queue_clean);
vm_pageout_inactive++;
@@ -699,7 +713,7 @@ void vm_pageout_scan(void)
if (!m)
goto pause;
}
-
+ got_one:
object = m->object;
/*
@@ -782,7 +796,7 @@ void vm_pageout_scan(void)
m->busy = TRUE;
pmap_page_protect(m->phys_addr, VM_PROT_NONE);
if (!m->dirty)
- m->dirty = pmap_is_modified(m->phys_addr);
+ vm_page_mark_dirty (m, pmap_is_modified(m->phys_addr));
if (m->external) {
/* Figure out if we still care about this
diff --git a/xen/block.c b/xen/block.c
index d98b31e..175955a 100644
--- a/xen/block.c
+++ b/xen/block.c
@@ -539,7 +539,7 @@ device_read (void *d, ipc_port_t reply_port,
assert (m->busy);
vm_page_lock_queues ();
PAGE_WAKEUP_DONE (m);
- m->dirty = TRUE;
+ vm_page_mark_dirty (m, TRUE);
vm_page_insert (m, object, o);
vm_page_unlock_queues ();
o += PAGE_SIZE;
--
2.1.4
|