Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp904911ybv; Wed, 19 Feb 2020 11:37:39 -0800 (PST) X-Google-Smtp-Source: APXvYqzV2zHG47bDOr0cZaKlVV+0d38vT0BEkVeoIuJR7I8ZJDsp4S1s2B31NHwOvJtez+sOPzMM X-Received: by 2002:a05:6830:10d7:: with SMTP id z23mr20732228oto.114.1582141059050; Wed, 19 Feb 2020 11:37:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582141059; cv=none; d=google.com; s=arc-20160816; b=NM/B9R5Afpu4te7JrMzcdzmU3kA5gOQKkrrb1CUvlVtrgcUEN9YHBAYLa6xOAco5yj 6L4bPge4LzYOXeUNaRyw4ymko1HVTsPyPx8mdrRQI/PdvtCUKfEfp85fz8ljfd3UcRiw KmdYsvKVpi7Z+Qxq7qy1j4rQtwERnrUwMHyGels/5DWKR0TUic2qeswUo0BbT5jKZwdL Bx3n+pKF9JhzCEOmKj6lcQReXEZJb3/zEo1Wl5Agq1Ice7zZIciSEWW6NPNpxp6SmO88 fACTWiDeIsanrW/+eNSJ9XbVbxkCewCt10+ndg2qdYG9uXqdMkc4fsyvfOp4BLPXK2/F +H/w== 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=DFD/PBmG0P7U1KLcfwxQ00ort/KIczMCNrbTAdH0j9g=; b=kanXk7sx5ZgmJ6mPwnl3d0SuAxI/IIE0KeWVkHuLBU9LOf+jbHhVctTLRiVp7WMRI3 hFp0zFtvrDbDZkwvUWneMEqt8/KDpFoyMDBX/Aw4qe5YaD1xiLJjp0Vy/PRJFRF4eida gYodk0vWGkQpNHe84jn+Pe9Sw6T1AE5lzrI7QfhpCjJOj9gsge4jp+J0PmH2dsC9uvRk IGa3FsxAH6uSMmXUqyrtzJGH2rNS3P4QqN3Gql1KolgIPjBqmBkHL62SChOHDRPRhqhQ 8zTlcr8OWe9YPpyWjURRhMJaq3xSSkZJDDYk104midApNeeyZczszIDru6phN/CbL3my xHUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b="yaW/aMLv"; 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 i6si433316otj.24.2020.02.19.11.37.26; Wed, 19 Feb 2020 11:37:39 -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="yaW/aMLv"; 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 S1726811AbgBSThR (ORCPT + 99 others); Wed, 19 Feb 2020 14:37:17 -0500 Received: from mail-qv1-f66.google.com ([209.85.219.66]:45780 "EHLO mail-qv1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726750AbgBSThQ (ORCPT ); Wed, 19 Feb 2020 14:37:16 -0500 Received: by mail-qv1-f66.google.com with SMTP id l14so727856qvu.12 for ; Wed, 19 Feb 2020 11:37:13 -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=DFD/PBmG0P7U1KLcfwxQ00ort/KIczMCNrbTAdH0j9g=; b=yaW/aMLvoyD72gqf9JCZfvj8P+9plgT82zxsbaIugjOxyXEvghFgPPkSW1TqZoFdOz 4tr15KFItwTQfQhiWTeY+8Srat3gbX/RQ6Hgm8rIjfZHfqUEOtVpm0Q0y6F6cxJPlxus aT1ZO43r5M7YLtCgzwbt1D8ZnTuATju1/2pg5HZAfLmHpY1Yh/Z7A5oBPM+qsrjhzFYg 06X+pEaoT5XF8PuErVI1qHsDU1VgFW1ysvMlUiI/+N+tGsYUStvrmG0W7bnou7gueZLc ihBEHv0EAdrzu6j9rSD6n8XlF0kXuGg2ShChO3x4tSekiZ9F5qExxRVGGzQojLOTDfO1 jLJQ== 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=DFD/PBmG0P7U1KLcfwxQ00ort/KIczMCNrbTAdH0j9g=; b=K5U2l8QUGAF/aeR28vjcODg+yXTmqYQa1/nEMJ8h1eT3ZbBWqZnA6cmrc4a31Fh6by 3sWiZ0nudtx2igVfF4UdBfBQaBt8snXZ3nbqMo0w8WFYIyUcuRYycH7VZBbJtO+hXlsA ZCKE2goLXQAPVdlBa9gF761M5ZYqOKX0X9S5W3H7fzGW0HR8SXqjPMlCZWqfa/x3LEvm 8ESs+GB9XRDgs3onwR+GiR+FnQW1GuNiHMjMWfokd8WlH+lnTVtemMaNK7Z8r7vNaSrV 2NlHM6MIebgGgI6lsuflFYUqyylG0dGmfeF47fXkARWM2S11PrX00ZKxEI0hv716BxQ1 N18Q== X-Gm-Message-State: APjAAAW5s435Xa4OnCTuYSeRti88M18wGmOcg3YcX99yY2MSXyYwUb8Y Uf3rcqcj29LN2c707bhkoaaGWg== X-Received: by 2002:a05:6214:50f:: with SMTP id v15mr22688159qvw.42.1582141032641; Wed, 19 Feb 2020 11:37:12 -0800 (PST) Received: from localhost ([2620:10d:c091:500::2:3bde]) by smtp.gmail.com with ESMTPSA id p2sm344987qkg.102.2020.02.19.11.37.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 11:37:12 -0800 (PST) Date: Wed, 19 Feb 2020 14:37:11 -0500 From: Johannes Weiner To: Chris Down Cc: Dan Schatzberg , Jens Axboe , Tejun Heo , Li Zefan , Michal Hocko , Vladimir Davydov , Hugh Dickins , Andrew Morton , Roman Gushchin , Shakeel Butt , Thomas Gleixner , "open list:BLOCK LAYER" , open list , "open list:CONTROL GROUP (CGROUP)" , "open list:CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)" Subject: Re: [PATCH v2 2/3] mm: Charge active memcg when no mm is set Message-ID: <20200219193711.GC54486@cmpxchg.org> References: <8e41630b9d1c5d00f92a00f998285fa6003af5eb.1581088326.git.dschatzberg@fb.com> <20200207211807.GA138184@chrisdown.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200207211807.GA138184@chrisdown.name> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 07, 2020 at 09:18:07PM +0000, Chris Down wrote: > > @@ -6856,8 +6857,12 @@ int mem_cgroup_try_charge(struct page *page, struct mm_struct *mm, > > } > > } > > > > - if (!memcg) > > - memcg = get_mem_cgroup_from_mm(mm); > > + if (!memcg) { > > + if (!mm) > > + memcg = get_mem_cgroup_from_current(); > > + else > > + memcg = get_mem_cgroup_from_mm(mm); > > + } > > Just to do due diligence, did we double check whether this results in any > unintentional shift in accounting for those passing in both mm and memcg as > NULL with no current->active_memcg set, since previously we never even tried > to consult current->mm and always used root_mem_cgroup in > get_mem_cgroup_from_mm? Excellent question on a subtle issue. But nobody actually passes NULL. They either pass current->mm (or a destination mm) in syscalls, or vma->vm_mm in page faults. The only times we end up with NULL is when kernel threads do something and have !current->mm. We redirect those to root_mem_cgroup. So this patch doesn't change those semantics.