summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/subr_hibernate.c42
-rw-r--r--sys/sys/hibernate.h3
-rw-r--r--sys/uvm/uvm_pmemrange.c40
-rw-r--r--sys/uvm/uvm_pmemrange.h3
4 files changed, 45 insertions, 43 deletions
diff --git a/sys/kern/subr_hibernate.c b/sys/kern/subr_hibernate.c
index 51d376b126e..f9159b5853e 100644
--- a/sys/kern/subr_hibernate.c
+++ b/sys/kern/subr_hibernate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_hibernate.c,v 1.1 2011/07/08 17:58:16 ariane Exp $ */
+/* $OpenBSD: subr_hibernate.c,v 1.2 2011/07/08 18:20:10 ariane Exp $ */
/*
* Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl>
@@ -21,6 +21,7 @@
#include <sys/tree.h>
#include <sys/types.h>
#include <sys/systm.h>
+#include <uvm/uvm.h>
/*
@@ -222,3 +223,42 @@ hiballoc_init(struct hiballoc_arena *arena, void *p_ptr, size_t p_len)
return 0;
}
+
+
+/*
+ * Zero all free memory.
+ */
+void
+uvm_pmr_zero_everything(void)
+{
+ struct uvm_pmemrange *pmr;
+ struct vm_page *pg;
+ int i;
+
+ uvm_lock_fpageq();
+ TAILQ_FOREACH(pmr, &uvm.pmr_control.use, pmr_use) {
+ /* Zero single pages. */
+ while ((pg = TAILQ_FIRST(&pmr->single[UVM_PMR_MEMTYPE_DIRTY]))
+ != NULL) {
+ uvm_pmr_remove(pmr, pg);
+ uvm_pagezero(pg);
+ atomic_setbits_int(&pg->pg_flags, PG_ZERO);
+ uvmexp.zeropages++;
+ uvm_pmr_insert(pmr, pg, 0);
+ }
+
+ /* Zero multi page ranges. */
+ while ((pg = RB_ROOT(&pmr->size[UVM_PMR_MEMTYPE_DIRTY]))
+ != NULL) {
+ pg--; /* Size tree always has second page. */
+ uvm_pmr_remove(pmr, pg);
+ for (i = 0; i < pg->fpgsz; i++) {
+ uvm_pagezero(&pg[i]);
+ atomic_setbits_int(&pg[i].pg_flags, PG_ZERO);
+ uvmexp.zeropages++;
+ }
+ uvm_pmr_insert(pmr, pg, 0);
+ }
+ }
+ uvm_unlock_fpageq();
+}
diff --git a/sys/sys/hibernate.h b/sys/sys/hibernate.h
index cd3d18ab6e4..ebadd6ab5ed 100644
--- a/sys/sys/hibernate.h
+++ b/sys/sys/hibernate.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hibernate.h,v 1.1 2011/07/08 17:58:16 ariane Exp $ */
+/* $OpenBSD: hibernate.h,v 1.2 2011/07/08 18:20:10 ariane Exp $ */
/*
* Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl>
@@ -38,5 +38,6 @@ struct hiballoc_arena
void *hib_alloc(struct hiballoc_arena*, size_t);
void hib_free(struct hiballoc_arena*, void*);
int hiballoc_init(struct hiballoc_arena*, void*, size_t len);
+void uvm_pmr_zero_everything(void);
#endif /* _SYS_HIBERNATE_H_ */
diff --git a/sys/uvm/uvm_pmemrange.c b/sys/uvm/uvm_pmemrange.c
index 82b17de8eae..c39f01f3074 100644
--- a/sys/uvm/uvm_pmemrange.c
+++ b/sys/uvm/uvm_pmemrange.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_pmemrange.c,v 1.30 2011/07/08 18:15:44 ariane Exp $ */
+/* $OpenBSD: uvm_pmemrange.c,v 1.31 2011/07/08 18:20:10 ariane Exp $ */
/*
* Copyright (c) 2009, 2010 Ariane van der Steldt <ariane@stack.nl>
@@ -1945,44 +1945,6 @@ uvm_wakeup_pla(paddr_t low, psize_t len)
#ifndef SMALL_KERNEL
/*
- * Zero all free memory.
- */
-void
-uvm_pmr_zero_everything(void)
-{
- struct uvm_pmemrange *pmr;
- struct vm_page *pg;
- int i;
-
- uvm_lock_fpageq();
- TAILQ_FOREACH(pmr, &uvm.pmr_control.use, pmr_use) {
- /* Zero single pages. */
- while ((pg = TAILQ_FIRST(&pmr->single[UVM_PMR_MEMTYPE_DIRTY]))
- != NULL) {
- uvm_pmr_remove(pmr, pg);
- uvm_pagezero(pg);
- atomic_setbits_int(&pg->pg_flags, PG_ZERO);
- uvmexp.zeropages++;
- uvm_pmr_insert(pmr, pg, 0);
- }
-
- /* Zero multi page ranges. */
- while ((pg = RB_ROOT(&pmr->size[UVM_PMR_MEMTYPE_DIRTY]))
- != NULL) {
- pg--; /* Size tree always has second page. */
- uvm_pmr_remove(pmr, pg);
- for (i = 0; i < pg->fpgsz; i++) {
- uvm_pagezero(&pg[i]);
- atomic_setbits_int(&pg[i].pg_flags, PG_ZERO);
- uvmexp.zeropages++;
- }
- uvm_pmr_insert(pmr, pg, 0);
- }
- }
- uvm_unlock_fpageq();
-}
-
-/*
* Allocate the biggest contig chunk of memory.
*/
int
diff --git a/sys/uvm/uvm_pmemrange.h b/sys/uvm/uvm_pmemrange.h
index 2bd53868614..697d9637c53 100644
--- a/sys/uvm/uvm_pmemrange.h
+++ b/sys/uvm/uvm_pmemrange.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_pmemrange.h,v 1.9 2011/07/08 18:15:44 ariane Exp $ */
+/* $OpenBSD: uvm_pmemrange.h,v 1.10 2011/07/08 18:20:10 ariane Exp $ */
/*
* Copyright (c) 2009 Ariane van der Steldt <ariane@stack.nl>
@@ -124,7 +124,6 @@ int uvm_pmr_isfree(struct vm_page *pg);
#endif
#ifndef SMALL_KERNEL
-void uvm_pmr_zero_everything(void);
int uvm_pmr_alloc_pig(paddr_t*, psize_t*);
#endif /* SMALL_KERNEL */