lkml.org 
[lkml]   [2011]   [Jul]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 8/8] res_counter: Allow charge failure pointer to be null
Date
So that callers of res_counter_charge() don't have to create and
pass this pointer even if they aren't interested in it.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Menage <menage@google.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Aditya Kali <adityakali@google.com>
Cc: Oleg Nesterov <oleg@redhat.com>
---
kernel/cgroup_task_counter.c | 6 ++----
kernel/res_counter.c | 6 ++++--
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/kernel/cgroup_task_counter.c b/kernel/cgroup_task_counter.c
index 7f12ac9..dacc4a9 100644
--- a/kernel/cgroup_task_counter.c
+++ b/kernel/cgroup_task_counter.c
@@ -93,11 +93,10 @@ static int task_counter_can_attach_task(struct cgroup *cgrp, struct cgroup *old_
{
struct res_counter *res = cgroup_task_counter_res(cgrp);
struct res_counter *old_res = cgroup_task_counter_res(old_cgrp);
- struct res_counter *limit_fail_at;

common_ancestor = res_counter_common_ancestor(res, old_res);

- return res_counter_charge_until(res, common_ancestor, 1, &limit_fail_at);
+ return res_counter_charge_until(res, common_ancestor, 1, NULL);
}

static void task_counter_cancel_attach_task(struct cgroup *cgrp, struct task_struct *tsk)
@@ -154,13 +153,12 @@ int cgroup_task_counter_fork(struct task_struct *child)
{
struct cgroup_subsys_state *css = child->cgroups->subsys[tasks_subsys_id];
struct cgroup *cgrp = css->cgroup;
- struct res_counter *limit_fail_at;

/* Optimize for the root cgroup case, which doesn't have a limit */
if (!cgrp->parent)
return 0;

- return res_counter_charge(cgroup_task_counter_res(cgrp), 1, &limit_fail_at);
+ return res_counter_charge(cgroup_task_counter_res(cgrp), 1, NULL);
}

struct cgroup_subsys tasks_subsys = {
diff --git a/kernel/res_counter.c b/kernel/res_counter.c
index 725dfa6..7eac803 100644
--- a/kernel/res_counter.c
+++ b/kernel/res_counter.c
@@ -43,14 +43,16 @@ int res_counter_charge_until(struct res_counter *counter,
unsigned long flags;
struct res_counter *c, *u;

- *limit_fail_at = NULL;
+ if (limit_fail_at)
+ *limit_fail_at = NULL;
local_irq_save(flags);
for (c = counter; c != limit; c = c->parent) {
spin_lock(&c->lock);
ret = res_counter_charge_locked(c, val);
spin_unlock(&c->lock);
if (ret < 0) {
- *limit_fail_at = c;
+ if (limit_fail_at)
+ *limit_fail_at = c;
goto undo;
}
}
--
1.7.5.4


\
 
 \ /
  Last update: 2011-07-29 18:17    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site