diff options
author | Mike Larkin <mlarkin@cvs.openbsd.org> | 2014-07-11 03:06:09 +0000 |
---|---|---|
committer | Mike Larkin <mlarkin@cvs.openbsd.org> | 2014-07-11 03:06:09 +0000 |
commit | 1e40105f9d7186da8a1b4a40cfe605f6b31a33a1 (patch) | |
tree | 34479ec1ccff8398fbd30b0d1e45d30098c2f41f /sys/kern | |
parent | 857a5da492530b541a853523c85314cdd100479e (diff) |
Flush the buffercache to 16MB on hibernate and restore its previous max
size (kern.bufcachepercent) on resume, for better hibernate performance.
ok beck@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/vfs_bio.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 936777e4709..bab53313460 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_bio.c,v 1.156 2014/07/08 17:19:25 deraadt Exp $ */ +/* $OpenBSD: vfs_bio.c,v 1.157 2014/07/11 03:06:08 mlarkin Exp $ */ /* $NetBSD: vfs_bio.c,v 1.44 1996/06/11 11:15:36 pk Exp $ */ /* @@ -58,6 +58,10 @@ #include <sys/kernel.h> #include <sys/specdev.h> +#ifdef HIBERNATE +#include <sys/hibernate.h> +#endif /* HIBERNATE */ + int nobuffers; int needbuffer; struct bio_ops bioops; @@ -1228,3 +1232,31 @@ bufcache_release(struct buf *bp) } TAILQ_INSERT_TAIL(queue, bp, b_freelist); } + +#ifdef HIBERNATE +/* + * Flush buffercache to lowest value on hibernate suspend + */ +void +hibernate_suspend_bufcache(void) +{ + long save_buflowpages = buflowpages; + + /* Shrink buffercache to 16MB (4096 pages) */ + buflowpages = 4096; + bufadjust(buflowpages); + buflowpages = save_buflowpages; + bufhighpages = bufpages; +} + +void +hibernate_resume_bufcache(void) +{ + uint64_t dmapages, pgs; + + dmapages = uvm_pagecount(&dma_constraint); + pgs = bufcachepercent * dmapages / 100; + bufadjust(pgs); + bufhighpages = bufpages; +} +#endif /* HIBERNATE */ |