public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: David Rientjes <rientjes@google.com>
Cc: peterz@infradead.org, david@fromorbit.com,
	cl@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [patch 2/2] mm: add dirty_background_bytes and dirty_bytes sysctls
Date: Mon, 24 Nov 2008 15:38:43 -0800	[thread overview]
Message-ID: <20081124153843.d3c4782c.akpm@linux-foundation.org> (raw)
In-Reply-To: <alpine.DEB.2.00.0811230228530.11384@chino.kir.corp.google.com>

On Sun, 23 Nov 2008 10:55:16 -0800 (PST)
David Rientjes <rientjes@google.com> wrote:

> This change introduces two new sysctls to /proc/sys/vm:
> dirty_background_bytes and dirty_bytes.
> 
>
> ...
>
> @@ -365,23 +429,29 @@ void
>  get_dirty_limits(unsigned long *pbackground, unsigned long *pdirty,
>  		 unsigned long *pbdi_dirty, struct backing_dev_info *bdi)
>  {
> -	int background_ratio;		/* Percentages */
> -	int dirty_ratio;
>  	unsigned long background;
>  	unsigned long dirty;
>  	unsigned long available_memory = determine_dirtyable_memory();
>  	struct task_struct *tsk;
>  
> -	dirty_ratio = vm_dirty_ratio;
> -	if (dirty_ratio < 5)
> -		dirty_ratio = 5;
> +	if (vm_dirty_bytes)
> +		dirty = (vm_dirty_bytes + PAGE_SIZE) / PAGE_SIZE;

It would be conventional to use DIV_ROUND_UP() here.

> +	else {
> +		int dirty_ratio;

hm, I wonder why vm_dirty_ratio has a signed type.  

> -	background_ratio = dirty_background_ratio;
> -	if (background_ratio >= dirty_ratio)
> -		background_ratio = dirty_ratio / 2;
> +		dirty_ratio = vm_dirty_ratio;
> +		if (dirty_ratio < 5)
> +			dirty_ratio = 5;
> +		dirty = (dirty_ratio * available_memory) / 100;
> +	}
> +
> +	if (dirty_background_bytes)
> +		background = (dirty_background_bytes + PAGE_SIZE) / PAGE_SIZE;

DIV_ROUND_UP()?

> +	else
> +		background = (dirty_background_ratio * available_memory) / 100;
>  
> -	background = (background_ratio * available_memory) / 100;
> -	dirty = (dirty_ratio * available_memory) / 100;
> +	if (background >= dirty)
> +		background = dirty / 2;
>  	tsk = current;
>  	if (tsk->flags & PF_LESS_THROTTLE || rt_task(tsk)) {
>  		background += background / 4;

  parent reply	other threads:[~2008-11-24 23:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-23 18:55 [patch 1/2] mm: change dirty limit type specifiers to unsigned long David Rientjes
2008-11-23 18:55 ` [patch 2/2] mm: add dirty_background_bytes and dirty_bytes sysctls David Rientjes
2008-11-24 19:15   ` Peter Zijlstra
2008-11-24 23:38   ` Andrew Morton [this message]
2008-11-25  0:52     ` Randy Dunlap
2008-11-25  1:05       ` David Rientjes
2008-11-25  1:00     ` David Rientjes
2009-02-01  1:22   ` [PATCH] mm: Fix dirty_bytes/dirty_background_bytes sysctls on 64bit arches Sven Wegener
2009-02-01  9:19     ` Peter Zijlstra
2009-02-01 10:22       ` Sven Wegener
2009-02-02  0:26     ` David Rientjes
2008-11-24 19:16 ` [patch 1/2] mm: change dirty limit type specifiers to unsigned long Peter Zijlstra
2008-11-24 19:49   ` David Rientjes

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=20081124153843.d3c4782c.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=cl@linux-foundation.org \
    --cc=david@fromorbit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rientjes@google.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