summaryrefslogtreecommitdiffstats
path: root/sys/sys/vmmeter.h
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>1999-09-17 04:56:40 +0000
committerdillon <dillon@FreeBSD.org>1999-09-17 04:56:40 +0000
commit4cb1921c9b97c10844176bdd697e070b4af7e717 (patch)
treef570abee242d756236804e1630a4d34162994241 /sys/sys/vmmeter.h
parent2600195b6aa16ae0dd89bbb61802b1058238e31e (diff)
downloadFreeBSD-src-4cb1921c9b97c10844176bdd697e070b4af7e717.zip
FreeBSD-src-4cb1921c9b97c10844176bdd697e070b4af7e717.tar.gz
Reviewed by: Alan Cox <alc@cs.rice.edu>, David Greenman <dg@root.com>
Replace various VM related page count calculations strewn over the VM code with inlines to aid in readability and to reduce fragility in the code where modules depend on the same test being performed to properly sleep and wakeup. Split out a portion of the page deactivation code into an inline in vm_page.c to support vm_page_dontneed(). add vm_page_dontneed(), which handles the madvise MADV_DONTNEED feature in a related commit coming up for vm_map.c/vm_object.c. This code prevents degenerate cases where an essentially active page may be rotated through a subset of the paging lists, resulting in premature disposal.
Diffstat (limited to 'sys/sys/vmmeter.h')
-rw-r--r--sys/sys/vmmeter.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/sys/sys/vmmeter.h b/sys/sys/vmmeter.h
index e382d90..2ae45a3 100644
--- a/sys/sys/vmmeter.h
+++ b/sys/sys/vmmeter.h
@@ -91,9 +91,95 @@ struct vmmeter {
u_int v_cache_max; /* max number of pages in cached obj */
u_int v_pageout_free_min; /* min number pages reserved for kernel */
u_int v_interrupt_free_min; /* reserved number of pages for int code */
+ u_int v_free_severe; /* severe depletion of pages below this pt */
};
#ifdef KERNEL
+
extern struct vmmeter cnt;
+
+/*
+ * Return TRUE if we are under our reserved low-free-pages threshold
+ */
+
+static __inline
+int
+vm_page_count_reserved(void)
+{
+ return (cnt.v_free_reserved > (cnt.v_free_count + cnt.v_cache_count));
+}
+
+/*
+ * Return TRUE if we are under our severe low-free-pages threshold
+ *
+ * This routine is typically used at the user<->system interface to determine
+ * whether we need to block in order to avoid a low memory deadlock.
+ */
+
+static __inline
+int
+vm_page_count_severe(void)
+{
+ return (cnt.v_free_severe > (cnt.v_free_count + cnt.v_cache_count));
+}
+
+/*
+ * Return TRUE if we are under our minimum low-free-pages threshold.
+ *
+ * This routine is typically used within the system to determine whether
+ * we can execute potentially very expensive code in terms of memory. It
+ * is also used by the pageout daemon to calculate when to sleep, when
+ * to wake waiters up, and when (after making a pass) to become more
+ * desparate.
+ */
+
+static __inline
+int
+vm_page_count_min(void)
+{
+ return (cnt.v_free_min > (cnt.v_free_count + cnt.v_cache_count));
+}
+
+/*
+ * Return TRUE if we have not reached our free page target during
+ * free page recovery operations.
+ */
+
+static __inline
+int
+vm_page_count_target(void)
+{
+ return (cnt.v_free_target > (cnt.v_free_count + cnt.v_cache_count));
+}
+
+/*
+ * Return the number of pages we need to free-up or cache
+ * A positive number indicates that we do not have enough free pages.
+ */
+
+static __inline
+int
+vm_paging_target(void)
+{
+ return (
+ (cnt.v_free_target + cnt.v_cache_min) -
+ (cnt.v_free_count + cnt.v_cache_count)
+ );
+}
+
+/*
+ * Return a positive number if the pagedaemon needs to be woken up.
+ */
+
+static __inline
+int
+vm_paging_needed(void)
+{
+ return (
+ (cnt.v_free_reserved + cnt.v_cache_min) >
+ (cnt.v_free_count + cnt.v_cache_count)
+ );
+}
+
#endif
/* systemwide totals computed every five seconds */
OpenPOWER on IntegriCloud