From: Ethan Solomita <solo@google.com>
To: linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@google.com>,
a.p.zijlstra@chello.nl
Subject: [RFC 7/7] cpuset dirty limits
Date: Thu, 31 May 2007 23:17:35 -0700 [thread overview]
Message-ID: <465FB9FF.4000302@google.com> (raw)
In-Reply-To: <465FB6CF.4090801@google.com>
Per cpuset dirty ratios
This implements dirty ratios per cpuset. Two new files are added
to the cpuset directories:
background_dirty_ratio Percentage at which background writeback starts
throttle_dirty_ratio Percentage at which the application is throttled
and we start synchrononous writeout.
Both variables are set to -1 by default which means that the global
limits (/proc/sys/vm/vm_dirty_ratio and /proc/sys/vm/dirty_background_ratio)
are used for a cpuset.
Originally by Christoph Lameter <clameter@sgi.com>
Signed-off-by: Ethan Solomita <solo@google.com>
---
diff -uprN -X 0/Documentation/dontdiff 6/include/linux/cpuset.h 7/include/linux/cpuset.h
--- 6/include/linux/cpuset.h 2007-05-30 11:39:17.000000000 -0700
+++ 7/include/linux/cpuset.h 2007-05-30 11:39:48.000000000 -0700
@@ -75,6 +75,7 @@ static inline int cpuset_do_slab_mem_spr
extern void cpuset_track_online_nodes(void);
+extern void cpuset_get_current_ratios(int *background, int *ratio);
/*
* We need macros since struct address_space is not defined yet
*/
diff -uprN -X 0/Documentation/dontdiff 6/kernel/cpuset.c 7/kernel/cpuset.c
--- 6/kernel/cpuset.c 2007-05-30 11:39:17.000000000 -0700
+++ 7/kernel/cpuset.c 2007-05-30 11:39:48.000000000 -0700
@@ -49,6 +49,7 @@
#include <linux/time.h>
#include <linux/backing-dev.h>
#include <linux/sort.h>
+#include <linux/writeback.h>
#include <asm/uaccess.h>
#include <asm/atomic.h>
@@ -99,6 +100,9 @@ struct cpuset {
int mems_generation;
struct fmeter fmeter; /* memory_pressure filter */
+
+ int background_dirty_ratio;
+ int throttle_dirty_ratio;
};
/* bits in struct cpuset flags field */
@@ -176,6 +180,8 @@ static struct cpuset top_cpuset = {
.count = ATOMIC_INIT(0),
.sibling = LIST_HEAD_INIT(top_cpuset.sibling),
.children = LIST_HEAD_INIT(top_cpuset.children),
+ .background_dirty_ratio = -1,
+ .throttle_dirty_ratio = -1,
};
static struct vfsmount *cpuset_mount;
@@ -1030,6 +1036,21 @@ static int update_flag(cpuset_flagbits_t
return 0;
}
+static int update_int(int *cs_int, char *buf, int min, int max)
+{
+ char *endp;
+ int val;
+
+ val = simple_strtol(buf, &endp, 10);
+ if (val < min || val > max)
+ return -EINVAL;
+
+ mutex_lock(&callback_mutex);
+ *cs_int = val;
+ mutex_unlock(&callback_mutex);
+ return 0;
+}
+
/*
* Frequency meter - How fast is some event occurring?
*
@@ -1238,6 +1259,8 @@ typedef enum {
FILE_SPREAD_PAGE,
FILE_SPREAD_SLAB,
FILE_TASKLIST,
+ FILE_THROTTLE_DIRTY_RATIO,
+ FILE_BACKGROUND_DIRTY_RATIO,
} cpuset_filetype_t;
static ssize_t cpuset_common_file_write(struct file *file,
@@ -1308,6 +1331,12 @@ static ssize_t cpuset_common_file_write(
case FILE_TASKLIST:
retval = attach_task(cs, buffer, &pathbuf);
break;
+ case FILE_BACKGROUND_DIRTY_RATIO:
+ retval = update_int(&cs->background_dirty_ratio, buffer, -1, 100);
+ break;
+ case FILE_THROTTLE_DIRTY_RATIO:
+ retval = update_int(&cs->throttle_dirty_ratio, buffer, -1, 100);
+ break;
default:
retval = -EINVAL;
goto out2;
@@ -1420,6 +1449,12 @@ static ssize_t cpuset_common_file_read(s
case FILE_SPREAD_SLAB:
*s++ = is_spread_slab(cs) ? '1' : '0';
break;
+ case FILE_BACKGROUND_DIRTY_RATIO:
+ s += sprintf(s, "%d", cs->background_dirty_ratio);
+ break;
+ case FILE_THROTTLE_DIRTY_RATIO:
+ s += sprintf(s, "%d", cs->throttle_dirty_ratio);
+ break;
default:
retval = -EINVAL;
goto out;
@@ -1788,6 +1823,16 @@ static struct cftype cft_spread_slab = {
.private = FILE_SPREAD_SLAB,
};
+static struct cftype cft_background_dirty_ratio = {
+ .name = "background_dirty_ratio",
+ .private = FILE_BACKGROUND_DIRTY_RATIO,
+};
+
+static struct cftype cft_throttle_dirty_ratio = {
+ .name = "throttle_dirty_ratio",
+ .private = FILE_THROTTLE_DIRTY_RATIO,
+};
+
static int cpuset_populate_dir(struct dentry *cs_dentry)
{
int err;
@@ -1810,6 +1855,10 @@ static int cpuset_populate_dir(struct de
return err;
if ((err = cpuset_add_file(cs_dentry, &cft_spread_slab)) < 0)
return err;
+ if ((err = cpuset_add_file(cs_dentry, &cft_background_dirty_ratio)) < 0)
+ return err;
+ if ((err = cpuset_add_file(cs_dentry, &cft_throttle_dirty_ratio)) < 0)
+ return err;
if ((err = cpuset_add_file(cs_dentry, &cft_tasks)) < 0)
return err;
return 0;
@@ -1849,6 +1898,8 @@ static long cpuset_create(struct cpuset
INIT_LIST_HEAD(&cs->children);
cs->mems_generation = cpuset_mems_generation++;
fmeter_init(&cs->fmeter);
+ cs->background_dirty_ratio = parent->background_dirty_ratio;
+ cs->throttle_dirty_ratio = parent->throttle_dirty_ratio;
cs->parent = parent;
@@ -2483,8 +2534,30 @@ int cpuset_mem_spread_node(void)
}
EXPORT_SYMBOL_GPL(cpuset_mem_spread_node);
-#if MAX_NUMNODES > BITS_PER_LONG
+/*
+ * Determine the dirty ratios for the currently active cpuset
+ */
+void cpuset_get_current_ratios(int *background_ratio, int *throttle_ratio)
+{
+ int background = -1;
+ int throttle = -1;
+ struct task_struct *tsk = current;
+
+ task_lock(tsk);
+ background = tsk->cpuset->background_dirty_ratio;
+ throttle = tsk->cpuset->throttle_dirty_ratio;
+ task_unlock(tsk);
+ if (background == -1)
+ background = dirty_background_ratio;
+ if (throttle == -1)
+ throttle = vm_dirty_ratio;
+
+ *background_ratio = background;
+ *throttle_ratio = throttle;
+}
+
+#if MAX_NUMNODES > BITS_PER_LONG
/*
* Special functions for NUMA systems with a large number of nodes.
* The nodemask is pointed to from the address space structures.
diff -uprN -X 0/Documentation/dontdiff 6/mm/page-writeback.c 7/mm/page-writeback.c
--- 6/mm/page-writeback.c 2007-05-30 11:39:25.000000000 -0700
+++ 7/mm/page-writeback.c 2007-05-30 11:39:48.000000000 -0700
@@ -216,6 +216,7 @@ get_dirty_limits(struct dirty_limits *dl
}
dirtyable_memory -= highmem_dirtyable_memory(nodes,
dirtyable_memory);
+ cpuset_get_current_ratios(&background_ratio, &dirty_ratio);
} else
#endif
{
@@ -226,19 +227,19 @@ get_dirty_limits(struct dirty_limits *dl
dirtyable_memory = determine_dirtyable_memory();
nr_mapped = global_page_state(NR_FILE_MAPPED) +
global_page_state(NR_ANON_PAGES);
+ dirty_ratio = vm_dirty_ratio;
+ background_ratio = dirty_background_ratio;
}
unmapped_ratio = 100 - ((global_page_state(NR_FILE_MAPPED) +
global_page_state(NR_ANON_PAGES)) * 100) /
vm_total_pages;
- dirty_ratio = vm_dirty_ratio;
if (dirty_ratio > unmapped_ratio / 2)
dirty_ratio = unmapped_ratio / 2;
if (dirty_ratio < 5)
dirty_ratio = 5;
- background_ratio = dirty_background_ratio;
if (background_ratio >= dirty_ratio)
background_ratio = dirty_ratio / 2;
next prev parent reply other threads:[~2007-06-01 6:18 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-01 6:03 [RFC 1/7] cpuset write dirty map Ethan Solomita
2007-06-01 6:10 ` [RFC 2/7] cpuset write pdflush nodemask Ethan Solomita
2007-06-01 6:11 ` [RFC 3/7] cpuset write throttle Ethan Solomita
2007-06-01 6:13 ` [RFC 4/7] cpuset write vmscan Ethan Solomita
2007-06-01 6:15 ` [RFC 5/7] cpuset write vm writeout Ethan Solomita
2007-06-01 6:16 ` [corrected][RFC " Ethan Solomita
2007-06-01 6:16 ` [RFC 6/7] cpuset write fixes Ethan Solomita
2007-06-01 6:17 ` Ethan Solomita [this message]
2007-06-04 18:39 ` [RFC 1/7] cpuset write dirty map Christoph Lameter
2007-06-04 19:38 ` Ethan Solomita
2007-06-04 19:52 ` Christoph Lameter
2007-06-25 20:21 ` Ethan Solomita
2007-06-26 19:16 ` Christoph Lameter
2007-06-26 22:22 ` Andrew Morton
2007-06-27 3:18 ` Christoph Lameter
2007-06-27 9:14 ` Andrew Morton
2007-06-27 12:44 ` Christoph Lameter
2007-06-27 21:10 ` Mel Gorman
2007-06-27 18:17 ` Ethan Solomita
2007-06-27 21:38 ` Christoph Lameter
2007-07-01 2:57 ` Ethan Solomita
2007-07-03 18:09 ` Christoph Lameter
2007-07-11 19:18 ` Ethan Solomita
2007-07-11 20:11 ` Christoph Lameter
2007-07-12 1:07 ` Ethan Solomita
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=465FB9FF.4000302@google.com \
--to=solo@google.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).