Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1646101ybv; Thu, 6 Feb 2020 07:28:26 -0800 (PST) X-Google-Smtp-Source: APXvYqyqlKVeXu1nxJLjkO7IVhWMdJJJMzvpq/Tp2TvBPPgm3wZhg3dVF1V4+OxchuD4oIs0EQcI X-Received: by 2002:aca:ec15:: with SMTP id k21mr7371834oih.35.1581002906135; Thu, 06 Feb 2020 07:28:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581002906; cv=none; d=google.com; s=arc-20160816; b=OwrqTAyh96z0RrfFHFQWtxMmtmUm6uAwHRJuJA1FfFmPzrkpEJ2w2RulEtBoW3lSmv 4V7coGnaYhKtTPPmJ50M3lXKnRYLpYpH+31+XvaVCY/4JpEtlJ2djmoS+aRTQ3JudblC TetSKO4DLSPglPcdORAwZY6jnVdzPIfNEt2T+NpbSsE+ngceTxcfhKp60GnGk5Qbg0bC egSAEWbZxbaDEw9tvN2jX4jzGn5Z++0ltjuvft5jt4RYpjSFa2ZkqRYkXOEFRDMwLUnH stFLya8EDoMHOOHbEotRFJXWBbmkiD3Eq8sSe/jRVd6RdjtcjRlpFBsmzEQFPi4g8U71 PBWQ== 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=XZOggLanx1OakxhbvmLypkwLB6o7BwYbW0LP99Ryt1o=; b=KinYw0xLtkmeJg5vyu4eb336ddYWUn6tAWPmQrRUMdAWBEZ4+jNtt31gU9ND5VTxAM nM66R5TETqTJWNPv65+J3nfKyebzfmNn20DSdDgijMYpKDry0Wrylq8EwRACzIqs/vpO 4Ko2sia32HjHChDMHpVlSZEENuAR3dpPsNnm9KlLJ981+wBIcMPiYz+dD67/AsBwu22A wa0QLcylfnjfOSDi2pvpVkSu1Zgo3yZo7czDpcgF/I2hosP99TsxUXFAkGUlQZgxUyqZ RVTFTp7b/jZodqx256hzh32cQxhc+sybsq07svewl7wNU9uMRi+Kb9j9mTQhEjvnAhMq okaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b="yqZ/FZfL"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id l8si2162662oii.249.2020.02.06.07.28.12; Thu, 06 Feb 2020 07:28:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b="yqZ/FZfL"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727562AbgBFP1J (ORCPT + 99 others); Thu, 6 Feb 2020 10:27:09 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:42299 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727473AbgBFP1I (ORCPT ); Thu, 6 Feb 2020 10:27:08 -0500 Received: by mail-qk1-f194.google.com with SMTP id q15so5887758qke.9 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=CJe6iiFE0a3ekuCySJXGwWSs36KVfqFORpmn3Ro7y6zYbnzvvN9x7z9INfvCcW8sJL eeKXu+d0xVtkdydmiwpCxCzKeOaLhkzo6AkxM1flPJ6CzPo+FFj2CE1qI95zu8Q/Z6yF 4ivmn/fTTNighvhqtPYqNhHrs5LXoRt2D6rt9rbXxzW+rhhov2wqBJZAhsHiNYo2WWPa SmwDXy+Z2cNGrt84WwjdcPHZpPvYK89zMimoXu485e4/dFr0oMWiOVHheektoKoRmQIi L1qUzLIU2rqTavMVbC7LFcg0C4Yc2SPUA439kDatUXmpmuIvyEpf/HxDfOf4I/CPnONo +MQQ== X-Gm-Message-State: APjAAAXb/1vp7y+iCLwwbaz4pU5Fm4UUmkyiwRCOEwAzsL9mlpJOYZYi 3FcEojCmG64r9uk6stLHSn33O8+vutE= 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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