Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1103748ybv; Thu, 20 Feb 2020 13:17:01 -0800 (PST) X-Google-Smtp-Source: APXvYqx5lbusaMhJLwVhlcabJ/KNeu2HLuOfhVSPHGgEKZ3mfYFhJPNUpC3w3bQCyBQkfz/mj19p X-Received: by 2002:a9d:24c8:: with SMTP id z66mr25730564ota.52.1582233421160; Thu, 20 Feb 2020 13:17:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582233421; cv=none; d=google.com; s=arc-20160816; b=ZtQx0gTib0dQuBYNRFcK61Zot9cS4sOAYs8ngikRHLhy98aw1Jz1sRfnzJhyLQ+zFt O3/xjx+EPL5AEIsRRJPyG6saeTSYlGyd9xiIf1C8wN728usmnxGng7X1Agba1NJ7nohl +KFotN13GMxuoY9YiHhswx9KJFFRPLNnOlBR0GqYE7/ZiH0XnPs8WKm3PMrV7y8ZkS6k h7i3bMh5NRhR7OBi3VvIjNO61Zn89HSKTQA1fqx7+tvkJ7wcuBEdRJsei/Vfgf7m+kVj +XSMdvyBqr+qqRp15pndwu4cx/eh0Sk8kQMS0kjQ09m/xkcRgMVQX4NXlHcB2KyFqBtG FEAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=VtH6MBxxbzar9OipIWWKPkk5V8ZZykX/4RLjsMCgSw0=; b=N4G6jmo2b5FTysJtEh0dFWJ90ip0LEyvcGjFCGeoZiW9d6Wrx07dterfDjChVOWKp7 tFZFl3+dZI1zVrS0N5igQKgxZJBAzn5BlgQ1b9BlaKSc34++pUIubydyYfrO0t7Mifsj fQKaw9LnWLBLicMJWlR4NTtGOGMYYtfMeKOvvcEYik2yy0hEOwT9H26tV0wvkDiYWevE ea6PyXo+N2vYT07/2zAZewURaiBdR6Ao2i5fFCK4qmjI4JLkxVzYkpITCFlJ0mv7b6nK Cn4P1QgCy53ABIQzZntBHgXWQyoQgwiR+Dnd9i8ID7lvubPeQ1CIEQ1VpDFKawMGqjrw vm8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=itJvvjLT; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c130si253539oib.182.2020.02.20.13.16.48; Thu, 20 Feb 2020 13:17:01 -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=@google.com header.s=20161025 header.b=itJvvjLT; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729163AbgBTVPS (ORCPT + 99 others); Thu, 20 Feb 2020 16:15:18 -0500 Received: from mail-vk1-f196.google.com ([209.85.221.196]:46670 "EHLO mail-vk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727801AbgBTVPR (ORCPT ); Thu, 20 Feb 2020 16:15:17 -0500 Received: by mail-vk1-f196.google.com with SMTP id u6so1607474vkn.13 for ; Thu, 20 Feb 2020 13:15:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VtH6MBxxbzar9OipIWWKPkk5V8ZZykX/4RLjsMCgSw0=; b=itJvvjLTjnAztaW3ELzLWWOItRSpx0VEbznSWQRD2w5LWICCqXBPNEHhDU5rFKFP6Q vuyEYtotOdCIFIz1XJec20kXLy25/JiQ6uw+0bgl/zEfBCQyL6qIxrsqZdnFBw+0pOa6 dhuSeGnzbUKkl20/CUxAFyxo57oxShrr081lqlT55iOBkdQo+UkLgySNpVO0kGfAe3h5 PMbTsKhsLUG0Oh3M0J9t4j+UdalOyoi/arcDlydpv0KIHUjajmBRd+IRjc3Ds7lsHaBK OQOIgksxwxaYbkPodvrysTB+g9laG5Peu7Mo06tw+vP91Kj31rabF/tyoXRamNVQmH2F 8CTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VtH6MBxxbzar9OipIWWKPkk5V8ZZykX/4RLjsMCgSw0=; b=nAgWe2kYt4gYe5i0KPr/5xFvAJ8Z2M3Q9mTvAi/q6Ql/xJ5gJCa95x6dJVMhLIOEU8 MYFas92GWO8HzZTEheMWGvyx9tDvr51P9M7YOnyD8fLoaSM4n9VFlpGy129HQ5OFqSYd XP0ZW6EukiRv12mJt46EEHFQFg2nXm7EWi9p1+Z24vP82wrqcp3S8hl5XPUFyQLRS+Nz ELnUHYYbcdq6hzUzNtyhYdIMKvcBjgHNbHZz7iBnYlockopjvwufe2yQOjhYZ79AJDih WLVJPk+qiTP0RdUQSWu8kK/mfmVUE01QwGW1UJKPrtCtwcFrklvzlYZNFeUS0wfXXELc WQUw== X-Gm-Message-State: APjAAAVqumhjrIYi/HpmTzeVNx9YkUukgmAYZ1d87ACQ6lcwrtQQ0Hfh 2plxe6EdygOkI9yMPSBXyCIt95E6FJwyemFOAEbhdQ== X-Received: by 2002:a1f:ee45:: with SMTP id m66mr15468181vkh.75.1582233316395; Thu, 20 Feb 2020 13:15:16 -0800 (PST) MIME-Version: 1.0 References: <0a27b6fcbd1f7af104d7f4cf0adc6a31e0e7dd19.1582216294.git.schatzberg.dan@gmail.com> In-Reply-To: <0a27b6fcbd1f7af104d7f4cf0adc6a31e0e7dd19.1582216294.git.schatzberg.dan@gmail.com> From: Shakeel Butt Date: Thu, 20 Feb 2020 13:15:05 -0800 Message-ID: Subject: Re: [PATCH v3 2/3] mm: Charge active memcg when no mm is set To: Dan Schatzberg Cc: Jens Axboe , Tejun Heo , Li Zefan , Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Hugh Dickins , Roman Gushchin , Chris Down , Yang Shi , Thomas Gleixner , "open list:BLOCK LAYER" , open list , "open list:CONTROL GROUP (CGROUP)" , "open list:CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 20, 2020 at 8:52 AM Dan Schatzberg wrote: > > 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. > > Previously, if a NULL mm was passed to mem_cgroup_try_charge (case 3) it > would always charge the root cgroup. Now it looks up the current > active_memcg first (falling back to charging the root cgroup if not > set). > > Signed-off-by: Dan Schatzberg > Acked-by: Johannes Weiner > Acked-by: Tejun Heo Reviewed-by: Shakeel Butt