From: Wu Fengguang <fengguang.wu@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Dave Chinner <david@fromorbit.com>,
Christoph Hellwig <hch@infradead.org>, Mel Gorman <mel@csn.ul.ie>,
Chris Mason <chris.mason@oracle.com>,
Jens Axboe <axboe@kernel.dk>, Jan Kara <jack@suse.cz>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [PATCH 07/13] writeback: explicit low bound for vm.dirty_ratio
Date: Fri, 6 Aug 2010 20:44:52 +0800 [thread overview]
Message-ID: <20100806124452.GC4717@localhost> (raw)
In-Reply-To: <20100805163401.e9754032.akpm@linux-foundation.org>
On Fri, Aug 06, 2010 at 07:34:01AM +0800, Andrew Morton wrote:
> On Fri, 06 Aug 2010 00:10:58 +0800
> Wu Fengguang <fengguang.wu@intel.com> wrote:
>
> > Force a user visible low bound of 5% for the vm.dirty_ratio interface.
> >
> > Currently global_dirty_limits() applies a low bound of 5% for
> > vm_dirty_ratio. This is not very user visible -- if the user sets
> > vm.dirty_ratio=1, the operation seems to succeed but will be rounded up
> > to 5% when used.
> >
> > Another problem is inconsistency: calc_period_shift() uses the plain
> > vm_dirty_ratio value, which may be a problem when vm.dirty_ratio is set
> > to < 5 by the user.
>
> The changelog describes the old behaviour but doesn't describe the
> proposed new behaviour.
Yeah, fixed below.
> > --- linux-next.orig/kernel/sysctl.c 2010-08-05 22:48:34.000000000 +0800
> > +++ linux-next/kernel/sysctl.c 2010-08-05 22:48:47.000000000 +0800
> > @@ -126,6 +126,7 @@ static int ten_thousand = 10000;
> >
> > /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
> > static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
> > +static int dirty_ratio_min = 5;
> >
> > /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
> > static int maxolduid = 65535;
> > @@ -1031,7 +1032,7 @@ static struct ctl_table vm_table[] = {
> > .maxlen = sizeof(vm_dirty_ratio),
> > .mode = 0644,
> > .proc_handler = dirty_ratio_handler,
> > - .extra1 = &zero,
> > + .extra1 = &dirty_ratio_min,
> > .extra2 = &one_hundred,
> > },
>
> I forget how the procfs core handles this. Presumably the write will
> now fail with -EINVAL or something?
Right.
# echo 111 > /proc/sys/vm/dirty_ratio
echo: write error: invalid argument
> So people's scripts will now error out and their space shuttles will
> crash?
Looks like a serious problem. I'm now much more reserved on pushing
this patch :)
> All of which illustrates why it's important to fully describe changes
> in the changelog! So people can consider and discuss the end-user
> implications of a change.
Good point. Here is the patch with updated changelog.
Thanks,
Fengguang
---
Subject: writeback: explicit low bound for vm.dirty_ratio
From: Wu Fengguang <fengguang.wu@intel.com>
Date: Thu Jul 15 10:28:57 CST 2010
Force a user visible low bound of 5% for the vm.dirty_ratio interface.
This is an interface change. When doing
echo N > /proc/sys/vm/dirty_ratio
where N < 5, the old behavior is pretend to accept the value, while
the new behavior is to reject it explicitly with -EINVAL. This will
possibly break user space if they checks the return value.
Currently global_dirty_limits() applies a low bound of 5% for
vm_dirty_ratio. This is not very user visible -- if the user sets
vm.dirty_ratio=1, the operation seems to succeed but will be rounded up
to 5% when used.
Another problem is inconsistency: calc_period_shift() uses the plain
vm_dirty_ratio value, which may be a problem when vm.dirty_ratio is set
to < 5 by the user.
CC: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
kernel/sysctl.c | 3 ++-
mm/page-writeback.c | 10 ++--------
2 files changed, 4 insertions(+), 9 deletions(-)
--- linux-next.orig/kernel/sysctl.c 2010-08-05 22:48:34.000000000 +0800
+++ linux-next/kernel/sysctl.c 2010-08-05 22:48:47.000000000 +0800
@@ -126,6 +126,7 @@ static int ten_thousand = 10000;
/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
+static int dirty_ratio_min = 5;
/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
static int maxolduid = 65535;
@@ -1031,7 +1032,7 @@ static struct ctl_table vm_table[] = {
.maxlen = sizeof(vm_dirty_ratio),
.mode = 0644,
.proc_handler = dirty_ratio_handler,
- .extra1 = &zero,
+ .extra1 = &dirty_ratio_min,
.extra2 = &one_hundred,
},
{
--- linux-next.orig/mm/page-writeback.c 2010-08-05 22:48:42.000000000 +0800
+++ linux-next/mm/page-writeback.c 2010-08-05 22:48:47.000000000 +0800
@@ -415,14 +415,8 @@ void global_dirty_limits(unsigned long *
if (vm_dirty_bytes)
dirty = DIV_ROUND_UP(vm_dirty_bytes, PAGE_SIZE);
- else {
- int dirty_ratio;
-
- dirty_ratio = vm_dirty_ratio;
- if (dirty_ratio < 5)
- dirty_ratio = 5;
- dirty = (dirty_ratio * available_memory) / 100;
- }
+ else
+ dirty = (vm_dirty_ratio * available_memory) / 100;
if (dirty_background_bytes)
background = DIV_ROUND_UP(dirty_background_bytes, PAGE_SIZE);
WARNING: multiple messages have this Message-ID (diff)
From: Wu Fengguang <fengguang.wu@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Dave Chinner <david@fromorbit.com>,
Christoph Hellwig <hch@infradead.org>, Mel Gorman <mel@csn.ul.ie>,
Chris Mason <chris.mason@oracle.com>,
Jens Axboe <axboe@kernel.dk>, Jan Kara <jack@suse.cz>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [PATCH 07/13] writeback: explicit low bound for vm.dirty_ratio
Date: Fri, 6 Aug 2010 20:44:52 +0800 [thread overview]
Message-ID: <20100806124452.GC4717@localhost> (raw)
In-Reply-To: <20100805163401.e9754032.akpm@linux-foundation.org>
On Fri, Aug 06, 2010 at 07:34:01AM +0800, Andrew Morton wrote:
> On Fri, 06 Aug 2010 00:10:58 +0800
> Wu Fengguang <fengguang.wu@intel.com> wrote:
>
> > Force a user visible low bound of 5% for the vm.dirty_ratio interface.
> >
> > Currently global_dirty_limits() applies a low bound of 5% for
> > vm_dirty_ratio. This is not very user visible -- if the user sets
> > vm.dirty_ratio=1, the operation seems to succeed but will be rounded up
> > to 5% when used.
> >
> > Another problem is inconsistency: calc_period_shift() uses the plain
> > vm_dirty_ratio value, which may be a problem when vm.dirty_ratio is set
> > to < 5 by the user.
>
> The changelog describes the old behaviour but doesn't describe the
> proposed new behaviour.
Yeah, fixed below.
> > --- linux-next.orig/kernel/sysctl.c 2010-08-05 22:48:34.000000000 +0800
> > +++ linux-next/kernel/sysctl.c 2010-08-05 22:48:47.000000000 +0800
> > @@ -126,6 +126,7 @@ static int ten_thousand = 10000;
> >
> > /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
> > static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
> > +static int dirty_ratio_min = 5;
> >
> > /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
> > static int maxolduid = 65535;
> > @@ -1031,7 +1032,7 @@ static struct ctl_table vm_table[] = {
> > .maxlen = sizeof(vm_dirty_ratio),
> > .mode = 0644,
> > .proc_handler = dirty_ratio_handler,
> > - .extra1 = &zero,
> > + .extra1 = &dirty_ratio_min,
> > .extra2 = &one_hundred,
> > },
>
> I forget how the procfs core handles this. Presumably the write will
> now fail with -EINVAL or something?
Right.
# echo 111 > /proc/sys/vm/dirty_ratio
echo: write error: invalid argument
> So people's scripts will now error out and their space shuttles will
> crash?
Looks like a serious problem. I'm now much more reserved on pushing
this patch :)
> All of which illustrates why it's important to fully describe changes
> in the changelog! So people can consider and discuss the end-user
> implications of a change.
Good point. Here is the patch with updated changelog.
Thanks,
Fengguang
---
Subject: writeback: explicit low bound for vm.dirty_ratio
From: Wu Fengguang <fengguang.wu@intel.com>
Date: Thu Jul 15 10:28:57 CST 2010
Force a user visible low bound of 5% for the vm.dirty_ratio interface.
This is an interface change. When doing
echo N > /proc/sys/vm/dirty_ratio
where N < 5, the old behavior is pretend to accept the value, while
the new behavior is to reject it explicitly with -EINVAL. This will
possibly break user space if they checks the return value.
Currently global_dirty_limits() applies a low bound of 5% for
vm_dirty_ratio. This is not very user visible -- if the user sets
vm.dirty_ratio=1, the operation seems to succeed but will be rounded up
to 5% when used.
Another problem is inconsistency: calc_period_shift() uses the plain
vm_dirty_ratio value, which may be a problem when vm.dirty_ratio is set
to < 5 by the user.
CC: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
kernel/sysctl.c | 3 ++-
mm/page-writeback.c | 10 ++--------
2 files changed, 4 insertions(+), 9 deletions(-)
--- linux-next.orig/kernel/sysctl.c 2010-08-05 22:48:34.000000000 +0800
+++ linux-next/kernel/sysctl.c 2010-08-05 22:48:47.000000000 +0800
@@ -126,6 +126,7 @@ static int ten_thousand = 10000;
/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
+static int dirty_ratio_min = 5;
/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
static int maxolduid = 65535;
@@ -1031,7 +1032,7 @@ static struct ctl_table vm_table[] = {
.maxlen = sizeof(vm_dirty_ratio),
.mode = 0644,
.proc_handler = dirty_ratio_handler,
- .extra1 = &zero,
+ .extra1 = &dirty_ratio_min,
.extra2 = &one_hundred,
},
{
--- linux-next.orig/mm/page-writeback.c 2010-08-05 22:48:42.000000000 +0800
+++ linux-next/mm/page-writeback.c 2010-08-05 22:48:47.000000000 +0800
@@ -415,14 +415,8 @@ void global_dirty_limits(unsigned long *
if (vm_dirty_bytes)
dirty = DIV_ROUND_UP(vm_dirty_bytes, PAGE_SIZE);
- else {
- int dirty_ratio;
-
- dirty_ratio = vm_dirty_ratio;
- if (dirty_ratio < 5)
- dirty_ratio = 5;
- dirty = (dirty_ratio * available_memory) / 100;
- }
+ else
+ dirty = (vm_dirty_ratio * available_memory) / 100;
if (dirty_background_bytes)
background = DIV_ROUND_UP(dirty_background_bytes, PAGE_SIZE);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2010-08-07 16:21 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-05 16:10 [PATCH 00/13] writeback patches for 2.6.36 Wu Fengguang
2010-08-05 16:10 ` Wu Fengguang
2010-08-05 16:10 ` Wu Fengguang
2010-08-05 16:10 ` [PATCH 01/13] writeback: reduce calls to global_page_state in balance_dirty_pages() Wu Fengguang
2010-08-05 16:10 ` Wu Fengguang
2010-08-05 16:10 ` Wu Fengguang
2010-08-05 16:10 ` [PATCH 02/13] writeback: avoid unnecessary calculation of bdi dirty thresholds Wu Fengguang
2010-08-05 16:10 ` Wu Fengguang
2010-08-06 10:14 ` Peter Zijlstra
2010-08-06 10:14 ` Peter Zijlstra
2010-08-05 16:10 ` [PATCH 03/13] writeback: add comment to the dirty limits functions Wu Fengguang
2010-08-05 16:10 ` Wu Fengguang
2010-08-06 10:17 ` Peter Zijlstra
2010-08-06 10:17 ` Peter Zijlstra
2010-08-07 16:47 ` Wu Fengguang
2010-08-07 16:47 ` Wu Fengguang
2010-08-05 16:10 ` [PATCH 04/13] writeback: dont redirty tail an inode with dirty pages Wu Fengguang
2010-08-05 16:10 ` Wu Fengguang
2010-08-05 16:10 ` Wu Fengguang
2010-08-05 16:10 ` [PATCH 05/13] writeback: fix queue_io() ordering Wu Fengguang
2010-08-05 16:10 ` Wu Fengguang
2010-08-05 16:10 ` Wu Fengguang
2010-08-05 16:10 ` [PATCH 06/13] writeback: merge for_kupdate and !for_kupdate cases Wu Fengguang
2010-08-05 16:10 ` Wu Fengguang
2010-08-05 16:10 ` Wu Fengguang
2010-08-05 16:10 ` [PATCH 07/13] writeback: explicit low bound for vm.dirty_ratio Wu Fengguang
2010-08-05 16:10 ` Wu Fengguang
2010-08-05 16:10 ` Wu Fengguang
2010-08-05 23:34 ` Andrew Morton
2010-08-05 23:34 ` Andrew Morton
2010-08-06 12:44 ` Wu Fengguang [this message]
2010-08-06 12:44 ` Wu Fengguang
2010-08-10 3:12 ` KOSAKI Motohiro
2010-08-10 3:12 ` KOSAKI Motohiro
2010-08-10 3:57 ` Neil Brown
2010-08-10 3:57 ` Neil Brown
2010-08-10 13:29 ` Jan Kara
2010-08-10 13:29 ` Jan Kara
2010-08-10 18:12 ` Wu Fengguang
2010-08-10 18:12 ` Wu Fengguang
2010-08-10 18:06 ` Wu Fengguang
2010-08-10 18:06 ` Wu Fengguang
2010-08-05 16:10 ` [PATCH 08/13] writeback: pass writeback_control down to move_expired_inodes() Wu Fengguang
2010-08-05 16:10 ` Wu Fengguang
2010-08-05 16:10 ` Wu Fengguang
2010-08-05 16:11 ` [PATCH 09/13] writeback: the kupdate expire timestamp should be a moving target Wu Fengguang
2010-08-05 16:11 ` Wu Fengguang
2010-08-05 16:11 ` Wu Fengguang
2010-08-05 16:11 ` [PATCH 10/13] writeback: kill writeback_control.more_io Wu Fengguang
2010-08-05 16:11 ` Wu Fengguang
2010-08-05 16:11 ` Wu Fengguang
2010-08-05 16:11 ` [PATCH 11/13] writeback: sync expired inodes first in background writeback Wu Fengguang
2010-08-05 16:11 ` Wu Fengguang
2010-08-05 16:11 ` Wu Fengguang
2010-08-05 16:11 ` [PATCH 12/13] writeback: try more writeback as long as something was written Wu Fengguang
2010-08-05 16:11 ` Wu Fengguang
2010-08-05 16:11 ` Wu Fengguang
2010-08-05 17:00 ` Jan Kara
2010-08-05 17:00 ` Jan Kara
2010-08-05 22:39 ` Wu Fengguang
2010-08-05 22:39 ` Wu Fengguang
2010-08-05 22:50 ` Jan Kara
2010-08-05 22:50 ` Jan Kara
2010-08-05 16:11 ` [PATCH 13/13] writeback: introduce writeback_control.inodes_written Wu Fengguang
2010-08-05 16:11 ` Wu Fengguang
2010-08-05 16:11 ` Wu Fengguang
2010-08-05 23:08 ` [PATCH 00/13] writeback patches for 2.6.36 Andrew Morton
2010-08-05 23:08 ` Andrew Morton
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=20100806124452.GC4717@localhost \
--to=fengguang.wu@intel.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=chris.mason@oracle.com \
--cc=david@fromorbit.com \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.