Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp126864ybz; Thu, 23 Apr 2020 20:03:37 -0700 (PDT) X-Google-Smtp-Source: APiQypJpcVj4DOQ4cFDxop7uBZFjs5ayKAYNeZhjf+VbbPlOOg4yzxSlxLMfy0mAWbEauWEjiGDF X-Received: by 2002:aa7:d655:: with SMTP id v21mr5572198edr.355.1587697416906; Thu, 23 Apr 2020 20:03:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587697416; cv=none; d=google.com; s=arc-20160816; b=iXfRcCKGuuHcq2rf//QMFKywxTQKsCfe4SxwdedG13DXACk/UgIZmW/5uDHSAwXYkJ Bj4NMhPdhPoH+Z+X9C0Lcdp65vlrBnEv17sB1unmbEDVfueLeQYEQ5x5z2XPPXEHIwZM /o2bipi5EPTXMCZcOSrfHpPuClfUmryikHG5G67oLFvgfvcNSk6BPlkjLZPxxEXRjNWC C/WoWVnKGp6oA1/Go3mS8k1zOvUKB1yCVcLyPglTFPg/67mkZX16QhtDerYJNXqXHvR5 ke5d3FajynTST7Omsps75c5RPjEIONwtoW2cptcly/ATj6oKuxekIzHCvIud5/0M2o0N z1RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=kyzduwWV8InceUnIl0vidH/X3bbDtm0JxJsBZQHUEsg=; b=jr7tIlDzSTUElnsZJOWb5uFCfw6xnsc/EZwOqD7mJy+rQMeFj31ex+mgnmUU6w0fKC mZa2+dt7UkTEXyFvSKp0D/NdelAdsLl1qsPu61jkJz9S/RxMBaZGarmmIrtXGLinaniV jGk+7izwYdAPWFNbINs8vVfwhq5cRL+dGVpmivl8xb6/HYypMx+YICgNmwGG5C8v/f0A 8wGfDG8qTZ0Qzd91klFdqeBsutWqFaFqXd0V0HOLciOH+BewCC3KLSQkGUHkYKaEF2Rw ADMNAULgltRvbpheb+ljzRujXPJHXPtYQZY/w0qFRMu40EjDVcV28uqB57Cqn9ZF0HyY WVbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=xCajfsFC; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f12si2273236eja.218.2020.04.23.20.03.13; Thu, 23 Apr 2020 20:03:36 -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=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=xCajfsFC; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726240AbgDXDBV (ORCPT + 99 others); Thu, 23 Apr 2020 23:01:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725913AbgDXDBU (ORCPT ); Thu, 23 Apr 2020 23:01:20 -0400 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8649C09B045 for ; Thu, 23 Apr 2020 20:01:20 -0700 (PDT) Received: by mail-qv1-xf42.google.com with SMTP id di6so4018255qvb.10 for ; Thu, 23 Apr 2020 20:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=kyzduwWV8InceUnIl0vidH/X3bbDtm0JxJsBZQHUEsg=; b=xCajfsFC29zFs0ldyM1nenfzOzJDtFNYbMcgKb1rYjfjosHZZWeWeXnPI+8bxZ2ntm XHXSecOpa9F53pVydA37qwBNQQz3IM8/taC9P6tAXhUnpQt/iT4a01qo0tF1UzjpM1pl 9weajk44I9MEZiCL03RFgeD8nMd6M1w7/fZJVwQ9w0ADRRNU6IYndhE3AF/qOVSxKDnx voK4SCOCZVyquDhFXfze9UC5Qoftazh/65yyjBEJeOa43yxDbu4gxT1oLoaN8bh/AsTH 9tc/JQBlf043Zpg9/w1+sY2RY/7r2b4k7AZyRfSTf+lRVIRzyrXJ5E4L4HDmZr5V+x+J G9zA== 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:references :mime-version:content-disposition:in-reply-to; bh=kyzduwWV8InceUnIl0vidH/X3bbDtm0JxJsBZQHUEsg=; b=E3/TJ0WJf73/Ggw9rBUTgiP+TPIgThsGwIiDT4Bxt9qonnZ3kmyP+7cL6H+1X23yQp dWIIX92NbzdsMBSu+PJfbKSEy4AIxvk1IH3pTTWoMtSQMZvwWxDDP5dOMU45LhJAi5Wx I/LUhw2yCqBaarPR4bF7L5tKEmAZp4E+zru93IMJkadkuJZgUUDdyrhQkHXUyFYwbjS9 UFrM8Wtryn0v5h2S3i6HF3Ys2Lnptej6DiPDJnEfEhRS5InCHBk19CfDFzVu3ZWCBQQ3 W5RUP1Bbvl5gDJNBS9kSKPHWzP2MBZXRM2hHQtdpN0DnZZcgjAxItMpG1g1ZpYEGvOgc 9nxg== X-Gm-Message-State: AGi0PuYm+LSxrX3Vm9ZVtU3ZfxfKegCU27NVJBQ7W12a8MEhaqQBkFXE cFMKfTMJWKcb3BXxeHlPKysSZA== X-Received: by 2002:a05:6214:1812:: with SMTP id o18mr7437268qvw.64.1587697279787; Thu, 23 Apr 2020 20:01:19 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::921]) by smtp.gmail.com with ESMTPSA id g187sm2808459qkf.115.2020.04.23.20.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 20:01:19 -0700 (PDT) Date: Thu, 23 Apr 2020 23:01:17 -0400 From: Johannes Weiner To: Joonsoo Kim , Alex Shi Cc: Shakeel Butt , Hugh Dickins , Michal Hocko , "Kirill A. Shutemov" , Roman Gushchin , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH 15/18] mm: memcontrol: make swap tracking an integral part of memory control Message-ID: <20200424030117.GC464082@cmpxchg.org> References: <20200420221126.341272-1-hannes@cmpxchg.org> <20200420221126.341272-16-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200420221126.341272-16-hannes@cmpxchg.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 20, 2020 at 06:11:23PM -0400, Johannes Weiner wrote: > @@ -6884,9 +6876,6 @@ void mem_cgroup_swapout(struct page *page, swp_entry_t entry) > VM_BUG_ON_PAGE(PageLRU(page), page); > VM_BUG_ON_PAGE(page_count(page), page); > > - if (!do_memsw_account()) > - return; > - > memcg = page->mem_cgroup; > > /* Readahead page, never charged */ I messed up here. mem_cgroup_swapout() must not run on cgroup2, because cgroup2 uses mem_cgroup_try_charge_swap() instead. Both record a swap entry and running them both will trigger a VM_BUG_ON() on an existing record. I'm actually somewhat baffled why this didn't trigger in my MADV_PAGEOUT -> MADV_WILLNEED swap test. memory.max driven swapout triggered it right away. !do_memsw_account() needs to be !cgroup_subsys_on_dfl(memory_cgrp_subsys) > @@ -6913,7 +6902,7 @@ void mem_cgroup_swapout(struct page *page, swp_entry_t entry) > if (!mem_cgroup_is_root(memcg)) > page_counter_uncharge(&memcg->memory, nr_entries); > > - if (memcg != swap_memcg) { > + if (do_memsw_account() && memcg != swap_memcg) { > if (!mem_cgroup_is_root(swap_memcg)) > page_counter_charge(&swap_memcg->memsw, nr_entries); > page_counter_uncharge(&memcg->memsw, nr_entries); And this can be !cgroup_memory_noswap instead. It'll do the same thing, but will be clearer. I'll have it fixed in version 2.