Received: by 10.192.165.156 with SMTP id m28csp598079imm; Fri, 13 Apr 2018 04:46:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+XwbxhiXd0c4mFmkvmb5qnBG5sQOcQyvU3Yl4F6vS1Upi4VVgq0phX+sgym9ntBtao2+UD X-Received: by 2002:a17:902:8501:: with SMTP id bj1-v6mr4886667plb.239.1523620013507; Fri, 13 Apr 2018 04:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523620013; cv=none; d=google.com; s=arc-20160816; b=Wfy31PX3Em3arHYCFcua9A75as5U82AAkwpPiRW/kDBol3TWx901L5W7Cw59Iag798 0muzs8aTeJ4qdfrq0BwsHZJgM86/nrNgX6BaDAkORrljjV0qrnOSjw+BTss+uJp8DHGW RWC8Y+Uoz8J6dtbLAaDv9/C+3L6M0uq26ixd8fyNU6acOy9cQepeMuhSYsTAKlN5/o8t SfQVwBJ4Grz67R2cVVSdY7qj149csUH0MLjQFqD7CYamVYc0mpqz/CQDcad9gMLg2gZ7 FGGturLzurzEoGuDNjojEAOCjvFT9cG3t/JCeZ2BVrL+TCd2KPpObMZLiQewkMwhcQwN vBNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:arc-authentication-results; bh=kF0N+wc3ASnwFfp9lincePt8cWImzKfSRwOvtNyL/zY=; b=PSlu7NREH5TE0wW3dJlWs3In1Tt7tjGAf0byTKigcKCLrAzu0Zg7KP7bHNH0ZyUaVN sAgWcp5Tg4UpDw+FEtkE8dFlnUS6Pf218l0CakQ4dQRAjiigLN+KytQipklqqzGW1nqp tWz0xhMSo07q34MfLb/n9Y3kwybK0j8LVDCBDyys9iwASH1Su8QZU+TuotVx8zqUVzBw blpKATIfDLX13Zf87W1DknUmkG+hVZ+RX7+A5ge4ztU8/ZlbQ6TOluNlj5d6VBKlvm4J 4SdGsgidxGe4gQ76OrcSva6xdDHFoJ7P8C1vetzDlHVg+bbVPXDvNRQlyCbhF8o+aRMm D9CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=CpggtEJt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l14-v6si4182559plk.599.2018.04.13.04.46.27; Fri, 13 Apr 2018 04:46:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=CpggtEJt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753894AbeDMJfb (ORCPT + 99 others); Fri, 13 Apr 2018 05:35:31 -0400 Received: from mail-eopbgr20119.outbound.protection.outlook.com ([40.107.2.119]:63903 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753185AbeDMJf3 (ORCPT ); Fri, 13 Apr 2018 05:35:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=kF0N+wc3ASnwFfp9lincePt8cWImzKfSRwOvtNyL/zY=; b=CpggtEJtiRfGvDYFPLqBHjzWLe09iPusYUEz3Xlxvv/LqxgB8QR67drC45C+UBCkikTcs9/u5fd4JpaIIQtQsaOg5W/xsV5b8PuWrJvLg1hJSw27oI6Pb/+5hNkzhx0md5cF6z4ztcCRTWtKHRz5CDEq72vgLFQDIdFPaOuvpTc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Received: from [172.16.25.5] (195.214.232.6) by HE1PR0801MB1337.eurprd08.prod.outlook.com (2603:10a6:3:39::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.653.12; Fri, 13 Apr 2018 09:35:25 +0000 Subject: Re: [PATCH] memcg: Remove memcg_cgroup::id from IDR on mem_cgroup_css_alloc() failure To: Michal Hocko Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, vdavydov.dev@gmail.com, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <152354470916.22460.14397070748001974638.stgit@localhost.localdomain> <20180413085553.GF17484@dhcp22.suse.cz> From: Kirill Tkhai Message-ID: Date: Fri, 13 Apr 2018 12:35:22 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180413085553.GF17484@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR0802CA0023.eurprd08.prod.outlook.com (2603:10a6:3:bd::33) To HE1PR0801MB1337.eurprd08.prod.outlook.com (2603:10a6:3:39::27) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:HE1PR0801MB1337; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1337;3:Bu5gwkwwT94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Phet/+wYdJfC7RP2RvNyfSz1yBcxnRB7EruK4XIL89HavlPi0Rp81Hix3MyXuOJZhq8Q09+LdtdAt9Ap9teYYy61zidKzWagtYwvU4Q21cvkv50uw9LBrtJpNrWmbduHsCr4WhccBq9mQYK7T1AtTila2sympev684+WzKhldeMsg1Cw89RbgRREAetjuFuhCLPYOv7soezSwL03Ny/R5D+FSFHPmmh3oZAd3ah6/0ZxJah9q8bmFlliKTIe7rBc5geMF39c4Yaqk8vRPSYCeqBho0uBRigfBzBJz+rLTRMqkjUHp16AQmWqGPGHIzLwoKfvDdzB9IckXLS/yzY;4:bu+rceFpcoa/vyuoNQOhpQgHzfkEkdXvzrKzm9scvlGJFmqLg+TeDNehwNJ672W2ll3QPArANNMRGZLB4yS2EzlwAhed7OssGTytlT34XpHzXusfIVnTdvFp9E0nLd19wI+dR4CEPVKW7e63cvrRfb57/ahmJWmFsoim5tgNiAU4+8SDWVIcusBC7ER+B3k/9SUPhz996EpLz/LMU79kxoIGgQlkv2aqLEPRkAGlXdGa+UsiR66YhSsgn8ik/ZoDYrHR4EEQGtGkNxjqLt3K7L7Zdxfnv7Czpb6hdC6iOqW3wmdF95ESgDqdo2b1aDN2 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(265634631926514); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(3231232)(944501327)(52105095)(93006095)(93001095)(10201501046)(3002001)(6041310)(20161123560045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:HE1PR0801MB1337;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0801MB1337; X-Forefront-PRVS: 0641678E68 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6049001)(396003)(376002)(366004)(39850400004)(346002)(39380400002)(189003)(199004)(377424004)(8936002)(58126008)(305945005)(55236004)(81166006)(64126003)(5660300001)(39060400002)(65806001)(478600001)(97736004)(4326008)(65956001)(65826007)(386003)(66066001)(59450400001)(50466002)(47776003)(2486003)(36756003)(76176011)(23676004)(316002)(2906002)(25786009)(8676002)(52146003)(52116002)(81156014)(77096007)(3846002)(105586002)(68736007)(106356001)(6666003)(446003)(16526019)(53546011)(229853002)(86362001)(6116002)(7736002)(11346002)(31696002)(6916009)(16576012)(476003)(6486002)(31686004)(6246003)(956004)(53936002)(26005)(186003)(230700001)(486006)(2616005);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1PR0801MB1337;H:[172.16.25.5];FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtIRTFQUjA4MDFNQjEzMzc7MjM6ZHd1T0pHZTRucCt0ZWZuKzNoUkZnSGdU?= =?utf-8?B?YzEzV1pWNkdZSkdWUmdIcDdIVEw4ckN6dkpSUjk2UTdVWmlZV0VHak9YdHVN?= =?utf-8?B?aWY1UGZVNXpreHJ5SHVCUW1NMDV2Z29rcmdrbGF0Q25vUkVEZTdKODRUVFc5?= =?utf-8?B?VEFxWHpHeFJHVHpKVGtINlZCU09OWFZkeDBpYk1YRlNOeWg5QytMamE3aHJQ?= =?utf-8?B?VlpKZURKczdJWS9XOFA0Z0pMVkg0TmJGQjB2cC9ZVUJXdVBRUlVIVnc2VlQz?= =?utf-8?B?R3pFMjd4KzNuQ3M3RUoydys3aGNPS2VhQ21OYWN0TGo4TXZFaUpqMk5jak9G?= =?utf-8?B?bUdEZ2d4N1ZxZDhHS2xkTjNQUEJLZEMwNlVDQjNjaWtTTm5qc3pUa0ZZVFlv?= =?utf-8?B?eElYaXBINGJoM21IdnAwZHBVSXRNOElkenplQkpybzdCUlFSR0Q0Q0RxZlBu?= =?utf-8?B?R2d2bGsvUVNjdDNJSnNSQzdtSDB0b3NIaDRJZkZJekppdzlCUjByZmRoUGFX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CRtQXpea1pVNa+Vj9IDyFWeKczLUzXlnPpEB0CQPp09+UY5PNE5RimGWCERtZSPjmsc9+lnA3qwB3/HDl6BETq/IdVAZsfqEzy2Y= X-MS-Office365-Filtering-Correlation-Id: 9a2d5749-8934-4854-d632-08d5a121e307 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2018 09:35:25.4914 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9a2d5749-8934-4854-d632-08d5a121e307 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1337 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13.04.2018 11:55, Michal Hocko wrote: > On Thu 12-04-18 17:52:04, Kirill Tkhai wrote: > [...] >> @@ -4471,6 +4477,7 @@ mem_cgroup_css_alloc(struct cgroup_subsys_state *parent_css) >> >> return &memcg->css; >> fail: >> + mem_cgroup_id_remove(memcg); >> mem_cgroup_free(memcg); >> return ERR_PTR(-ENOMEM); >> } > > The only path which jumps to fail: here (in the current mmotm tree) is > error = memcg_online_kmem(memcg); > if (error) > goto fail; > > AFAICS and the only failure path in memcg_online_kmem > memcg_id = memcg_alloc_cache_id(); > if (memcg_id < 0) > return memcg_id; > > I am not entirely clear on memcg_alloc_cache_id but it seems we do clean > up properly. Or am I missing something? memcg_alloc_cache_id() may allocate a lot of memory, in case of the system reached memcg_nr_cache_ids cgroups. In this case it iterates over all LRU lists, and double size of every of them. In case of memory pressure it can fail. If this occurs, mem_cgroup::id is not unhashed from IDR and we leak this id. After further iterations, all IDs may be occupied, and there won't be able to create a memcg in the system ever. You may reproduce the situation with the patch: [root@localhost ~]# cd /sys/fs/cgroup/memory/ [root@localhost memory]# mkdir 1 mkdir: cannot create directory `1': Cannot allocate memory [root@localhost memory]# for i in {1..65535}; do mkdir 1 2>/dev/null; done [root@localhost memory]# mkdir 1 mkdir: cannot create directory `1': No space left on device diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 3e7942c301a8..5e17bfee9e6f 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2156,6 +2156,7 @@ static int memcg_alloc_cache_id(void) err = memcg_update_all_caches(size); if (!err) err = memcg_update_all_list_lrus(size); + err = -ENOMEM; if (!err) memcg_nr_cache_ids = size; @@ -4422,7 +4423,7 @@ mem_cgroup_css_alloc(struct cgroup_subsys_state *parent_css) { struct mem_cgroup *parent = mem_cgroup_from_css(parent_css); struct mem_cgroup *memcg; - long error = -ENOMEM; + long error = -ENOSPC; memcg = mem_cgroup_alloc(); if (!memcg) ENOSPC was added to the second hunk to show that the function fails on IDR allocation. Kirill