From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755909Ab2BADih (ORCPT ); Tue, 31 Jan 2012 22:38:37 -0500 Received: from mail-iy0-f174.google.com ([209.85.210.174]:60762 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755862Ab2BADiY (ORCPT ); Tue, 31 Jan 2012 22:38:24 -0500 From: Frederic Weisbecker To: Andrew Morton , Tejun Heo , Li Zefan Cc: LKML , Frederic Weisbecker , Paul Menage , Johannes Weiner , Aditya Kali , Oleg Nesterov , Tim Hockin , Tejun Heo , Containers , Glauber Costa , Cgroups , Daniel J Walsh , "Daniel P. Berrange" , KAMEZAWA Hiroyuki , Max Kellermann , Mandeep Singh Baines Subject: [PATCH 06/10] cgroups: pull up res counter charge failure interpretation to caller Date: Wed, 1 Feb 2012 04:37:46 +0100 Message-Id: <1328067470-5980-7-git-send-email-fweisbec@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1328067470-5980-1-git-send-email-fweisbec@gmail.com> References: <1328067470-5980-1-git-send-email-fweisbec@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Paul Menage Cc: Li Zefan Cc: Johannes Weiner Cc: Aditya Kali Cc: Oleg Nesterov Cc: Tim Hockin Cc: Tejun Heo Cc: Containers Cc: Glauber Costa Cc: Cgroups Cc: Daniel J Walsh Cc: "Daniel P. Berrange" Cc: KAMEZAWA Hiroyuki Cc: Max Kellermann Cc: Mandeep Singh Baines Acked-by: Kirill A. Shutemov Signed-off-by: Andrew Morton --- Documentation/cgroups/resource_counter.txt | 2 ++ kernel/res_counter.c | 2 +- 2 files changed, 3 insertions(+), 1 deletions(-) diff --git a/Documentation/cgroups/resource_counter.txt b/Documentation/cgroups/resource_counter.txt index a2cd05b..24ec61c 100644 --- a/Documentation/cgroups/resource_counter.txt +++ b/Documentation/cgroups/resource_counter.txt @@ -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) diff --git a/kernel/res_counter.c b/kernel/res_counter.c index d2fc4cd..78cc444 100644 --- a/kernel/res_counter.c +++ b/kernel/res_counter.c @@ -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; -- 1.7.5.4