aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
Diffstat (limited to 'mm')
-rw-r--r--mm/pdflush.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/mm/pdflush.c b/mm/pdflush.c
index 235ac440c44e..f2caf96993f8 100644
--- a/mm/pdflush.c
+++ b/mm/pdflush.c
@@ -58,6 +58,14 @@ static DEFINE_SPINLOCK(pdflush_lock);
58int nr_pdflush_threads = 0; 58int nr_pdflush_threads = 0;
59 59
60/* 60/*
61 * The max/min number of pdflush threads. R/W by sysctl at
62 * /proc/sys/vm/nr_pdflush_threads_max/min
63 */
64int nr_pdflush_threads_max __read_mostly = MAX_PDFLUSH_THREADS;
65int nr_pdflush_threads_min __read_mostly = MIN_PDFLUSH_THREADS;
66
67
68/*
61 * The time at which the pdflush thread pool last went empty 69 * The time at which the pdflush thread pool last went empty
62 */ 70 */
63static unsigned long last_empty_jifs; 71static unsigned long last_empty_jifs;
@@ -68,7 +76,7 @@ static unsigned long last_empty_jifs;
68 * Thread pool management algorithm: 76 * Thread pool management algorithm:
69 * 77 *
70 * - The minimum and maximum number of pdflush instances are bound 78 * - The minimum and maximum number of pdflush instances are bound
71 * by MIN_PDFLUSH_THREADS and MAX_PDFLUSH_THREADS. 79 * by nr_pdflush_threads_min and nr_pdflush_threads_max.
72 * 80 *
73 * - If there have been no idle pdflush instances for 1 second, create 81 * - If there have been no idle pdflush instances for 1 second, create
74 * a new one. 82 * a new one.
@@ -134,14 +142,13 @@ static int __pdflush(struct pdflush_work *my_work)
134 * To throttle creation, we reset last_empty_jifs. 142 * To throttle creation, we reset last_empty_jifs.
135 */ 143 */
136 if (time_after(jiffies, last_empty_jifs + 1 * HZ)) { 144 if (time_after(jiffies, last_empty_jifs + 1 * HZ)) {
137 if (list_empty(&pdflush_list)) { 145 if (list_empty(&pdflush_list) &&
138 if (nr_pdflush_threads < MAX_PDFLUSH_THREADS) { 146 nr_pdflush_threads < nr_pdflush_threads_max) {
139 last_empty_jifs = jiffies; 147 last_empty_jifs = jiffies;
140 nr_pdflush_threads++; 148 nr_pdflush_threads++;
141 spin_unlock_irq(&pdflush_lock); 149 spin_unlock_irq(&pdflush_lock);
142 start_one_pdflush_thread(); 150 start_one_pdflush_thread();
143 spin_lock_irq(&pdflush_lock); 151 spin_lock_irq(&pdflush_lock);
144 }
145 } 152 }
146 } 153 }
147 154
@@ -153,7 +160,7 @@ static int __pdflush(struct pdflush_work *my_work)
153 */ 160 */
154 if (list_empty(&pdflush_list)) 161 if (list_empty(&pdflush_list))
155 continue; 162 continue;
156 if (nr_pdflush_threads <= MIN_PDFLUSH_THREADS) 163 if (nr_pdflush_threads <= nr_pdflush_threads_min)
157 continue; 164 continue;
158 pdf = list_entry(pdflush_list.prev, struct pdflush_work, list); 165 pdf = list_entry(pdflush_list.prev, struct pdflush_work, list);
159 if (time_after(jiffies, pdf->when_i_went_to_sleep + 1 * HZ)) { 166 if (time_after(jiffies, pdf->when_i_went_to_sleep + 1 * HZ)) {
@@ -259,9 +266,9 @@ static int __init pdflush_init(void)
259 * Pre-set nr_pdflush_threads... If we fail to create, 266 * Pre-set nr_pdflush_threads... If we fail to create,
260 * the count will be decremented. 267 * the count will be decremented.
261 */ 268 */
262 nr_pdflush_threads = MIN_PDFLUSH_THREADS; 269 nr_pdflush_threads = nr_pdflush_threads_min;
263 270
264 for (i = 0; i < MIN_PDFLUSH_THREADS; i++) 271 for (i = 0; i < nr_pdflush_threads_min; i++)
265 start_one_pdflush_thread(); 272 start_one_pdflush_thread();
266 return 0; 273 return 0;
267} 274}