Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp423956pxj; Thu, 3 Jun 2021 09:57:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmV9KAnkb2rbwQTtobdKyx/rlahzbRCfYRs3Qyr1ISnKSv+Gb000qJUqVTSpKmMB4D9qk6 X-Received: by 2002:a17:906:ca54:: with SMTP id jx20mr302768ejb.380.1622739427244; Thu, 03 Jun 2021 09:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622739427; cv=none; d=google.com; s=arc-20160816; b=wQgTQAu0kj7FByArTdXE8np26XyCle9plZwuEWmTG/KAkIAx8prEp0AjbPaHl3ANZp ZfkqNG9ILTtkAnVobWyNXAXM7a2++E59jUH94XDU3lH7ebHNYiYqDMnMSFo54fbq8peE kSo7PBwBsO7VDPVHMjvg4bOQKTQ7PiBiF25u5587RfMO3gkwGamPJB89wPGRo9w0EYzo yZGDo3BNNu8IBXrSR4HtKq9Yu82LGjU9MJz36455HIMVZ28EfU6FgK6dcKQqOr8etVrq Wbl9rhQB69S2awP56xlvI5GEOaXf4z79fWOqtT69WcajY4bor85mF/U0WbUK6sDnHXeB kruw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=t0rBINIjyYVjiWlKA6CZdf8Cu1m85/b95NW0HipMWEw=; b=c+/EgaRYIRIrDXyrPim7vWRZbSSnuLpbA9sPeDfdTxFFhah/qdRfCLNH1jpGWnfbj8 JLDWS/DyTAvkXdgh9zQkwXh+76uDYVKKs5VAiTfN0Or+SdZ6xLXa435YyydAN3cfycFf hjWemMch8PW5MI1nvjgTlH44XYAMPEaXKxoaOLD7rrghAUM50lVJ/Pje23cSChfyk3sw CUHsvbP8VgMl+uNIYbg8Em/1Z+k/w8D+sZp3z+rZ+xqWWe2VKil8THIbjumD7efpBGkg rVjbUvQtOKmc3XynRucGxVbK60UKG3YCoeY+jz6qvl4VkEsQQcj8ZGr4xyZzPWANAYmA mUHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RT6DDw3h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id k26si2700877eds.205.2021.06.03.09.56.43; Thu, 03 Jun 2021 09:57:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RT6DDw3h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S230018AbhFCQzb (ORCPT + 99 others); Thu, 3 Jun 2021 12:55:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbhFCQzb (ORCPT ); Thu, 3 Jun 2021 12:55:31 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F10CBC06174A for ; Thu, 3 Jun 2021 09:53:29 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id f12so8019043ljp.2 for ; Thu, 03 Jun 2021 09:53:29 -0700 (PDT) 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=t0rBINIjyYVjiWlKA6CZdf8Cu1m85/b95NW0HipMWEw=; b=RT6DDw3hX0Vd0D9y8P1+wlBANWRsJKcOTL5XNuqjuoqdcO+eVWb3h5lPuPBdWbpXRP qS7RpEK9U4hewHkB9ReHFH0CpGE6xxnLud53HxAhqun48esVrJ2Tsyp+XW2wrFLkrwHK lH/KFiL4LHRVHxBi+EJaxQ1OcbONA/XKS1BDaSuddZH/u57dzNoDmqyVp/ACKK8Zo9xA GYN86bl7bcGB1HAkjN9u3Li/fE5sVQbAL/zx25EkFYVTSn2KJIenbUvhjj/7OSdYsqOj aF8pnMaxmokmARnSb/3P9IcKdc1ySVi+6IVr0FK6l431NPIU5pv9T8uTmzgRjZmKVxX7 SuIg== 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=t0rBINIjyYVjiWlKA6CZdf8Cu1m85/b95NW0HipMWEw=; b=hO0tmClOSx0ZQf8DXxFaChcx0OrHgQHHgkRPcCmoEt1prZVND9R34+gpuR7XZIKAmz Zue2VzQZSrOVUQnG+NcAFV8D47HpqRRE6X33boqg1E7yIRoBRfhGsqXX+BdH2pyTaA7i 9ER1JYzg4fL16wL8+KUIjikgNQeIAGsF1k3qZ0M3q9f0yuivgr5CV5w1D0+3KxTicqXT yvrB1jac5GRAQmeTrBKpGLIVFei0ZJ9ObYvFmP+qdaDfV/wQzUT5/0dTl2fyoRNpIiQs I9aqsH/WDoPiEYakOmlm0trRDCua6DTZvsGmeOBW2gGyxY/MX3bsPmuiMPEhsoO3Mx+X DsHA== X-Gm-Message-State: AOAM532zjM4gbtt/QmF5ZFE7H01I35rML4PRdajjg/CGRuHojpkcTyO3 AOBN+n5eAz3dFLUOJU2awd1J4xu/umwMq6UlgqFJHg== X-Received: by 2002:a05:651c:210f:: with SMTP id a15mr235460ljq.160.1622739208042; Thu, 03 Jun 2021 09:53:28 -0700 (PDT) MIME-Version: 1.0 References: <20210603145707.4031641-1-schatzberg.dan@gmail.com> <20210603145707.4031641-3-schatzberg.dan@gmail.com> In-Reply-To: <20210603145707.4031641-3-schatzberg.dan@gmail.com> From: Shakeel Butt Date: Thu, 3 Jun 2021 09:53:16 -0700 Message-ID: Subject: Re: [PATCH 2/3] mm: Charge active memcg when no mm is set To: Dan Schatzberg , Muchun Song Cc: Jens Axboe , "open list:BLOCK LAYER" , open list , "open list:CONTROL GROUP (CGROUP)" , "open list:MEMORY MANAGEMENT" , Johannes Weiner , Tejun Heo , Chris Down Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 3, 2021 at 7:57 AM Dan Schatzberg wrote: > > set_active_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 there is an > active_memcg, use that. Otherwise, current->mm->memcg. > > Previously, if a NULL mm was passed to mem_cgroup_charge (case 3) it > would always charge the root cgroup. Now it looks up the 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 > Acked-by: Jens Axboe > Reviewed-by: Shakeel Butt Can you please rebase over the latest mm tree? Specifically over Muchun's patch "mm: memcontrol: bail out early when !mm in get_mem_cgroup_from_mm".