Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp971845ybv; Thu, 20 Feb 2020 10:36:14 -0800 (PST) X-Google-Smtp-Source: APXvYqzgub5jMweH6/2Wq15kviN2oo+vgafcohWL/Q7Nua+zZWFQKMUffOkub0bNA0uHk/slB0nL X-Received: by 2002:a9d:24c8:: with SMTP id z66mr25221508ota.52.1582223774432; Thu, 20 Feb 2020 10:36:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582223774; cv=none; d=google.com; s=arc-20160816; b=zOD9zL5qaL7K0cKooa0H8AzOZspABvT5NNIsBjd102TY5ivq9KHO89e0+wh14INFe1 rabAC3D8ZgF/H1JNjGg0MQU6pZqzDUBNZHEfVZ1lmz2JDnIL3jpcOb2HjsnY1Qv3EHLN Hy2OLrSe1z7UjsRduRVxgYvH97IqViMQSfANjPG5OhgeDAE3pMqosviDnXCDvL3TFs4U BxfMW5iVLWmK7MTuFemeoAlBB4U9sepiO+sQHJx1th0jOMNZy+7Po1z5vCein77Po97x ljjeF1C/yLBreSBCoFxerZGpGXoj2l+4obrQK/z9VsydwLw4BE9hKoCl5mlGo3zFj6hl jU8g== 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=Ui1GYJ+3TKdhDhER6hX80GC8ogMrESlUENKJdsvmiJw=; b=TUVk2fejmQ5QezVZey3DekjFz13JlLiNMT4bSYPwmN7yXOTI6Zvx3pyYfGFEQlZ97a DBSqRyxUGZWV7WPGHvsEWn+9Fgsk1fCwrWEhDUSIgBIkzeQszDEvic/7OKcdWmRnsYyG qWKXNSfZZ2qXoziVQyUCuhGJTOrzyneNlKEOp64piIB2lPmPggnBhOp6QA9/AyrOBl9R EAaXh4ZQin6AbllGB0OOp5ygQNYAlKAZ8u7DI4moTlX7iBHGobxFeM1b2u++nZDk57o+ Wc7KLJO63k4TO/f3lMBKuleHl4MJTWGw3d8s0cBHBZYI0hGeakBpIKR+zGNcmbdgJTtV wcfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=fmztncXT; 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=NONE sp=NONE dis=NONE) header.from=chrisdown.name Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 22si53338oin.34.2020.02.20.10.36.01; Thu, 20 Feb 2020 10:36:14 -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=@chrisdown.name header.s=google header.b=fmztncXT; 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=NONE sp=NONE dis=NONE) header.from=chrisdown.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728400AbgBTSf4 (ORCPT + 99 others); Thu, 20 Feb 2020 13:35:56 -0500 Received: from mail-qv1-f65.google.com ([209.85.219.65]:42843 "EHLO mail-qv1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728217AbgBTSfz (ORCPT ); Thu, 20 Feb 2020 13:35:55 -0500 Received: by mail-qv1-f65.google.com with SMTP id dc14so2345415qvb.9 for ; Thu, 20 Feb 2020 10:35:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Ui1GYJ+3TKdhDhER6hX80GC8ogMrESlUENKJdsvmiJw=; b=fmztncXTcGHJiFgzRFjgjLEip0FvqqT27efzmzqFHV75pB/K83qJ3D1hNW4E70dXeZ CJFi4rvcQHriQibThmglNljM7AMJM2WmKPyRjHJZtP1+ft4kHUBatB/TJEuTN6xxhTiN E6+kHjefonE2x7TQtlE6uRTgWbAoPRwp5TtqE= 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=Ui1GYJ+3TKdhDhER6hX80GC8ogMrESlUENKJdsvmiJw=; b=PVOk/1Z1JZyv2GKwqGwVWtOr5bbu29Xq2sMxZAPmzsNXau6dCd0O9NcB5M7pTYcdrD 3/yFdQaZk+0hhGqK3yEvLXnk4lbrRuhizJc0stV5eD3tVUZqeW/sFnCiw16rQfB7xVoE meqy09Vt3RQdpYyPQMnHoEuM4k1lfaxBm28qXhkPT3n4ODItDhcwE74feVOru11Ru0qG sBlQz3e5KhQ42axpV/SkjE7DLwkgAUJMtE5lQKuP37elDnsK4Cts/lAZFn6Cg33gdtKs esTsqZ1UOHsvMTeV357NUdfhkbD8N1SBX19Nxl26OmOvQ4STO1pefvKONs3fgX1HhedU oT6w== X-Gm-Message-State: APjAAAX8T/UQ6ZUunMf0fK6rXB1xFwrgXD76cPJh+x49+NtaE3+YciBs VdjE2/NqRyYYppToLoeuP0vCtQ== X-Received: by 2002:ad4:478b:: with SMTP id z11mr27009509qvy.185.1582223754273; Thu, 20 Feb 2020 10:35:54 -0800 (PST) Received: from localhost ([2620:10d:c091:500::2:a76b]) by smtp.gmail.com with ESMTPSA id g9sm226424qkl.11.2020.02.20.10.35.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2020 10:35:53 -0800 (PST) Date: Thu, 20 Feb 2020 13:35:52 -0500 From: Chris Down To: Dan Schatzberg Cc: Jens Axboe , Tejun Heo , Li Zefan , Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Hugh Dickins , Roman Gushchin , Shakeel Butt , Yang Shi , Thomas Gleixner , "open list:BLOCK LAYER" , open list , "open list:CONTROL GROUP (CGROUP)" , "open list:CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)" Subject: Re: [PATCH v3 2/3] mm: Charge active memcg when no mm is set Message-ID: <20200220183552.GA2181061@chrisdown.name> References: <0a27b6fcbd1f7af104d7f4cf0adc6a31e0e7dd19.1582216294.git.schatzberg.dan@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <0a27b6fcbd1f7af104d7f4cf0adc6a31e0e7dd19.1582216294.git.schatzberg.dan@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dan Schatzberg writes: >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 Acked-by: Chris Down Thanks! The clarification the v2 thread for this made things clear to me.