From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F59DC352A2 for ; Thu, 6 Feb 2020 15:27:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 04D3D2465D for ; Thu, 6 Feb 2020 15:27:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="yqZ/FZfL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 04D3D2465D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9A0C86B0003; Thu, 6 Feb 2020 10:27:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9523A6B0006; Thu, 6 Feb 2020 10:27:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 83FD16B0007; Thu, 6 Feb 2020 10:27:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0113.hostedemail.com [216.40.44.113]) by kanga.kvack.org (Postfix) with ESMTP id 6C3716B0003 for ; Thu, 6 Feb 2020 10:27:08 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D783B180AC15C for ; Thu, 6 Feb 2020 15:27:07 +0000 (UTC) X-FDA: 76460080494.08.way84_785f49f12b315 X-HE-Tag: way84_785f49f12b315 X-Filterd-Recvd-Size: 4430 Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Thu, 6 Feb 2020 15:27:07 +0000 (UTC) Received: by mail-qk1-f193.google.com with SMTP id x82so5879097qkb.8 for ; Thu, 06 Feb 2020 07:27:06 -0800 (PST) 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=XZOggLanx1OakxhbvmLypkwLB6o7BwYbW0LP99Ryt1o=; b=yqZ/FZfL7rzCP/2Jqs5bBr0b3LqQr+WLoYGIPyBGKw6323lJiZKUFKys6E+VHeTJf2 Q6Piw50B5YbifhP9CblDm+U1GrvZEKZfGAIM/WgHxJp8L+nPX03q6D8VELhZ9R6NOLtJ 0N0BATZjWI1IczjjfHIveuTCnUgMe+YptD0IpellozuQtXZMs1KXJDOQoRD808ussEVS Oeq1YPf/gA/4zQLcWiJBTPhyXQkV4fdKw2VzJoUCEkl+iDXax7CtlZ/cnhsc9SesEK6s rSpSpV2Ot3fvi+Ga5GgVIr1vsjh5V4Ifnz9qtatPI8rzuX97IK5IffeOowrdFDe+hNk2 Ak9A== 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=XZOggLanx1OakxhbvmLypkwLB6o7BwYbW0LP99Ryt1o=; b=J8n8mYR8hA4E/IWcpZhqz80NzpYJTfNYHZ9YZ54hGD2iCB3OkJK+q+8buDSB2MbAfQ cl/pgUuChjV2qj298hItHz6JlQsKEBcWyleh2o1edIix8hT1+56/4d81BDfLS25AvVdk 2R1qvtOJVAmKlK4XtV7TEkgu2jQ9D3vtomEF3YiHzSzfYewfanP6FcAvRWvjYmz3QtYZ rt5phPO6QCxZcUpE7HYqE15XuZFdj5G4hj0pLySmhLAKneisvLjbI+D+5QvItJ0i9Vff dNsQqmqJeU73uhPUhXit7Z3gZM7wLKVj/hQbYXvA0AmmjzURUA18oRR5FNN6labEM0+z Na6g== X-Gm-Message-State: APjAAAXbhe7d1XMwzRKVcYmelwwT00spHr4RH9zo7jHZKzcehFv4kYkZ 9+WtwHgT3QUt99cEtyJEFl7DOg== X-Google-Smtp-Source: APXvYqwoCWoPoxMsBmJ48AbMG+4iF96O7gepmNsPc8GfJXUuFMj8rT6ge/PsiVIYjdA9hTy/JKrEoQ== X-Received: by 2002:a05:620a:7f4:: with SMTP id k20mr2931953qkk.483.1581002826313; Thu, 06 Feb 2020 07:27:06 -0800 (PST) Received: from localhost (pool-108-27-252-85.nycmny.fios.verizon.net. [108.27.252.85]) by smtp.gmail.com with ESMTPSA id b24sm1741820qto.71.2020.02.06.07.27.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2020 07:27:05 -0800 (PST) Date: Thu, 6 Feb 2020 10:27:04 -0500 From: Johannes Weiner To: Dan Schatzberg Cc: Jens Axboe , Tejun Heo , Li Zefan , Michal Hocko , Vladimir Davydov , Andrew Morton , Hugh Dickins , "open list:BLOCK LAYER" , open list , "open list:CONTROL GROUP (CGROUP)" , "open list:CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)" Subject: Re: [PATCH 1/2] mm: Charge current memcg when no mm is set Message-ID: <20200206152704.GA24735@cmpxchg.org> References: <20200205223348.880610-1-dschatzberg@fb.com> <20200205223348.880610-2-dschatzberg@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200205223348.880610-2-dschatzberg@fb.com> 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: On Wed, Feb 05, 2020 at 02:33:47PM -0800, Dan Schatzberg wrote: > This modifies the shmem and mm charge logic so that now if there is no > mm set (as in the case of tmpfs backed loop device), we charge the > current memcg, if set. > > Signed-off-by: Dan Schatzberg Acked-by: Johannes Weiner It's a dependency for 2/2, but it's also an overdue cleanup IMO: it's always been a bit weird that memalloc_use_memcg() worked for kernel allocations but was silently ignored for user pages. This patch establishes a precedence order for who gets charged: 1. If there is a memcg associated with the page already, that memcg is charged. This happens during swapin. 2. If an explicit mm is passed, mm->memcg is charged. This happens during page faults, which can be triggered in remote VMs (eg gup). 3. Otherwise consult the current process context. If it has configured a current->active_memcg, use that. Otherwise, current->mm->memcg. Thanks Dan