Skip to contentSkip to conversation

pdflush cleanup

PATCH In review Andrew Morton 1 participant 1 message Jul 4, 2002

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 8/27 pdflush cleanup

Writeback/pdflush cleanup patch from Steven Augart

* Exposes nr_pdflush_threads as /proc/sys/vm/nr_pdflush_threads, read-only.

(I like this - I expect that management of the pdflush thread pool will be important for many-spindle machines, and this is a neat way of getting at the info).

* Adds minimum and maximum checking to the five writable pdflush and fs-writeback parameters.

* Minor indentation fix in sysctl.c

* mm/pdflush.c now includes linux/writeback.h, which prototypes pdflush_operation. This is so that the compiler can automatically check that the prototype matches the definition.

* Adds a few comments to existing code.

 include/linux/sysctl.h    |    6 +++++-
 include/linux/writeback.h |    7 +++++++
 kernel/sysctl.c           |   42 ++++++++++++++++++++++++++++++++++--------
 mm/page-writeback.c       |   12 +++++++++---
 mm/pdflush.c              |    8 +++++++-
 5 files changed, 62 insertions(+), 13 deletions(-)
include/linux/sysctl.h renamed from include/linux/sysctl.h~pdflush-cleanup +5 -1
@@ -30,7 +30,10 @@
 
 struct file;
 
-#define CTL_MAXNAME 10
+#define CTL_MAXNAME 10		/* how many path components do we allow in a
+				   call to sysctl?   In other words, what is
+				   the largest acceptable value for the nlen
+				   member of a struct __sysctl_args to have? */
 
 struct __sysctl_args {
 	int *name;
@@ -145,6 +148,7 @@ enum
 	VM_DIRTY_SYNC=13,	/* dirty_sync_ratio */
 	VM_DIRTY_WB_CS=14,	/* dirty_writeback_centisecs */
 	VM_DIRTY_EXPIRE_CS=15,	/* dirty_expire_centisecs */
+	VM_NR_PDFLUSH_THREADS=16, /* nr_pdflush_threads */
 };
 
 
include/linux/writeback.h renamed from include/linux/writeback.h~pdflush-cleanup +7 -0
@@ -49,15 +49,22 @@ static inline void wait_on_inode(struct 
 /*
  * mm/page-writeback.c
  */
+/* These 5 are exported to sysctl. */
 extern int dirty_background_ratio;
 extern int dirty_async_ratio;
 extern int dirty_sync_ratio;
 extern int dirty_writeback_centisecs;
 extern int dirty_expire_centisecs;
 
+
 void balance_dirty_pages(struct address_space *mapping);
 void balance_dirty_pages_ratelimited(struct address_space *mapping);
 int pdflush_operation(void (*fn)(unsigned long), unsigned long arg0);
 int do_writepages(struct address_space *mapping, int *nr_to_write);
 
+/* pdflush.c */
+extern int nr_pdflush_threads;	/* Global so it can be exported to sysctl
+				   read-only. */
+
+
 #endif		/* WRITEBACK_H */
kernel/sysctl.c renamed from kernel/sysctl.c~pdflush-cleanup +34 -8

58 lines not on this page · raw message

mm/page-writeback.c renamed from mm/page-writeback.c~pdflush-cleanup +9 -3
@@ -47,6 +47,8 @@
 #define SYNC_WRITEBACK_PAGES	1500
 
 
+/* The following parameters are exported via /proc/sys/vm */
+
 /*
  * Dirty memory thresholds, in percentages
  */
@@ -67,15 +69,18 @@ int dirty_async_ratio = 50;
 int dirty_sync_ratio = 60;
 
 /*
- * The interval between `kupdate'-style writebacks.
+ * The interval between `kupdate'-style writebacks, in centiseconds
+ * (hundredths of a second)
  */
 int dirty_writeback_centisecs = 5 * 100;
 
 /*
- * The largest amount of time for which data is allowed to remain dirty
+ * The longest amount of time for which data is allowed to remain dirty
  */
 int dirty_expire_centisecs = 30 * 100;
 
+/* End of sysctl-exported parameters */
+
 
 static void background_writeout(unsigned long _min_pages);
 
@@ -233,7 +238,8 @@ static void wb_kupdate(unsigned long arg
 static void wb_timer_fn(unsigned long unused)
 {
 	if (pdflush_operation(wb_kupdate, 0) < 0)
-		mod_timer(&wb_timer, jiffies + HZ);
+		mod_timer(&wb_timer, jiffies + HZ); /* delay 1 second */
+
 }
 
 static int __init wb_timer_init(void)
mm/pdflush.c renamed from mm/pdflush.c~pdflush-cleanup +7 -1
@@ -15,6 +15,9 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/suspend.h>
+#include <linux/sched.h>	// Needed by writeback.h
+#include <linux/fs.h>		// Needed by writeback.h
+#include <linux/writeback.h>	// Prototypes pdflush_operation()
 
 
 /*
@@ -44,8 +47,11 @@ static spinlock_t pdflush_lock = SPIN_LO
 /*
  * The count of currently-running pdflush threads.  Protected
  * by pdflush_lock.
+ *
+ * Readable by sysctl, but not writable.  Published to userspace at
+ * /proc/sys/vm/nr_pdflush_threads.
  */
-static int nr_pdflush_threads = 0;
+int nr_pdflush_threads = 0;
 
 /*
  * The time at which the pdflush thread pool last went empty

-