lkml.org 
[lkml]   [2010]   [Nov]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 6/6] memcg: make mem_cgroup_page_stat() return value unsigned
Date
mem_cgroup_page_stat() used to return a negative page count
value to indicate value.

mem_cgroup_page_stat() has changed so it never returns
error so convert the return value to the traditional page
count type (unsigned long).

Signed-off-by: Greg Thelen <gthelen@google.com>
---
include/linux/memcontrol.h | 6 +++---
mm/memcontrol.c | 12 ++++++++++--
2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index a81dfda..3433784 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -158,8 +158,8 @@ bool mem_cgroup_has_dirty_limit(void);
bool mem_cgroup_dirty_info(unsigned long sys_available_mem,
struct mem_cgroup *memcg,
struct dirty_info *info);
-long mem_cgroup_page_stat(struct mem_cgroup *mem,
- enum mem_cgroup_nr_pages_item item);
+unsigned long mem_cgroup_page_stat(struct mem_cgroup *mem,
+ enum mem_cgroup_nr_pages_item item);

unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
gfp_t gfp_mask);
@@ -354,7 +354,7 @@ static inline bool mem_cgroup_dirty_info(unsigned long sys_available_mem,
return false;
}

-static inline long mem_cgroup_page_stat(struct mem_cgroup *mem,
+static inline unsigned long mem_cgroup_page_stat(struct mem_cgroup *mem,
enum mem_cgroup_nr_pages_item item)
{
return -ENOSYS;
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index ccdbb7e..ed070d0 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1361,8 +1361,8 @@ memcg_hierarchical_free_pages(struct mem_cgroup *mem)
*
* Return the accounted statistic value.
*/
-long mem_cgroup_page_stat(struct mem_cgroup *mem,
- enum mem_cgroup_nr_pages_item item)
+unsigned long mem_cgroup_page_stat(struct mem_cgroup *mem,
+ enum mem_cgroup_nr_pages_item item)
{
struct mem_cgroup *iter;
long value;
@@ -1388,6 +1388,14 @@ long mem_cgroup_page_stat(struct mem_cgroup *mem,
for_each_mem_cgroup_tree(iter, mem)
value += mem_cgroup_local_page_stat(iter, item);

+ /*
+ * The sum of unlocked per-cpu counters may yield a slightly negative
+ * value. This function returns an unsigned value, so round it up to
+ * zero to avoid returning a very large value.
+ */
+ if (value < 0)
+ value = 0;
+
put_online_cpus();

return value;
--
1.7.3.1


\
 
 \ /
  Last update: 2010-11-09 10:29    [W:0.130 / U:0.300 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site