linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Greg Thelen <gthelen@google.com>
Cc: Minchan Kim <minchan.kim@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Dave Young <hidave.darkstar@gmail.com>,
	Andrea Righi <arighi@develer.com>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>,
	Balbir Singh <balbir@linux.vnet.ibm.com>,
	Wu Fengguang <fengguang.wu@intel.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [patch 1/4] memcg: use native word to represent dirtyable pages
Date: Sun,  7 Nov 2010 23:14:36 +0100	[thread overview]
Message-ID: <20101107220353.115646194@cmpxchg.org> (raw)
In-Reply-To: <20101107215030.007259800@cmpxchg.org>

[-- Attachment #1: memcg-use-native-word-to-represent-dirtyable-pages.patch --]
[-- Type: text/plain, Size: 1575 bytes --]

The memory cgroup dirty info calculation currently uses a signed
64-bit type to represent the amount of dirtyable memory in pages.

This can instead be changed to an unsigned word, which will allow the
formula to function correctly with up to 160G of LRU pages on a 32-bit
system, assuming 4k pages.  That should be plenty even when taking
racy folding of the per-cpu counters into account.

This fixes a compilation error on 32-bit systems as this code tries to
do 64-bit division.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reported-by: Dave Young <hidave.darkstar@gmail.com>
---
 mm/memcontrol.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1222,9 +1222,10 @@ static void __mem_cgroup_dirty_param(str
 bool mem_cgroup_dirty_info(unsigned long sys_available_mem,
 			   struct dirty_info *info)
 {
-	s64 available_mem;
 	struct vm_dirty_param dirty_param;
+	unsigned long available_mem;
 	struct mem_cgroup *memcg;
+	s64 value;
 
 	if (mem_cgroup_disabled())
 		return false;
@@ -1238,11 +1239,11 @@ bool mem_cgroup_dirty_info(unsigned long
 	__mem_cgroup_dirty_param(&dirty_param, memcg);
 	rcu_read_unlock();
 
-	available_mem = mem_cgroup_page_stat(MEMCG_NR_DIRTYABLE_PAGES);
-	if (available_mem < 0)
+	value = mem_cgroup_page_stat(MEMCG_NR_DIRTYABLE_PAGES);
+	if (value < 0)
 		return false;
 
-	available_mem = min((unsigned long)available_mem, sys_available_mem);
+	available_mem = min((unsigned long)value, sys_available_mem);
 
 	if (dirty_param.dirty_bytes)
 		info->dirty_thresh =



  parent reply	other threads:[~2010-11-07 22:15 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-05 16:08 [PATCH] memcg: use do_div to divide s64 in 32 bit machine Minchan Kim
2010-11-05 16:34 ` Greg Thelen
2010-11-06  1:03 ` hannes
2010-11-06 17:19   ` Greg Thelen
2010-11-06 17:31     ` Minchan Kim
2010-11-07 22:14     ` [patch 0/4] memcg: variable type fixes Johannes Weiner
2010-11-07 22:14     ` Johannes Weiner [this message]
2010-11-07 22:56       ` [patch 1/4] memcg: use native word to represent dirtyable pages Minchan Kim
2010-11-08 22:25         ` Greg Thelen
2010-11-08 22:38           ` Johannes Weiner
2010-11-08 22:43             ` Greg Thelen
2010-11-16  3:37       ` KAMEZAWA Hiroyuki
2010-11-07 22:14     ` [patch 2/4] memcg: catch negative per-cpu sums in dirty info Johannes Weiner
2010-11-07 23:26       ` Minchan Kim
2010-11-08 22:28         ` Greg Thelen
2010-11-16  3:39       ` KAMEZAWA Hiroyuki
2010-11-07 22:14     ` [patch 3/4] memcg: break out event counters from other stats Johannes Weiner
2010-11-07 23:52       ` Minchan Kim
2010-11-08 23:20         ` Greg Thelen
2010-11-16  3:41       ` KAMEZAWA Hiroyuki
2010-11-07 22:14     ` [patch 4/4] memcg: use native word page statistics counters Johannes Weiner
2010-11-08  0:01       ` Minchan Kim
2010-11-08  9:08         ` Johannes Weiner
2010-11-08 22:51         ` Greg Thelen
2010-11-08  0:07       ` Minchan Kim
2010-11-08  9:37         ` memcg writeout throttling, was: " Johannes Weiner
2010-11-08 15:45           ` Wu Fengguang
2010-11-08 19:00             ` Greg Thelen
2010-11-08 23:27       ` Greg Thelen
2010-11-08 23:45         ` Johannes Weiner
2010-11-16  3:44       ` KAMEZAWA Hiroyuki

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=20101107220353.115646194@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=akpm@linux-foundation.org \
    --cc=arighi@develer.com \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=fengguang.wu@intel.com \
    --cc=gthelen@google.com \
    --cc=hidave.darkstar@gmail.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan.kim@gmail.com \
    --cc=nishimura@mxp.nes.nec.co.jp \
    /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).