From patchwork Fri Sep 20 12:29:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyrill Gorcunov X-Patchwork-Id: 11154369 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 E97AE1747 for ; Fri, 20 Sep 2019 12:29:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B57D121A4C for ; Fri, 20 Sep 2019 12:29:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GNbjA0OL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B57D121A4C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DF8006B0003; Fri, 20 Sep 2019 08:29:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D81686B0008; Fri, 20 Sep 2019 08:29:12 -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 C22C16B0266; Fri, 20 Sep 2019 08:29:12 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0249.hostedemail.com [216.40.44.249]) by kanga.kvack.org (Postfix) with ESMTP id A2BE76B0003 for ; Fri, 20 Sep 2019 08:29:12 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 2620E181AC9B4 for ; Fri, 20 Sep 2019 12:29:12 +0000 (UTC) X-FDA: 75955228944.24.mind88_5046d99e39b1e X-Spam-Summary: 2,0,0,9e3a78eb3c1dff90,d41d8cd98f00b204,gorcunov@gmail.com,:linux-kernel@vger.kernel.org::hannes@cmpxchg.org:mhocko@kernel.org:vdavydov.dev@gmail.com:ktkhai@virtuozzo.com,RULES_HIT:41:355:379:800:960:965:966:973:988:989:1260:1277:1312:1313:1314:1345:1437:1516:1518:1519:1534:1541:1593:1594:1595:1596:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3867:3868:3870:3871:3872:4385:4390:4395:5007:6119:6261:6653:7514:7808:7875:7974:9413:10004:10400:11026:11658:11914:12043:12291:12297:12438:12517:12519:12679:12683:13069:13311:13357:13439:13895:14096:14097:14181:14394:14687:14721:21080:21444:21451:21627:21666:30054,0,RBL:209.85.208.194:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:27,LUA_SUMMARY:none X-HE-Tag: mind88_5046d99e39b1e X-Filterd-Recvd-Size: 4126 Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Sep 2019 12:29:11 +0000 (UTC) Received: by mail-lj1-f194.google.com with SMTP id j19so5414981lja.1 for ; Fri, 20 Sep 2019 05:29:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=zRqTS3V+m+4w0d7L5MeANtoAWhuIONw+ofn7LfLax7M=; b=GNbjA0OLqlXcmqK1epU19sHUETfXuc5bNucGPbu43hbBJRRCHB84gR38mBnRnV4QDn IsLVHtJ/kjm4u7fOP6Xnu/6GT+JJyZBaOnsg6ZJijLJnhT5zeOg9QWCV0kWvAAbLFriF O50eGu7iyy1t1jvOHVL5qWjQ7YgiuPKF6YtZxDRY1ymTQljCalRidsAh/YRtDx13VLkd +ydRU7HEhHJlDDdy5aCCUk5PhtNQ7vpwRDXzpV9Jlwzbs5BcBPrTgXlXehqdant/eC2d PXKCsTgY02l6NJsYzdfLbI6nUsWt8jgtQdnJiUAWfOqwxIWCpigPQVr4pg+cp1Y97Z9Z PmKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=zRqTS3V+m+4w0d7L5MeANtoAWhuIONw+ofn7LfLax7M=; b=E4OB33+JlaFxaXqUe5C+9mWVwbDyn9YQLVz/whHbrcc2ZHwmMFC6ATlz/Wb76JJi39 oxY974Q+IhL78zJaGA3YWPUhgKEAC+RKBa5MvIM8iA0DRMznnJVAxv08Nc4HR7YH3z1h KC4ljOP/De+ce4RCWh6v1IV694JDsYTAtKsoD/DFFLetWD+Gea5LNEgLSpjzT5an6wwk ywbXpPMo+VuDeafjYr2G6OvQ45egyNvLFGrZZU50RdeiL7ww+4jcodzXMBneiXTSUb0G 7m9gQzlEcEPsJYQdnShKwd0nH48pXa8PNitEgT3Jq+65v82vuGsT3xoof1W47Kh5R8SN htlg== X-Gm-Message-State: APjAAAXy6Y3jG90xe1PC8+WPddumZpjGZKqi4/TIvPoriVdjXS2nUz2C +DRpE3hympNXJ7zjxVeaats= X-Google-Smtp-Source: APXvYqysZ6X7F0kXPqDsa2l37Rkz7d6wWrYJIuXm6C88aYt/3zLc9GrhGdjYqnFW1nniutXZSOKk2A== X-Received: by 2002:a2e:6804:: with SMTP id c4mr9364426lja.120.1568982549984; Fri, 20 Sep 2019 05:29:09 -0700 (PDT) Received: from uranus.localdomain ([5.18.103.226]) by smtp.gmail.com with ESMTPSA id z72sm418739ljb.98.2019.09.20.05.29.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2019 05:29:08 -0700 (PDT) Received: by uranus.localdomain (Postfix, from userid 1000) id ED22E461797; Fri, 20 Sep 2019 15:29:07 +0300 (MSK) Date: Fri, 20 Sep 2019 15:29:07 +0300 From: Cyrill Gorcunov To: LKML Cc: Linux MM , Johannes Weiner , Michal Hocko , Vladimir Davydov , Kirill Tkhai Subject: [PATCH] mm, memcg: assign shrinker_map before kvfree Message-ID: <20190920122907.GG2507@uranus.lan> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.12.1 (2019-06-15) 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: Currently there is a small gap between fetching pointer, calling kvfree and assign its value to nil. In current callgraph it is not a problem (since memcg_free_shrinker_maps is running from memcg_alloc_shrinker_maps and mem_cgroup_css_free only) still this looks suspicious and we can easily eliminate the gap at all. Cc: Johannes Weiner Cc: Michal Hocko Cc: Vladimir Davydov Cc: Kirill Tkhai Signed-off-by: Cyrill Gorcunov --- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: linux-tip.git/mm/memcontrol.c =================================================================== --- linux-tip.git.orig/mm/memcontrol.c +++ linux-tip.git/mm/memcontrol.c @@ -364,9 +364,9 @@ static void memcg_free_shrinker_maps(str for_each_node(nid) { pn = mem_cgroup_nodeinfo(memcg, nid); map = rcu_dereference_protected(pn->shrinker_map, true); + rcu_assign_pointer(pn->shrinker_map, NULL); if (map) kvfree(map); - rcu_assign_pointer(pn->shrinker_map, NULL); } }