From patchwork Sun Jun 14 12:26:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11603281 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 153A2138C for ; Sun, 14 Jun 2020 12:27:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C4DA120775 for ; Sun, 14 Jun 2020 12:27:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.b="UZdFv0Xi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C4DA120775 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B97786B0022; Sun, 14 Jun 2020 08:27:21 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B47CB6B0023; Sun, 14 Jun 2020 08:27:21 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A37036B0024; Sun, 14 Jun 2020 08:27:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0042.hostedemail.com [216.40.44.42]) by kanga.kvack.org (Postfix) with ESMTP id 87C6C6B0022 for ; Sun, 14 Jun 2020 08:27:21 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4638A1EE6 for ; Sun, 14 Jun 2020 12:27:21 +0000 (UTC) X-FDA: 76927742682.16.boys29_6206c8c26ded Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 1D498100E690B for ; Sun, 14 Jun 2020 12:27:21 +0000 (UTC) X-Spam-Summary: 2,0,0,ef39bd8ba290a883,d41d8cd98f00b204,songmuchun@bytedance.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1437:1515:1534:1539:1568:1711:1714:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3865:5007:6119:6120:6261:6653:7901:7903:10004:11026:11658:11914:12043:12048:12296:12297:12438:12517:12519:12555:12679:12895:13069:13311:13357:13894:14181:14384:14394:14721:21080:21444:21451:21627:21740:21990:30054,0,RBL:209.85.214.195:@bytedance.com:.lbl8.mailshell.net-62.2.0.100 66.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: boys29_6206c8c26ded X-Filterd-Recvd-Size: 3647 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Sun, 14 Jun 2020 12:27:20 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id g12so5645526pll.10 for ; Sun, 14 Jun 2020 05:27:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=O3wDQLkjLZhz8HlGMqP3m6FBvc0T90YmqvSvkQbSHmY=; b=UZdFv0Xir9MEd893nm2NsmxcmIkqD+9uJfe/NWiB6X4ESmnvYuGlbYeBwqpFlqO9RE GEBYJJZFKnYz3RhjfSojLRVr5YVm5AGj/u7OUlKiuBC9pTCpa/UTUp4W0JS62X3RZVlN yUkG04sIKOg+sRsa+nZB76FklBpGfLDF2tULWeLOIx3xRMLvhRlyusQ8swY5N6V6FueI OgCRl6obnJBQmMr4UfhxeO0voZrS3sJhbQYyQanMRjl6HbdtGdAg8MKQCLIovef0xhA0 hY8ljJPDg1iToDvZczOb8CPHo34wtShhA11Rm7JQiD3cdRyhygvgKhIxkBp0UuA/gl99 oQpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=O3wDQLkjLZhz8HlGMqP3m6FBvc0T90YmqvSvkQbSHmY=; b=kZJuxb4nZcVpJMPGk/LdMFyTghWHiNrig+S9NGXTBnySdVha6WEA/ZFuVw2OeWMo6W i3cHedisI/pWz3tTs6ejHEhHsX+1meleXsBx9wPdDVqMbv1VemEd0CXMsRxjM3Yv+eLF 5JglWWga7QFiPAzSda9q+iQmLEH7AlmMWst+9l6E6khgIfqsepmXrJaYppiqO4X1RBZ/ whlGmXzAfkon5KwJ+lxEdwD/yO7LVfKEJdXy23xmYUKO8NYE1XdtYpr3vy6XSCgkN62F VfVvZCwU+kOUjMjrt8ujHDxtVEMatW+w/fTwBehHtySV/W8j08ub5ju5XAkDX8XJO99q bx4Q== X-Gm-Message-State: AOAM530A2u9BFWvrEJliH/hRCmK/GrLAGWAJFCJJey0W3ZiLkf5jORA/ MNDZ9jt0589Back0xV2Zj0ZeSA== X-Google-Smtp-Source: ABdhPJyKXq2O5tZt9d5Ihr84MF3ntpaY3fEND9aEIzF7aB1JW4W4ZCcKR2/fuQNjE6b9yQhdOpGLeg== X-Received: by 2002:a17:90a:de1:: with SMTP id 88mr7630576pjv.124.1592137639325; Sun, 14 Jun 2020 05:27:19 -0700 (PDT) Received: from Smcdef-MBP.lan ([103.136.221.68]) by smtp.gmail.com with ESMTPSA id u12sm9688454pjy.37.2020.06.14.05.27.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Jun 2020 05:27:18 -0700 (PDT) From: Muchun Song To: hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org Cc: guro@fb.com, cai@lca.pw, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Muchun Song Subject: [PATCH] mm: memcontrol: Fix do not put the css reference Date: Sun, 14 Jun 2020 20:26:53 +0800 Message-Id: <20200614122653.98829-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) MIME-Version: 1.0 X-Rspamd-Queue-Id: 1D498100E690B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: We should put the css reference when memory allocation failed. Fixes: f0a3a24b532d ("mm: memcg/slab: rework non-root kmem_cache lifecycle management") Signed-off-by: Muchun Song Acked-by: Roman Gushchin Acked-by: Michal Hocko --- mm/memcontrol.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 0b38b6ad547d..2323d811ee8e 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2772,8 +2772,10 @@ static void memcg_schedule_kmem_cache_create(struct mem_cgroup *memcg, return; cw = kmalloc(sizeof(*cw), GFP_NOWAIT | __GFP_NOWARN); - if (!cw) + if (!cw) { + css_put(&memcg->css); return; + } cw->memcg = memcg; cw->cachep = cachep;