[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1327071436-20763-3-git-send-email-glommer@parallels.com>
Date: Fri, 20 Jan 2012 18:57:15 +0400
From: Glauber Costa <glommer@...allels.com>
To: davem@...emloft.net
Cc: linux-kernel@...r.kernel.org, kamezawa.hiroyu@...fujitsu.com,
netdev@...r.kernel.org, eric.dumazet@...il.com,
cgroups@...r.kernel.org, Glauber Costa <glommer@...allels.com>,
Johannes Weiner <hannes@...xchg.org>,
Michal Hocko <mhocko@...e.cz>, Tejun Heo <tj@...nel.org>,
Li Zefan <lizf@...fujitsu.com>
Subject: [PATCH 2/3] cgroup: make sure memcg margin is 0 when over limit
For the memcg sock code, we'll need to register allocations
that are temporarily over limit. Let's make sure that margin
is 0 in this case.
I am keeping this as a separate patch, so that if any weirdness
interaction appears in the future, we can now exactly what caused
it.
Suggested by Johannes Weiner
Signed-off-by: Glauber Costa <glommer@...allels.com>
CC: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
CC: Johannes Weiner <hannes@...xchg.org>
CC: Michal Hocko <mhocko@...e.cz>
CC: Tejun Heo <tj@...nel.org>
CC: Li Zefan <lizf@...fujitsu.com>
---
include/linux/res_counter.h | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h
index c9d625c..d06d014 100644
--- a/include/linux/res_counter.h
+++ b/include/linux/res_counter.h
@@ -142,7 +142,10 @@ static inline unsigned long long res_counter_margin(struct res_counter *cnt)
unsigned long flags;
spin_lock_irqsave(&cnt->lock, flags);
- margin = cnt->limit - cnt->usage;
+ if (cnt->limit > cnt->usage)
+ margin = cnt->limit - cnt->usage;
+ else
+ margin = 0;
spin_unlock_irqrestore(&cnt->lock, flags);
return margin;
}
--
1.7.7.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists