Sat Mar 22 05:50:42 2008 UTC ()
Allow this to compile if LISTQ is undefined:

	- Put '#ifdef LISTQ' ... '#endif' pairs around pageq_insert_head()
	  and clockpro_insert_head().

	- Add missing argument to printf statement.


(bjs)
diff -r1.13 -r1.14 src/sys/uvm/uvm_pdpolicy_clockpro.c

cvs diff -r1.13 -r1.14 src/sys/uvm/uvm_pdpolicy_clockpro.c (expand / switch to unified diff)

--- src/sys/uvm/uvm_pdpolicy_clockpro.c 2008/02/07 12:27:38 1.13
+++ src/sys/uvm/uvm_pdpolicy_clockpro.c 2008/03/22 05:50:42 1.14
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: uvm_pdpolicy_clockpro.c,v 1.13 2008/02/07 12:27:38 yamt Exp $ */ 1/* $NetBSD: uvm_pdpolicy_clockpro.c,v 1.14 2008/03/22 05:50:42 bjs Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c)2005, 2006 YAMAMOTO Takashi, 4 * Copyright (c)2005, 2006 YAMAMOTO Takashi,
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -33,27 +33,27 @@ @@ -33,27 +33,27 @@
33 * approximation of the list of non-resident pages using hash: 33 * approximation of the list of non-resident pages using hash:
34 * http://linux-mm.org/ClockProApproximation 34 * http://linux-mm.org/ClockProApproximation
35 */ 35 */
36 36
37/* #define CLOCKPRO_DEBUG */ 37/* #define CLOCKPRO_DEBUG */
38 38
39#if defined(PDSIM) 39#if defined(PDSIM)
40 40
41#include "pdsim.h" 41#include "pdsim.h"
42 42
43#else /* defined(PDSIM) */ 43#else /* defined(PDSIM) */
44 44
45#include <sys/cdefs.h> 45#include <sys/cdefs.h>
46__KERNEL_RCSID(0, "$NetBSD: uvm_pdpolicy_clockpro.c,v 1.13 2008/02/07 12:27:38 yamt Exp $"); 46__KERNEL_RCSID(0, "$NetBSD: uvm_pdpolicy_clockpro.c,v 1.14 2008/03/22 05:50:42 bjs Exp $");
47 47
48#include "opt_ddb.h" 48#include "opt_ddb.h"
49 49
50#include <sys/param.h> 50#include <sys/param.h>
51#include <sys/proc.h> 51#include <sys/proc.h>
52#include <sys/systm.h> 52#include <sys/systm.h>
53#include <sys/kernel.h> 53#include <sys/kernel.h>
54#include <sys/hash.h> 54#include <sys/hash.h>
55 55
56#include <uvm/uvm.h> 56#include <uvm/uvm.h>
57#include <uvm/uvm_pdpolicy.h> 57#include <uvm/uvm_pdpolicy.h>
58#include <uvm/uvm_pdpolicy_impl.h> 58#include <uvm/uvm_pdpolicy_impl.h>
59 59
@@ -226,33 +226,35 @@ pageq_first(const pageq_t *q) @@ -226,33 +226,35 @@ pageq_first(const pageq_t *q)
226{ 226{
227 227
228 return TAILQ_FIRST(&q->q_q); 228 return TAILQ_FIRST(&q->q_q);
229} 229}
230 230
231static void 231static void
232pageq_insert_tail(pageq_t *q, struct vm_page *pg) 232pageq_insert_tail(pageq_t *q, struct vm_page *pg)
233{ 233{
234 234
235 TAILQ_INSERT_TAIL(&q->q_q, pg, pageq); 235 TAILQ_INSERT_TAIL(&q->q_q, pg, pageq);
236 q->q_len++; 236 q->q_len++;
237} 237}
238 238
 239#if defined(LISTQ)
239static void 240static void
240pageq_insert_head(pageq_t *q, struct vm_page *pg) 241pageq_insert_head(pageq_t *q, struct vm_page *pg)
241{ 242{
242 243
243 TAILQ_INSERT_HEAD(&q->q_q, pg, pageq); 244 TAILQ_INSERT_HEAD(&q->q_q, pg, pageq);
244 q->q_len++; 245 q->q_len++;
245} 246}
 247#endif
246 248
247static void 249static void
248pageq_remove(pageq_t *q, struct vm_page *pg) 250pageq_remove(pageq_t *q, struct vm_page *pg)
249{ 251{
250 252
251#if 1 253#if 1
252 KASSERT(clockpro_queue(&clockpro, clockpro_getq(pg)) == q); 254 KASSERT(clockpro_queue(&clockpro, clockpro_getq(pg)) == q);
253#endif 255#endif
254 KASSERT(q->q_len > 0); 256 KASSERT(q->q_len > 0);
255 TAILQ_REMOVE(&q->q_q, pg, pageq); 257 TAILQ_REMOVE(&q->q_q, pg, pageq);
256 q->q_len--; 258 q->q_len--;
257} 259}
258 260
@@ -271,35 +273,37 @@ pageq_remove_head(pageq_t *q) @@ -271,35 +273,37 @@ pageq_remove_head(pageq_t *q)
271} 273}
272 274
273/* ---------------------------------------- */ 275/* ---------------------------------------- */
274 276
275static void 277static void
276clockpro_insert_tail(struct clockpro_state *s, int qidx, struct vm_page *pg) 278clockpro_insert_tail(struct clockpro_state *s, int qidx, struct vm_page *pg)
277{ 279{
278 pageq_t *q = clockpro_queue(s, qidx); 280 pageq_t *q = clockpro_queue(s, qidx);
279  281
280 clockpro_setq(pg, qidx); 282 clockpro_setq(pg, qidx);
281 pageq_insert_tail(q, pg); 283 pageq_insert_tail(q, pg);
282} 284}
283 285
 286#if defined(LISTQ)
284static void 287static void
285clockpro_insert_head(struct clockpro_state *s, int qidx, struct vm_page *pg) 288clockpro_insert_head(struct clockpro_state *s, int qidx, struct vm_page *pg)
286{ 289{
287 pageq_t *q = clockpro_queue(s, qidx); 290 pageq_t *q = clockpro_queue(s, qidx);
288  291
289 clockpro_setq(pg, qidx); 292 clockpro_setq(pg, qidx);
290 pageq_insert_head(q, pg); 293 pageq_insert_head(q, pg);
291} 294}
292 295
 296#endif
293/* ---------------------------------------- */ 297/* ---------------------------------------- */
294 298
295typedef uint32_t nonres_cookie_t; 299typedef uint32_t nonres_cookie_t;
296#define NONRES_COOKIE_INVAL 0 300#define NONRES_COOKIE_INVAL 0
297 301
298typedef uintptr_t objid_t; 302typedef uintptr_t objid_t;
299 303
300/* 304/*
301 * XXX maybe these hash functions need reconsideration, 305 * XXX maybe these hash functions need reconsideration,
302 * given that hash distribution is critical here. 306 * given that hash distribution is critical here.
303 */ 307 */
304 308
305static uint32_t 309static uint32_t
@@ -1335,27 +1339,27 @@ clockpro_dump(void) @@ -1335,27 +1339,27 @@ clockpro_dump(void)
1335#if defined(LISTQ) 1339#if defined(LISTQ)
1336 if ((pg->pqflags & PQ_HOT) == 0) { 1340 if ((pg->pqflags & PQ_HOT) == 0) {
1337 printf("cold page in hotq: %p\n", pg); 1341 printf("cold page in hotq: %p\n", pg);
1338 } 1342 }
1339#endif /* defined(LISTQ) */ 1343#endif /* defined(LISTQ) */
1340 COUNT(pg) 1344 COUNT(pg)
1341 hotqlen++; 1345 hotqlen++;
1342 } 1346 }
1343 PRINTCOUNT("hotq"); 1347 PRINTCOUNT("hotq");
1344 1348
1345 INITCOUNT(); 1349 INITCOUNT();
1346 TAILQ_FOREACH(pg, &clockpro_queue(s, CLOCKPRO_LISTQ)->q_q, pageq) { 1350 TAILQ_FOREACH(pg, &clockpro_queue(s, CLOCKPRO_LISTQ)->q_q, pageq) {
1347#if !defined(LISTQ) 1351#if !defined(LISTQ)
1348 printf("listq %p\n"); 1352 printf("listq %p\n", pg);
1349#endif /* !defined(LISTQ) */ 1353#endif /* !defined(LISTQ) */
1350 if (clockpro_getq(pg) != CLOCKPRO_LISTQ) { 1354 if (clockpro_getq(pg) != CLOCKPRO_LISTQ) {
1351 printf("listq corrupt %p\n", pg); 1355 printf("listq corrupt %p\n", pg);
1352 } 1356 }
1353 COUNT(pg) 1357 COUNT(pg)
1354 listqlen++; 1358 listqlen++;
1355 } 1359 }
1356 PRINTCOUNT("listq"); 1360 PRINTCOUNT("listq");
1357 1361
1358 printf("newqlen=%d/%d, coldqlen=%d/%d, hotqlen=%d/%d, listqlen=%d/%d\n", 1362 printf("newqlen=%d/%d, coldqlen=%d/%d, hotqlen=%d/%d, listqlen=%d/%d\n",
1359 newqlen, pageq_len(clockpro_queue(s, CLOCKPRO_NEWQ)), 1363 newqlen, pageq_len(clockpro_queue(s, CLOCKPRO_NEWQ)),
1360 coldqlen, pageq_len(clockpro_queue(s, CLOCKPRO_COLDQ)), 1364 coldqlen, pageq_len(clockpro_queue(s, CLOCKPRO_COLDQ)),
1361 hotqlen, pageq_len(clockpro_queue(s, CLOCKPRO_HOTQ)), 1365 hotqlen, pageq_len(clockpro_queue(s, CLOCKPRO_HOTQ)),