Commit 001a541e authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'writeback-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/wfg/linux

* 'writeback-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/wfg/linux:
  writeback: move MIN_WRITEBACK_PAGES to fs-writeback.c
  writeback: balanced_rate cannot exceed write bandwidth
  writeback: do strict bdi dirty_exceeded
  writeback: avoid tiny dirty poll intervals
  writeback: max, min and target dirty pause time
  writeback: dirty ratelimit - think time compensation
  btrfs: fix dirtied pages accounting on sub-page writes
  writeback: fix dirtied pages accounting on redirty
  writeback: fix dirtied pages accounting on sub-page writes
  writeback: charge leaked page dirties to active tasks
  writeback: Include all dirty inodes in background writeback
parents 40ba5879 bc31b86a
...@@ -1136,7 +1136,8 @@ static noinline int prepare_pages(struct btrfs_root *root, struct file *file, ...@@ -1136,7 +1136,8 @@ static noinline int prepare_pages(struct btrfs_root *root, struct file *file,
GFP_NOFS); GFP_NOFS);
} }
for (i = 0; i < num_pages; i++) { for (i = 0; i < num_pages; i++) {
clear_page_dirty_for_io(pages[i]); if (clear_page_dirty_for_io(pages[i]))
account_page_redirty(pages[i]);
set_page_extent_mapped(pages[i]); set_page_extent_mapped(pages[i]);
WARN_ON(!PageLocked(pages[i])); WARN_ON(!PageLocked(pages[i]));
} }
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/pagemap.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/freezer.h> #include <linux/freezer.h>
#include <linux/writeback.h> #include <linux/writeback.h>
...@@ -28,6 +29,11 @@ ...@@ -28,6 +29,11 @@
#include <linux/tracepoint.h> #include <linux/tracepoint.h>
#include "internal.h" #include "internal.h"
/*
* 4MB minimal write chunk size
*/
#define MIN_WRITEBACK_PAGES (4096UL >> (PAGE_CACHE_SHIFT - 10))
/* /*
* Passed into wb_writeback(), essentially a subset of writeback_control * Passed into wb_writeback(), essentially a subset of writeback_control
*/ */
...@@ -742,11 +748,17 @@ static long wb_writeback(struct bdi_writeback *wb, ...@@ -742,11 +748,17 @@ static long wb_writeback(struct bdi_writeback *wb,
if (work->for_background && !over_bground_thresh(wb->bdi)) if (work->for_background && !over_bground_thresh(wb->bdi))
break; break;
/*
* Kupdate and background works are special and we want to
* include all inodes that need writing. Livelock avoidance is
* handled by these works yielding to any other work so we are
* safe.
*/
if (work->for_kupdate) { if (work->for_kupdate) {
oldest_jif = jiffies - oldest_jif = jiffies -
msecs_to_jiffies(dirty_expire_interval * 10); msecs_to_jiffies(dirty_expire_interval * 10);
work->older_than_this = &oldest_jif; } else if (work->for_background)
} oldest_jif = jiffies;
trace_writeback_start(wb->bdi, work); trace_writeback_start(wb->bdi, work);
if (list_empty(&wb->b_io)) if (list_empty(&wb->b_io))
......
...@@ -1544,6 +1544,7 @@ struct task_struct { ...@@ -1544,6 +1544,7 @@ struct task_struct {
*/ */
int nr_dirtied; int nr_dirtied;
int nr_dirtied_pause; int nr_dirtied_pause;
unsigned long dirty_paused_when; /* start of a write-and-pause period */
#ifdef CONFIG_LATENCYTOP #ifdef CONFIG_LATENCYTOP
int latency_record_count; int latency_record_count;
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/fs.h> #include <linux/fs.h>
DECLARE_PER_CPU(int, dirty_throttle_leaks);
/* /*
* The 1/4 region under the global dirty thresh is for smooth dirty throttling: * The 1/4 region under the global dirty thresh is for smooth dirty throttling:
* *
...@@ -23,11 +25,6 @@ ...@@ -23,11 +25,6 @@
#define DIRTY_SCOPE 8 #define DIRTY_SCOPE 8
#define DIRTY_FULL_SCOPE (DIRTY_SCOPE / 2) #define DIRTY_FULL_SCOPE (DIRTY_SCOPE / 2)
/*
* 4MB minimal write chunk size
*/
#define MIN_WRITEBACK_PAGES (4096UL >> (PAGE_CACHE_SHIFT - 10))
struct backing_dev_info; struct backing_dev_info;
/* /*
...@@ -194,6 +191,8 @@ void writeback_set_ratelimit(void); ...@@ -194,6 +191,8 @@ void writeback_set_ratelimit(void);
void tag_pages_for_writeback(struct address_space *mapping, void tag_pages_for_writeback(struct address_space *mapping,
pgoff_t start, pgoff_t end); pgoff_t start, pgoff_t end);
void account_page_redirty(struct page *page);
/* pdflush.c */ /* pdflush.c */
extern int nr_pdflush_threads; /* Global so it can be exported to sysctl extern int nr_pdflush_threads; /* Global so it can be exported to sysctl
read-only. */ read-only. */
......
...@@ -300,12 +300,13 @@ TRACE_EVENT(balance_dirty_pages, ...@@ -300,12 +300,13 @@ TRACE_EVENT(balance_dirty_pages,
unsigned long dirty_ratelimit, unsigned long dirty_ratelimit,
unsigned long task_ratelimit, unsigned long task_ratelimit,
unsigned long dirtied, unsigned long dirtied,
unsigned long period,
long pause, long pause,
unsigned long start_time), unsigned long start_time),
TP_ARGS(bdi, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty, TP_ARGS(bdi, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty,
dirty_ratelimit, task_ratelimit, dirty_ratelimit, task_ratelimit,
dirtied, pause, start_time), dirtied, period, pause, start_time),
TP_STRUCT__entry( TP_STRUCT__entry(
__array( char, bdi, 32) __array( char, bdi, 32)
...@@ -320,6 +321,8 @@ TRACE_EVENT(balance_dirty_pages, ...@@ -320,6 +321,8 @@ TRACE_EVENT(balance_dirty_pages,
__field(unsigned int, dirtied_pause) __field(unsigned int, dirtied_pause)
__field(unsigned long, paused) __field(unsigned long, paused)
__field( long, pause) __field( long, pause)
__field(unsigned long, period)
__field( long, think)
), ),
TP_fast_assign( TP_fast_assign(
...@@ -336,6 +339,9 @@ TRACE_EVENT(balance_dirty_pages, ...@@ -336,6 +339,9 @@ TRACE_EVENT(balance_dirty_pages,
__entry->task_ratelimit = KBps(task_ratelimit); __entry->task_ratelimit = KBps(task_ratelimit);
__entry->dirtied = dirtied; __entry->dirtied = dirtied;
__entry->dirtied_pause = current->nr_dirtied_pause; __entry->dirtied_pause = current->nr_dirtied_pause;
__entry->think = current->dirty_paused_when == 0 ? 0 :
(long)(jiffies - current->dirty_paused_when) * 1000/HZ;
__entry->period = period * 1000 / HZ;
__entry->pause = pause * 1000 / HZ; __entry->pause = pause * 1000 / HZ;
__entry->paused = (jiffies - start_time) * 1000 / HZ; __entry->paused = (jiffies - start_time) * 1000 / HZ;
), ),
...@@ -346,7 +352,7 @@ TRACE_EVENT(balance_dirty_pages, ...@@ -346,7 +352,7 @@ TRACE_EVENT(balance_dirty_pages,
"bdi_setpoint=%lu bdi_dirty=%lu " "bdi_setpoint=%lu bdi_dirty=%lu "
"dirty_ratelimit=%lu task_ratelimit=%lu " "dirty_ratelimit=%lu task_ratelimit=%lu "
"dirtied=%u dirtied_pause=%u " "dirtied=%u dirtied_pause=%u "
"paused=%lu pause=%ld", "paused=%lu pause=%ld period=%lu think=%ld",
__entry->bdi, __entry->bdi,
__entry->limit, __entry->limit,
__entry->setpoint, __entry->setpoint,
...@@ -358,7 +364,9 @@ TRACE_EVENT(balance_dirty_pages, ...@@ -358,7 +364,9 @@ TRACE_EVENT(balance_dirty_pages,
__entry->dirtied, __entry->dirtied,
__entry->dirtied_pause, __entry->dirtied_pause,
__entry->paused, /* ms */ __entry->paused, /* ms */
__entry->pause /* ms */ __entry->pause, /* ms */
__entry->period, /* ms */
__entry->think /* ms */
) )
); );
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include <trace/events/sched.h> #include <trace/events/sched.h>
#include <linux/hw_breakpoint.h> #include <linux/hw_breakpoint.h>
#include <linux/oom.h> #include <linux/oom.h>
#include <linux/writeback.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/unistd.h> #include <asm/unistd.h>
...@@ -1035,6 +1036,8 @@ NORET_TYPE void do_exit(long code) ...@@ -1035,6 +1036,8 @@ NORET_TYPE void do_exit(long code)
validate_creds_for_do_exit(tsk); validate_creds_for_do_exit(tsk);
preempt_disable(); preempt_disable();
if (tsk->nr_dirtied)
__this_cpu_add(dirty_throttle_leaks, tsk->nr_dirtied);
exit_rcu(); exit_rcu();
/* causes final put_task_struct in finish_task_switch(). */ /* causes final put_task_struct in finish_task_switch(). */
tsk->state = TASK_DEAD; tsk->state = TASK_DEAD;
......
...@@ -1294,6 +1294,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, ...@@ -1294,6 +1294,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
p->nr_dirtied = 0; p->nr_dirtied = 0;
p->nr_dirtied_pause = 128 >> (PAGE_SHIFT - 10); p->nr_dirtied_pause = 128 >> (PAGE_SHIFT - 10);
p->dirty_paused_when = 0;
/* /*
* Ok, make it visible to the rest of the system. * Ok, make it visible to the rest of the system.
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment