From patchwork Fri Jul 31 03:17:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 11693945 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 C72F913B1 for ; Fri, 31 Jul 2020 03:18:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8438C20829 for ; Fri, 31 Jul 2020 03:18:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lAKSCIQ2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8438C20829 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 87B438D0010; Thu, 30 Jul 2020 23:18:07 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 82DA98D000B; Thu, 30 Jul 2020 23:18:07 -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 719DB8D0010; Thu, 30 Jul 2020 23:18:07 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0229.hostedemail.com [216.40.44.229]) by kanga.kvack.org (Postfix) with ESMTP id 5CB748D000B for ; Thu, 30 Jul 2020 23:18:07 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 080A5181AEF09 for ; Fri, 31 Jul 2020 03:18:07 +0000 (UTC) X-FDA: 77096912214.17.queen37_0b09a3226f80 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id A3F50180D0185 for ; Fri, 31 Jul 2020 03:18:06 +0000 (UTC) X-Spam-Summary: 1,0,0,a6882287ec619ffc,d41d8cd98f00b204,hughd@google.com,,RULES_HIT:41:355:379:800:960:966:968:973:988:989:1260:1277:1313:1314:1345:1437:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2689:3138:3139:3140:3141:3142:3152:3352:3865:3866:3867:3868:3870:3871:3872:3874:4321:4385:5007:6261:6653:7875:8660:9592:10004:10400:11026:11232:11658:11914:12043:12297:12438:12517:12519:12555:12679:12740:12895:12986:13069:13148:13180:13229:13230:13255:13311:13357:13439:14096:14097:14181:14394:14659:14721:21080:21444:21450:21627:21939:30054:30070,0,RBL:209.85.222.169:@google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04yfyg9otfte9n79bgqa6xjenwjb8opgq7pjtzbuaferwn8iikhfutmmzz4g556.bjqsrq6hz98848oakyi74ed46udpjxebfrxua3rb1rcxjq5xz5jkw91bxsj7649.k-lbl8.mailshell.net-223.238.255.100,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:26,LUA_SUMMARY:none X-HE-Tag: queen37_0b09a3226f80 X-Filterd-Recvd-Size: 4482 Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Fri, 31 Jul 2020 03:18:06 +0000 (UTC) Received: by mail-qk1-f169.google.com with SMTP id g26so27688588qka.3 for ; Thu, 30 Jul 2020 20:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:user-agent:mime-version; bh=SR7+yosq1xp0zigF9l1fWsxuDY4XPAok3oMTFmLnUZc=; b=lAKSCIQ2Rm1+s3DGdgW2sY0SDCmsMzaowSi7+qudL2dAuv8GkPJze1HW+crvQ6Bhfa bkM2/M1ClQC6+0080PfNkgGwgB0AbZq1JsoB8c9CImd523NXd9fNcPWF/5YNjMQICD+Y kpXpwM+1wPiFvPABKKPQUbIdDPsEOsUfphQLlmbyxkGOBWAQLsXXp9GEM5eDp82hPbZa EOQ+UK60Akrhw6dGGA7YbsemwJu5TM6rh1aIzwbI1wpgfC3+fSULumcTUeCrc0DAOzpZ TL+Y5mNy6ctfeP06zq+RB2wSm63t5aiEvC4e2SEf0ZVyRmmnHq+taF6/YOWS4xqjrBAf gmQA== 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:user-agent :mime-version; bh=SR7+yosq1xp0zigF9l1fWsxuDY4XPAok3oMTFmLnUZc=; b=buFVHzxQY431dqpuBOi91gsqE9Y2I3nfYQ/QH7C0MZ/7aWqJ9deMYU/4maVl3GBE4H 4PYktoVit4Whd4l8+/Am3VJFhNSnWkKuWPHbPO8zgiXsH+h+0UUaAoT+0X1qXS89R1DT o+Amh0+AKOGvOzdrQAe/+I+4e9mQ6oBSpCSZcrEJDHUmQa8ecwMchYVjDz7WLOzonYOQ +X64uHBPZUO27fjDXau63PbPIjO84vi5Nh3UrWqxx+Oc3NnAJu+kEPuQ7DhdSGJJ0zFV w+TfIg777xuaTP/w6PWnM4VKreWsB0PK9SjOJY+vYJzxj0LMDSH0doyCDnfkzz/29uzq bhRg== X-Gm-Message-State: AOAM5326omAxI+WEg8becjxDjlHOGLciJcbUfTOVqCNwj2Cj4k3lrbRI t2ixVm1r1BSZcXSIm0RwA1Bovg== X-Google-Smtp-Source: ABdhPJwDwQt3K/iTgMokrKbRI7xWY04eq/mt5E9rmbuM1E79HWT25mrsITLMlCNlT8E1q0fjShonhQ== X-Received: by 2002:a05:620a:1424:: with SMTP id k4mr2210742qkj.2.1596165485326; Thu, 30 Jul 2020 20:18:05 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id s38sm7256566qts.78.2020.07.30.20.18.03 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Thu, 30 Jul 2020 20:18:04 -0700 (PDT) Date: Thu, 30 Jul 2020 20:17:50 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Andrew Morton cc: Roman Gushchin , Johannes Weiner , Shakeel Butt , Hugh Dickins , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH mmotm] mm: memcontrol: decouple reference counting from page accounting fix Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 X-Rspamd-Queue-Id: A3F50180D0185 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: Moving tasks between mem cgroups with memory.move_charge_at_immigrate 3, while swapping, crashes soon on mmotm (and so presumably on linux-next): for example, spinlock found corrupted when lock_page_memcg() is called. It's as if the mem cgroup structures have been freed too early. Stab in the dark: what if all the accounting is right, except that the css_put_many() in __mem_cgroup_clear_mc() is now (worse than) redundant? Removing it fixes the crashes, but that's hardly surprising; and stats temporarily hacked into mem_cgroup_css_alloc() and mem_cgroup_css_free() showed that mem cgroups were not being leaked with this change. Note: this removes the last call to css_put_many() from the tree; and mm-memcg-slab-use-a-single-set-of-kmem_caches-for-all-accounted-allocations.patch removes the last call to css_get_many(): now that their last references have gone, I expect them soon to be freed from include/linux/cgroup.h. Signed-off-by: Hugh Dickins Acked-by: Johannes Weiner Acked-by: Roman Gushchin --- Fixes mm-memcontrol-decouple-reference-counting-from-page-accounting.patch mm/memcontrol.c | 2 -- 1 file changed, 2 deletions(-) --- mmotm/mm/memcontrol.c 2020-07-27 18:55:00.700554752 -0700 +++ linux/mm/memcontrol.c 2020-07-30 12:05:00.640091618 -0700 @@ -5887,8 +5887,6 @@ static void __mem_cgroup_clear_mc(void) if (!mem_cgroup_is_root(mc.to)) page_counter_uncharge(&mc.to->memory, mc.moved_swap); - css_put_many(&mc.to->css, mc.moved_swap); - mc.moved_swap = 0; } memcg_oom_recover(from);