| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: uvm_pdaemon.c,v 1.93.4.2.4.13 2012/04/17 00:19:30 matt Exp $ */ | | 1 | /* $NetBSD: uvm_pdaemon.c,v 1.93.4.2.4.14 2012/04/27 20:41:09 matt Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1997 Charles D. Cranor and Washington University. | | 4 | * Copyright (c) 1997 Charles D. Cranor and Washington University. |
5 | * Copyright (c) 1991, 1993, The Regents of the University of California. | | 5 | * Copyright (c) 1991, 1993, The Regents of the University of California. |
6 | * | | 6 | * |
7 | * All rights reserved. | | 7 | * All rights reserved. |
8 | * | | 8 | * |
9 | * This code is derived from software contributed to Berkeley by | | 9 | * This code is derived from software contributed to Berkeley by |
10 | * The Mach Operating System project at Carnegie-Mellon University. | | 10 | * The Mach Operating System project at Carnegie-Mellon University. |
11 | * | | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | | 12 | * Redistribution and use in source and binary forms, with or without |
13 | * modification, are permitted provided that the following conditions | | 13 | * modification, are permitted provided that the following conditions |
14 | * are met: | | 14 | * are met: |
| @@ -61,27 +61,27 @@ | | | @@ -61,27 +61,27 @@ |
61 | * School of Computer Science | | 61 | * School of Computer Science |
62 | * Carnegie Mellon University | | 62 | * Carnegie Mellon University |
63 | * Pittsburgh PA 15213-3890 | | 63 | * Pittsburgh PA 15213-3890 |
64 | * | | 64 | * |
65 | * any improvements or extensions that they make and grant Carnegie the | | 65 | * any improvements or extensions that they make and grant Carnegie the |
66 | * rights to redistribute these changes. | | 66 | * rights to redistribute these changes. |
67 | */ | | 67 | */ |
68 | | | 68 | |
69 | /* | | 69 | /* |
70 | * uvm_pdaemon.c: the page daemon | | 70 | * uvm_pdaemon.c: the page daemon |
71 | */ | | 71 | */ |
72 | | | 72 | |
73 | #include <sys/cdefs.h> | | 73 | #include <sys/cdefs.h> |
74 | __KERNEL_RCSID(0, "$NetBSD: uvm_pdaemon.c,v 1.93.4.2.4.13 2012/04/17 00:19:30 matt Exp $"); | | 74 | __KERNEL_RCSID(0, "$NetBSD: uvm_pdaemon.c,v 1.93.4.2.4.14 2012/04/27 20:41:09 matt Exp $"); |
75 | | | 75 | |
76 | #include "opt_uvmhist.h" | | 76 | #include "opt_uvmhist.h" |
77 | #include "opt_readahead.h" | | 77 | #include "opt_readahead.h" |
78 | | | 78 | |
79 | #include <sys/param.h> | | 79 | #include <sys/param.h> |
80 | #include <sys/proc.h> | | 80 | #include <sys/proc.h> |
81 | #include <sys/systm.h> | | 81 | #include <sys/systm.h> |
82 | #include <sys/kernel.h> | | 82 | #include <sys/kernel.h> |
83 | #include <sys/pool.h> | | 83 | #include <sys/pool.h> |
84 | #include <sys/buf.h> | | 84 | #include <sys/buf.h> |
85 | #include <sys/atomic.h> | | 85 | #include <sys/atomic.h> |
86 | | | 86 | |
87 | #include <uvm/uvm.h> | | 87 | #include <uvm/uvm.h> |
| @@ -395,27 +395,26 @@ uvm_pageout(void *arg) | | | @@ -395,27 +395,26 @@ uvm_pageout(void *arg) |
395 | if (progress == false | | 395 | if (progress == false |
396 | || (pdinfo->pd_waiters == 0 | | 396 | || (pdinfo->pd_waiters == 0 |
397 | && TAILQ_FIRST(&pdinfo->pd_pendingq) == NULL)) { | | 397 | && TAILQ_FIRST(&pdinfo->pd_pendingq) == NULL)) { |
398 | UVMHIST_LOG(pdhist," <<SLEEPING>>",0,0,0,0); | | 398 | UVMHIST_LOG(pdhist," <<SLEEPING>>",0,0,0,0); |
399 | pdinfo->pd_stalled = !progress | | 399 | pdinfo->pd_stalled = !progress |
400 | && pdinfo->pd_waiters > 0; | | 400 | && pdinfo->pd_waiters > 0; |
401 | int timo = (pdinfo->pd_stalled ? 2 * hz : 0); | | 401 | int timo = (pdinfo->pd_stalled ? 2 * hz : 0); |
402 | UVM_UNLOCK_AND_WAIT(&uvm.pagedaemon, | | 402 | UVM_UNLOCK_AND_WAIT(&uvm.pagedaemon, |
403 | &uvm_fpageqlock, false, "pgdaemon", timo); | | 403 | &uvm_fpageqlock, false, "pgdaemon", timo); |
404 | uvmexp.pdwoke++; | | 404 | uvmexp.pdwoke++; |
405 | UVMHIST_LOG(pdhist," <<WOKE UP>>",0,0,0,0); | | 405 | UVMHIST_LOG(pdhist," <<WOKE UP>>",0,0,0,0); |
406 | want_tune = pdinfo->pd_stalled; | | 406 | want_tune = pdinfo->pd_stalled; |
407 | pdinfo->pd_stalled = false; | | 407 | pdinfo->pd_stalled = false; |
408 | progress = false; | | | |
409 | } else if (TAILQ_FIRST(&pdinfo->pd_pendingq) == NULL) { | | 408 | } else if (TAILQ_FIRST(&pdinfo->pd_pendingq) == NULL) { |
410 | /* | | 409 | /* |
411 | * Someone is waiting but no group are pending. | | 410 | * Someone is waiting but no group are pending. |
412 | * Let's kick ourselves to find groups that need work. | | 411 | * Let's kick ourselves to find groups that need work. |
413 | */ | | 412 | */ |
414 | uvm_kick_pdaemon(); | | 413 | uvm_kick_pdaemon(); |
415 | mutex_spin_exit(&uvm_fpageqlock); | | 414 | mutex_spin_exit(&uvm_fpageqlock); |
416 | } else { | | 415 | } else { |
417 | mutex_spin_exit(&uvm_fpageqlock); | | 416 | mutex_spin_exit(&uvm_fpageqlock); |
418 | } | | 417 | } |
419 | | | 418 | |
420 | /* | | 419 | /* |
421 | * now lock page queues and recompute inactive count | | 420 | * now lock page queues and recompute inactive count |
| @@ -430,26 +429,27 @@ uvm_pageout(void *arg) | | | @@ -430,26 +429,27 @@ uvm_pageout(void *arg) |
430 | || want_tune) { | | 429 | || want_tune) { |
431 | npages = uvmexp.npages; | | 430 | npages = uvmexp.npages; |
432 | extrapages = uvm_extrapages; | | 431 | extrapages = uvm_extrapages; |
433 | npggroups = uvmexp.npggroups; | | 432 | npggroups = uvmexp.npggroups; |
434 | uvmpd_tune(); | | 433 | uvmpd_tune(); |
435 | want_tune = false; | | 434 | want_tune = false; |
436 | } | | 435 | } |
437 | | | 436 | |
438 | /* | | 437 | /* |
439 | * Estimate a hint. Note that bufmem are returned to | | 438 | * Estimate a hint. Note that bufmem are returned to |
440 | * system only when entire pool page is empty. | | 439 | * system only when entire pool page is empty. |
441 | */ | | 440 | */ |
442 | bool need_wakeup = false; | | 441 | bool need_wakeup = false; |
| | | 442 | progress = false; |
443 | while ((grp = TAILQ_FIRST(&pdinfo->pd_pendingq)) != NULL) { | | 443 | while ((grp = TAILQ_FIRST(&pdinfo->pd_pendingq)) != NULL) { |
444 | KASSERT(grp->pgrp_npages > 0); | | 444 | KASSERT(grp->pgrp_npages > 0); |
445 | | | 445 | |
446 | uvmpdpol_tune(grp); | | 446 | uvmpdpol_tune(grp); |
447 | | | 447 | |
448 | /* | | 448 | /* |
449 | * While we are locked, remove this from the pendingq. | | 449 | * While we are locked, remove this from the pendingq. |
450 | */ | | 450 | */ |
451 | uvmpd_checkgroup(grp); | | 451 | uvmpd_checkgroup(grp); |
452 | KASSERT(grp->pgrp_scan_needed); | | 452 | KASSERT(grp->pgrp_scan_needed); |
453 | TAILQ_REMOVE(&pdinfo->pd_pendingq, grp, | | 453 | TAILQ_REMOVE(&pdinfo->pd_pendingq, grp, |
454 | pgrp_pending_link); | | 454 | pgrp_pending_link); |
455 | grp->pgrp_scan_needed = false; | | 455 | grp->pgrp_scan_needed = false; |