public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Andrea Righi <righi.andrea@gmail.com>
Cc: David Rientjes <rientjes@google.com>,
	akpm@linux-foundation.org, Dave Chinner <david@fromorbit.com>,
	Christoph Lameter <cl@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: prevent divide error for small values of vm_dirty_bytes
Date: Wed, 29 Apr 2009 10:44:36 +0200	[thread overview]
Message-ID: <1240994676.8021.83.camel@laptop> (raw)
In-Reply-To: <1240993759-30787-1-git-send-email-righi.andrea@gmail.com>

On Wed, 2009-04-29 at 10:29 +0200, Andrea Righi wrote:
> Avoid to set less than two pages for vm_dirty_byte: this is necessary to avoid
> potential division by 0 (like the following) in get_dirty_limits().

isn't changing the .extra1 in the sysctl table a better fix?

> Signed-off-by: Andrea Righi <righi.andrea@gmail.com>
> ---
>  mm/page-writeback.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index 30351f0..9d6c427 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -213,6 +213,12 @@ int dirty_bytes_handler(struct ctl_table *table, int write,
>  	int ret;
>  
>  	ret = proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos);
> +	/*
> +	 * Do not allow to set less than two pages for vm_dirty_byte: this is
> +	 * necessary to avoid division by 0 in get_dirty_limits().
> +	 */
> +	vm_dirty_bytes = max_t(typeof(vm_dirty_bytes),
> +				vm_dirty_bytes, 2 * PAGE_SIZE);
>  	if (ret == 0 && write && vm_dirty_bytes != old_bytes) {
>  		update_completion_period();
>  		vm_dirty_ratio = 0;


  reply	other threads:[~2009-04-29  8:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-29  8:29 [PATCH] mm: prevent divide error for small values of vm_dirty_bytes Andrea Righi
2009-04-29  8:44 ` Peter Zijlstra [this message]
2009-04-29  9:34   ` Andrea Righi
2009-04-29 20:02     ` David Rientjes
2009-04-29 21:46     ` Andrew Morton
2009-05-01 14:56       ` Andrea Righi
2009-05-01 19:53         ` Andrew Morton
2009-04-29  9:26 ` David Rientjes
2009-04-29  9:40   ` Andrea Righi

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=1240994676.8021.83.camel@laptop \
    --to=peterz@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux-foundation.org \
    --cc=david@fromorbit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rientjes@google.com \
    --cc=righi.andrea@gmail.com \
    /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