[PATCH 8/8] res_counter: Allow charge failure pointer to be null

From: Frederic Weisbecker
Date: Fri Jul 29 2011 - 12:14:05 EST


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@xxxxxxxxx>
Cc: Paul Menage <menage@xxxxxxxxxx>
Cc: Li Zefan <lizf@xxxxxxxxxxxxxx>
Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
Cc: Aditya Kali <adityakali@xxxxxxxxxx>
Cc: Oleg Nesterov <oleg@xxxxxxxxxx>
---
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/