From mboxrd@z Thu Jan 1 00:00:00 1970 From: Johannes Weiner Subject: Re: [PATCH v2 2/3] mm: Charge active memcg when no mm is set Date: Wed, 19 Feb 2020 14:37:11 -0500 Message-ID: <20200219193711.GC54486@cmpxchg.org> References: <8e41630b9d1c5d00f92a00f998285fa6003af5eb.1581088326.git.dschatzberg@fb.com> <20200207211807.GA138184@chrisdown.name> Mime-Version: 1.0 Return-path: 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== Content-Disposition: inline In-Reply-To: <20200207211807.GA138184-6Bi1550iOqEnzZ6mRAm98g@public.gmane.org> Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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)" 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.