Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp2398008ybg; Thu, 30 Jul 2020 20:21:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZXvEmBDT5iYyTyBZkAO14KcQ0LeWFUd9Gf87O14jO93gadvNewDr7bcKLZbgl8bbuCSGB X-Received: by 2002:a17:906:694b:: with SMTP id c11mr2043867ejs.232.1596165673692; Thu, 30 Jul 2020 20:21:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596165673; cv=none; d=google.com; s=arc-20160816; b=Vs0RW5sMstR2zQI/WxnSOeU+ciZy6CB2XsiswP1gz3G56gokhm43GSHBxECkFjHJBN bVKpiTZxXsO4m3zq0RCR6SWtr40QLO6+mXPwBuiu1436KGODAdUi2CAOy6COIjpwfmWf Lrtz6lG/FgRdgZ6yLM/Tzuva/xI6BuLPz1aWBzRE0zqlEsjrxmp4vQQmzJ5opYI+vwOR KBrpGKZFcJvMZqgdpiOMmcYSN8Pg5DWC6RONHcTuszSHjlOilgEmMk5s6ErlGQrGYtnH oGPLmkSL+ankGGhpje5+4d4gLpNkI1YukiEWTf/uIUDanfOsjvG/eAmq903qb5GRtfK+ fqZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :subject:cc:to:from:date:dkim-signature; bh=SR7+yosq1xp0zigF9l1fWsxuDY4XPAok3oMTFmLnUZc=; b=GraTrvmtOAFLZQVyXVObKZLi2txWE7ASIG22aVmJ+wFiOmsj4bbLU7ckhjnvtJAtzR xIjaD/wNc2Wz3LltESVnTJxsg0ydeZ1HjLrYQXMhzzuoNU4DLkzH88+rmlm6VhUtVSeQ qjlB0HfKRDyw59/eWt96Pfi4wJme2OceX0pkEn6TkDit8A4oWfPykTTFQR38e/TQ15zx tfq/r0FAQ++0Lkhg1MjeXWTwKSiKQwjTI9uVQnvB6kJwpSQQmn6Bk2k+9fk9c+JaeT8M /9GukwsioYX0umIM87lcbLtVBCQMPwglkTbHt8hbJG8yubOy8x59RyBQzwXG3aqEwCCv IOmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=lAKSCIQ2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb13si4603132edb.336.2020.07.30.20.20.46; Thu, 30 Jul 2020 20:21:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=lAKSCIQ2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731248AbgGaDSH (ORCPT + 99 others); Thu, 30 Jul 2020 23:18:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730820AbgGaDSG (ORCPT ); Thu, 30 Jul 2020 23:18:06 -0400 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 975D7C061574 for ; Thu, 30 Jul 2020 20:18:06 -0700 (PDT) Received: by mail-qk1-x736.google.com with SMTP id b79so27595749qkg.9 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=Ox6l1lcj03gLazP73N7hfeKcJvMi8uSQuOSZE/N/xMsBQF55Inn+4aoJ8qdAnwNfzj m5AEE4SmQt6ShwayjXbkQshaYWFB65ivJa2yKNQj2VG54p6eaCwTygYiT0bx4pyzqe7P q4C+qdFYYq09OdkarzltwfDTAkKbv0J0wv2OhRpdiJOmT8mKCkrzkxdUskuB+P0YOryg MP4Lbj6pSixyfhw08yvO4MjO/OQ4gi6yClo/A2jDjp6WuUTxQlFS9NehAsBRsBjM4xWx 8U/0kcMobgW/NYU6oKFigXpWzCE0pZt2iJhE8gu7cuFDPGAqTDlZx/TZy3T+0EXL+BRO lE3g== X-Gm-Message-State: AOAM530AW96nY6p3JUZbw1dZ8+JqehQLKOaBOGcbJL82W1x70R16PCRV CLdfrjJgaHzYysosLDxFDkdbWg== 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 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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);