aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorWu Fengguang <fengguang.wu@intel.com>2011-06-11 21:25:42 -0400
committerWu Fengguang <fengguang.wu@intel.com>2011-12-18 01:20:27 -0500
commit83712358ba0a1497ce59a4f84ce4dd0f803fe6fc (patch)
treed17ab27a7bff50616e3b63ad137c004d9ccfbcb0 /include
parent32c7f202a4801252a0f3578807b75a961f792870 (diff)
writeback: dirty ratelimit - think time compensation
Compensate the task's think time when computing the final pause time, so that ->dirty_ratelimit can be executed accurately. think time := time spend outside of balance_dirty_pages() In the rare case that the task slept longer than the 200ms period time (result in negative pause time), the sleep time will be compensated in the following periods, too, if it's less than 1 second. Accumulated errors are carefully avoided as long as the max pause area is not hitted. Pseudo code: period = pages_dirtied / task_ratelimit; think = jiffies - dirty_paused_when; pause = period - think; 1) normal case: period > think pause = period - think dirty_paused_when = jiffies + pause nr_dirtied = 0 period time |===============================>| think time pause time |===============>|==============>| ------|----------------|---------------|------------------------ dirty_paused_when jiffies 2) no pause case: period <= think don't pause; reduce future pause time by: dirty_paused_when += period nr_dirtied = 0 period time |===============================>| think time |===================================================>| ------|--------------------------------+-------------------|---- dirty_paused_when jiffies Acked-by: Jan Kara <jack@suse.cz> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/sched.h1
-rw-r--r--include/trace/events/writeback.h14
2 files changed, 12 insertions, 3 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 1c4f3e9b9bc5..984c3b295978 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1527,6 +1527,7 @@ struct task_struct {
1527 */ 1527 */
1528 int nr_dirtied; 1528 int nr_dirtied;
1529 int nr_dirtied_pause; 1529 int nr_dirtied_pause;
1530 unsigned long dirty_paused_when; /* start of a write-and-pause period */
1530 1531
1531#ifdef CONFIG_LATENCYTOP 1532#ifdef CONFIG_LATENCYTOP
1532 int latency_record_count; 1533 int latency_record_count;
diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
index 99d1d0decf88..8588a8918023 100644
--- a/include/trace/events/writeback.h
+++ b/include/trace/events/writeback.h
@@ -300,12 +300,13 @@ TRACE_EVENT(balance_dirty_pages,
300 unsigned long dirty_ratelimit, 300 unsigned long dirty_ratelimit,
301 unsigned long task_ratelimit, 301 unsigned long task_ratelimit,
302 unsigned long dirtied, 302 unsigned long dirtied,
303 unsigned long period,
303 long pause, 304 long pause,
304 unsigned long start_time), 305 unsigned long start_time),
305 306
306 TP_ARGS(bdi, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty, 307 TP_ARGS(bdi, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty,
307 dirty_ratelimit, task_ratelimit, 308 dirty_ratelimit, task_ratelimit,
308 dirtied, pause, start_time), 309 dirtied, period, pause, start_time),
309 310
310 TP_STRUCT__entry( 311 TP_STRUCT__entry(
311 __array( char, bdi, 32) 312 __array( char, bdi, 32)
@@ -320,6 +321,8 @@ TRACE_EVENT(balance_dirty_pages,
320 __field(unsigned int, dirtied_pause) 321 __field(unsigned int, dirtied_pause)
321 __field(unsigned long, paused) 322 __field(unsigned long, paused)
322 __field( long, pause) 323 __field( long, pause)
324 __field(unsigned long, period)
325 __field( long, think)
323 ), 326 ),
324 327
325 TP_fast_assign( 328 TP_fast_assign(
@@ -336,6 +339,9 @@ TRACE_EVENT(balance_dirty_pages,
336 __entry->task_ratelimit = KBps(task_ratelimit); 339 __entry->task_ratelimit = KBps(task_ratelimit);
337 __entry->dirtied = dirtied; 340 __entry->dirtied = dirtied;
338 __entry->dirtied_pause = current->nr_dirtied_pause; 341 __entry->dirtied_pause = current->nr_dirtied_pause;
342 __entry->think = current->dirty_paused_when == 0 ? 0 :
343 (long)(jiffies - current->dirty_paused_when) * 1000/HZ;
344 __entry->period = period * 1000 / HZ;
339 __entry->pause = pause * 1000 / HZ; 345 __entry->pause = pause * 1000 / HZ;
340 __entry->paused = (jiffies - start_time) * 1000 / HZ; 346 __entry->paused = (jiffies - start_time) * 1000 / HZ;
341 ), 347 ),
@@ -346,7 +352,7 @@ TRACE_EVENT(balance_dirty_pages,
346 "bdi_setpoint=%lu bdi_dirty=%lu " 352 "bdi_setpoint=%lu bdi_dirty=%lu "
347 "dirty_ratelimit=%lu task_ratelimit=%lu " 353 "dirty_ratelimit=%lu task_ratelimit=%lu "
348 "dirtied=%u dirtied_pause=%u " 354 "dirtied=%u dirtied_pause=%u "
349 "paused=%lu pause=%ld", 355 "paused=%lu pause=%ld period=%lu think=%ld",
350 __entry->bdi, 356 __entry->bdi,
351 __entry->limit, 357 __entry->limit,
352 __entry->setpoint, 358 __entry->setpoint,
@@ -358,7 +364,9 @@ TRACE_EVENT(balance_dirty_pages,
358 __entry->dirtied, 364 __entry->dirtied,
359 __entry->dirtied_pause, 365 __entry->dirtied_pause,
360 __entry->paused, /* ms */ 366 __entry->paused, /* ms */
361 __entry->pause /* ms */ 367 __entry->pause, /* ms */
368 __entry->period, /* ms */
369 __entry->think /* ms */
362 ) 370 )
363); 371);
364 372