Received: by 10.192.165.156 with SMTP id m28csp211751imm; Tue, 17 Apr 2018 08:55:31 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+xDLSo0YA3rAME3J01jOHrtbDE6ZrwDksYMAo0Imm15EEdepcjfrH3Rjg7hdsLt1UybZ0Y X-Received: by 10.99.132.198 with SMTP id k189mr2173012pgd.298.1523980531344; Tue, 17 Apr 2018 08:55:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523980531; cv=none; d=google.com; s=arc-20160816; b=WYg2GuTtt2DCGgfiWkRhLh+82EL920kuLU/PGp57fYDvjSbsGuPHOygA1BKizPge7P ibLjVwkBoocWPneZhnu2U5A7MiRn1MYiHMRIDkCHAY8diFg5HYHGobtXba36BrPfIP+R Y3uscQ+Sp2PowavttQEa4+31n+hLDsVZqKz3vjpvsWRh7CXRKybkykxH/hLyX2ur2CaY LVCi7tEgb0pzGzDsmCQ0XDgbpTwiazxfvmkvu1MWJ63nMtUH8GuRJxHQTjIrJAmF6Kmu LxaZOi31aCyzhaa3LLBzmTJkZAscYL3mrfKXK2NnTPnm3UFZYis2tVd51C7WTZJKbzMM 1PTg== 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:mime-version :user-agent:references:in-reply-to:message-id:date:to:from:subject :dkim-signature:arc-authentication-results; bh=UmS8+vd+6uY+aFGydnJA8fDH1f0obAe6fT0S5BLF9n8=; b=V+kSWa/JGLNwJrbkqK2mrb3ihgDYs9vXfUQfsFcJuvPb77dqlmcd7P7pcg+m/C6jr0 ztUPmDWldWgx6OkkPusQlVnJqY/W9Xqv6sAlG6MksaSWWa2CYp2qcdIzeTVKmzQg47EA VlFS01GckKC6NFAYeaLZQiVEKERVYeE7D1cJk6b62gRA2sRYZIkYCUwGkI+TKbTPA+b7 kMh6iqYs3ouyTg1vXXagFsZrTNrOLzQ1rViHTwhUcj+uidISozsJ98B2/otkXw3O4yPB 1SJrBKz5qJxpnLJo56BPthS6embACRhFiHXnK8W1hupACSrNOOje25vB/aK7Ri3/da7g qypg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=TD+pUH2z; 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 u188si634985pgc.170.2018.04.17.08.55.17; Tue, 17 Apr 2018 08:55:31 -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=TD+pUH2z; 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 S1753170AbeDQPxn (ORCPT + 99 others); Tue, 17 Apr 2018 11:53:43 -0400 Received: from mail-db5eur01on0125.outbound.protection.outlook.com ([104.47.2.125]:5408 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752672AbeDQPxi (ORCPT ); Tue, 17 Apr 2018 11:53:38 -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=UmS8+vd+6uY+aFGydnJA8fDH1f0obAe6fT0S5BLF9n8=; b=TD+pUH2zH9fAt5RBMuuxTu6K73v+rW0Jn1PZJ5AxkvP4V9+36Xde596GpEw6Vdo6omU7D+ju/MNMGYRunxNYFjI1GGny1HP8LLHoKGFLmW9aUW52MKFETn/HZ9S8sjqmD/f8a0SiQIlmJF2UFSwj1lTUWeKry8MWRpyrOvBA3VI= Received: from localhost.localdomain (195.214.232.6) by HE1PR0801MB1340.eurprd08.prod.outlook.com (2603:10a6:3:3a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.675.14; Tue, 17 Apr 2018 15:53:31 +0000 Subject: [PATCH v2 03/12] memcg: Refactoring in alloc_mem_cgroup_per_node_info() From: Kirill Tkhai To: akpm@linux-foundation.org, vdavydov.dev@gmail.com, shakeelb@google.com, viro@zeniv.linux.org.uk, hannes@cmpxchg.org, mhocko@kernel.org, ktkhai@virtuozzo.com, tglx@linutronix.de, pombredanne@nexb.com, stummala@codeaurora.org, gregkh@linuxfoundation.org, sfr@canb.auug.org.au, guro@fb.com, mka@chromium.org, penguin-kernel@I-love.SAKURA.ne.jp, chris@chris-wilson.co.uk, longman@redhat.com, minchan@kernel.org, hillf.zj@alibaba-inc.com, ying.huang@intel.com, mgorman@techsingularity.net, jbacik@fb.com, linux@roeck-us.net, linux-kernel@vger.kernel.org, linux-mm@kvack.org, willy@infradead.org, lirongqing@baidu.com, aryabinin@virtuozzo.com Date: Tue, 17 Apr 2018 21:53:21 +0300 Message-ID: <152399120185.3456.1990374174129524641.stgit@localhost.localdomain> In-Reply-To: <152397794111.3456.1281420602140818725.stgit@localhost.localdomain> References: <152397794111.3456.1281420602140818725.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR07CA0020.eurprd07.prod.outlook.com (2603:10a6:7:67::30) To HE1PR0801MB1340.eurprd08.prod.outlook.com (2603:10a6:3:3a::8) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(5600026)(2017052603328)(7153060)(7193020);SRVR:HE1PR0801MB1340; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1340;3:SXleErfAXDawe5n7dTHw7lTqcVaUYKd9arJU9e35ieZXbg33L98BYSAhrDJbNiQc05O4D08/Hu1AZbxtoFjpRp12QdteiqYlr1BiTNsYhHIkEQY/WzZRbqhx4QueulPzjSpoq0v90OVyaDHPA1nPr0V6wkMMn7VaNg8JSzruKbafKBJ5YXp4aFQ0/M9yXzGsyc/zVNnsZTRAmIMmKtOa2xglN7h7yMEAQJc502iipOW46pyNXha0LYhcrgyIpArJ;25:WJOnPfnm/v/ZszUQ9qkhs8Q+tf5PEWqQF0GZbGUpUaTGSo28CsBxI55tQFtlwaiguWBisEQkThMo7IqACVpiP1t06bzbHR6tysDcyajjgsdkMkfWY4f72sZbsoo+Y0xNM6QvPhK1aI70XJXKwZy3/dZy189F59pv7FbwdkXp6K5EWCAhC71MNHpU+Sn5jdSVAU4yKS6fXQSY5QGuRgMINfIEiHFjXbEdi+a6wQ960j55qlbMiiYtdFnOwFNw8kIufZPMvTLq4A8By3uDlwWzjIiez8ol0MyOw13gWoFJjHmhFceO6kOsAUgtCgL/4rzj1q1DJHZ0og/gpMMWHf5hPQ==;31:hAjCnFnKTYBImDNrgm/wK8cEYGnenbMxVxoDFbv5UFxxqHlGPtbetMCdgH+9a9BDT3RuedUQeVoxdCl9H+8V3Ff+BVg3ZnP0qoFE/CvHpyD53qM3Vp6ZmGnVDGXwGPMdj9bKNjIUGqpCuptRHqmcd9gdT+X6zzVcZOaZAEA2ovnEokyHCqwAkjutvmhPKQhSvCBGMNxbTPUe/tRJ/fnKzNy6KyCgPbbN+QhRTfe1BoI= X-MS-TrafficTypeDiagnostic: HE1PR0801MB1340: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1340;20:1fT3x/TFwRqCTxCusqdew4lrohRdsUdYaqpT11k3TorbNLEEIuk4Lyux/ycxe/OJ8jnT+r3m5LIimsskVacquocSo/22S8Z/3jvKv0eMPp1qsNIv+jFU0XcKZSU5rwFb5pIJZhvDh3ynPiB4faBba5SoB5Q+gn50V0fcjdfbR8yilydFyR+ERMCvQKSW77mIwaVCxngODzxrZAgXREmtef59JbVjaEYTsgAfGajOYaNcSHVVHl751mfhfUkcx4LmKhwEp6m2s0IVBnpKPcArM9Lgpd+DBQy4lXufhxIeeLwkDaEkh0vZN07abZwXFaZFpqA0wOQhChbXKNNhK8UFbz1d3fAMJc8KcQ+klf//yG3EGABx6YzOyO38Onflx52ZcWJLzKE8095htaUJp6HBvAnUruf4fMQNr4KEUTyJ72e6cTbHnpL9sQN/PxTUlGCka31FJPYw1mMj/UpO1xZhLcvS5Bv36HSv4FyYcGAq8GQdijHDAliEJlsnuS4eXtKf;4:1KCHf+fS0GghiDKdnGbJ1Wm7DnEk/rwkRJBi7uFx9CRGm9tJ3LPgBeCGmX2ecixIIPo5lAQBl9+o2yqqdzFyD7bUFE1zC+xw983D/hjOfrVWbegiMcNKomyHw8Op344uRb6uh+lwzBHXWNJv0mUDLlfVL0qxYqojiIcDvCV9GguxBSAGYd4hKR13tJNFXdb8lLqJhmfoF1W9Y9cwljpYm2v0uWlyf0nrq2AFAtPEvevzIkt6fEVJ4DH+KwtciDlDfG8LzLlucnnaZ7G59Rh1UA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(3231232)(944501359)(52105095)(10201501046)(3002001)(93006095)(93001095)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:HE1PR0801MB1340;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0801MB1340; X-Forefront-PRVS: 0645BEB7AA X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6069001)(366004)(39850400004)(376002)(39380400002)(346002)(396003)(199004)(189003)(6116002)(66066001)(386003)(68736007)(7736002)(16526019)(478600001)(486006)(58126008)(7416002)(956004)(53936002)(305945005)(86362001)(55236004)(316002)(47776003)(476003)(97736004)(55016002)(33896004)(11346002)(8936002)(103116003)(5660300001)(76176011)(52116002)(7696005)(81166006)(105586002)(81156014)(8676002)(61506002)(446003)(23676004)(2486003)(3846002)(9686003)(230700001)(39060400002)(6636002)(25786009)(6666003)(186003)(26005)(50466002)(2906002)(6506007)(106356001)(921003)(1121003);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1PR0801MB1340;H:localhost.localdomain;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtIRTFQUjA4MDFNQjEzNDA7MjM6RDFUWjlwbGxmVis4WXRwdmlJb25seURt?= =?utf-8?B?RXB1VVMwUm5qUWhPclN5OEpNblRidGk5WDR5bE84U2txclc1UllRdjFMdk1M?= =?utf-8?B?bkdaWGtUY0s0a3ZMMWlRZ1crTU1aZ3hwK2xuQTJXaHNXWFR4YzNDWmNsM296?= =?utf-8?B?ZFhPNzJiUGtmS3Nmb20zMTg5dFFlNGgxQit1Q1k1a0ZzWUNuUHZ0eVgzdGJO?= =?utf-8?B?dGtHR0RhZ3VTNFdXQnIrR1NWTXlGVUJRU3g5cjhhQlRaQmVJalFUSEdkUTVl?= =?utf-8?B?UFZVdjUvMk9YWlhCUnR5a3VCTnRxNzNjNUdzbVdpNktBeFVRYUQ5RzVSVkY4?= =?utf-8?B?RzZOekkweS84MDZpOFlESmZPMmlYUHFVRXM2bmd4OTlNTkgyTmtIUlZ3Z3cx?= =?utf-8?B?MUZqemtodUt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WeT+g= X-MS-Office365-Filtering-Correlation-Id: bf5d5ac6-ca72-46fa-f9fb-08d5a47b5f2e X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2018 15:53:31.9202 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bf5d5ac6-ca72-46fa-f9fb-08d5a47b5f2e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1340 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Organize the function in "if () goto err" style, since next patch will add more "if" branches. Also assign and clear memcg->nodeinfo[node] earlier for the same reason. Signed-off-by: Kirill Tkhai --- mm/memcontrol.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index d99ea5680ffe..2959a454a072 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4327,20 +4327,22 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) pn = kzalloc_node(sizeof(*pn), GFP_KERNEL, tmp); if (!pn) return 1; + memcg->nodeinfo[node] = pn; pn->lruvec_stat_cpu = alloc_percpu(struct lruvec_stat); - if (!pn->lruvec_stat_cpu) { - kfree(pn); - return 1; - } + if (!pn->lruvec_stat_cpu) + goto err_pcpu; lruvec_init(&pn->lruvec); pn->usage_in_excess = 0; pn->on_tree = false; pn->memcg = memcg; - - memcg->nodeinfo[node] = pn; return 0; + +err_pcpu: + memcg->nodeinfo[node] = NULL; + kfree(pn); + return 1; } static void free_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node)