aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/vmmeter.h
diff options
context:
space:
mode:
authorMatthew Dillon <dillon@FreeBSD.org>1999-09-17 04:56:40 +0000
committerMatthew Dillon <dillon@FreeBSD.org>1999-09-17 04:56:40 +0000
commit90ecac61c08aaa62351a9835b6788470d91c0e72 (patch)
tree062792ff2a372baca6dc9a49cea43b6d5250b3f4 /sys/sys/vmmeter.h
parent1ed9e51a4de04accbd9ae52d42c169b9091e95d9 (diff)
downloadsrc-90ecac61c08aaa62351a9835b6788470d91c0e72.tar.gz
src-90ecac61c08aaa62351a9835b6788470d91c0e72.zip
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.
Notes
Notes: svn path=/head/; revision=51337
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 e382d900f6df..2ae45a378cdc 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 */