]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
cgroups: pull up res counter charge failure interpretation to caller
authorFrederic Weisbecker <fweisbec@gmail.com>
Tue, 8 Nov 2011 00:20:21 +0000 (11:20 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 8 Nov 2011 03:25:29 +0000 (14:25 +1100)
res_counter_charge() always returns -ENOMEM when the limit is reached and
the charge thus can't happen.

However it's up to the caller to interpret this failure and return the
appropriate error value.  The task counter subsystem will need to report
the user that a fork() has been cancelled because of some limit reached,
not because we are too short on memory.

Fix this by returning -1 when res_counter_charge() fails.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Menage <paul@paulmenage.org>
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>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Tim Hockin <thockin@hockin.org>
Cc: Tejun Heo <htejun@gmail.com>
Acked-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Documentation/cgroups/resource_counter.txt
kernel/res_counter.c

index a2cd05bdbb39d8b1bcfce347522d3a37970105e9..24ec61ccf5d0786e559570abac0d54f1f011910f 100644 (file)
@@ -76,6 +76,8 @@ to work with it.
        limit_fail_at parameter is set to the particular res_counter element
        where the charging failed.
 
+       It returns 0 on success and -1 on failure.
+
  d. int res_counter_charge_locked
                        (struct res_counter *rc, unsigned long val)
 
index 6b36823541ba903171e5bf642cdea376b7b81832..b814d6ca9ff5cdbfe5ed8dfcd730565b3a18bad0 100644 (file)
@@ -26,7 +26,7 @@ int res_counter_charge_locked(struct res_counter *counter, unsigned long val)
 {
        if (counter->usage + val > counter->limit) {
                counter->failcnt++;
-               return -ENOMEM;
+               return -1;
        }
 
        counter->usage += val;