From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A1B0C38BFA for ; Mon, 24 Feb 2020 21:37:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EC41A21556 for ; Mon, 24 Feb 2020 21:37:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="G/dqJBKU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC41A21556 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8E4AF6B006C; Mon, 24 Feb 2020 16:37:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8BCBE6B0072; Mon, 24 Feb 2020 16:37:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 784416B0073; Mon, 24 Feb 2020 16:37:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0119.hostedemail.com [216.40.44.119]) by kanga.kvack.org (Postfix) with ESMTP id 5D5956B006C for ; Mon, 24 Feb 2020 16:37:54 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 217C140D6 for ; Mon, 24 Feb 2020 21:37:54 +0000 (UTC) X-FDA: 76526333268.12.pen06_27d8148a7df07 X-HE-Tag: pen06_27d8148a7df07 X-Filterd-Recvd-Size: 5843 Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Mon, 24 Feb 2020 21:37:53 +0000 (UTC) Received: by mail-qt1-f193.google.com with SMTP id p34so7614726qtb.6 for ; Mon, 24 Feb 2020 13:37:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=/oLy8oVuts+NDR86rWT12f1DfuTi/T+KFkIcevjcIVk=; b=G/dqJBKUaChhHiklV5Lw+49KVuJF9AbPOpkfS+2n6Qk8wkhPUVDGGMJD5uvSfRAwOx xzJfG8b8FMlMdMb4KndOLEFwTqa8kpbf1gnvD3wJ7DmQ3+a0myrZMyoZ7gQm/CiO1t8Y AQ2niiTydeDa2Tm4yZZQAzuwao4ut8S7wQoFQU7h30tlwtv05ivIKuBQl9CAbTmUQykG vhhobIrRrVhM0SrntztkE7e08WvFc+q24oNp6mNiqulz617fl7f3YoSmNWXPrsOexSXk /3UsPWtixv84JHg6mkf5BwIRJHok/gkKO/3aAOD4Hc4Tpta4BGbVr3rVA37at/r8be18 XmfA== 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=/oLy8oVuts+NDR86rWT12f1DfuTi/T+KFkIcevjcIVk=; b=Xl7D5vBf+zp78jxmUXtH1M+idJS0Og1ReOR7oFdBD5t/kaZMJ6xfCJJx16l4ksj6CZ 8Ivw4oOCqLu6RJ8tXgenFgpxwOzvlMDilI8MdcyBeDbyp60XmNMzWbos1Dewehq80X7r T7iSDngJq0v/e2BzRUqNoPLe4agCc6VytJI4RouR0wwXiQhBMqsStQ8vS99C8e5ldIpn J0yMzhHnddnaod+V/LUVKT7ZKPBoPSgV9/lS88gekuvAdhXUs8uk6Jdu9u/24Ig4jTT9 ot/ZJH+d5yXdrV4mA94nWmsANlVTsN8th+laEoBX6Ix2itoIAAvNy1Y2en7dgaWIOemi hKfw== X-Gm-Message-State: APjAAAW8pUjBh24fXcDDN75SKVugTwg/N0ky4IxGdyEChG8pe5DHWHyL LqWG1Rzp3r0YhB1Y7vbcsQ4= X-Google-Smtp-Source: APXvYqw6QDKZMmbPqHOGHQZTwBxnfivEGgL5joDo4YpHdeSL71y1/54B9Y6S4a4M109nogftkRXbJg== X-Received: by 2002:ac8:5419:: with SMTP id b25mr51215597qtq.390.1582580273055; Mon, 24 Feb 2020 13:37:53 -0800 (PST) Received: from dschatzberg-fedora-PC0Y6AEN.dhcp.thefacebook.com ([2620:10d:c091:500::2:b19b]) by smtp.gmail.com with ESMTPSA id c10sm6404718qkb.4.2020.02.24.13.37.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2020 13:37:52 -0800 (PST) Date: Mon, 24 Feb 2020 16:37:50 -0500 From: Dan Schatzberg To: Hugh Dickins Cc: Jens Axboe , Tejun Heo , Li Zefan , Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Roman Gushchin , Shakeel Butt , 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)" Subject: Re: [PATCH v3 2/3] mm: Charge active memcg when no mm is set Message-ID: <20200224213750.GA3773@dschatzberg-fedora-PC0Y6AEN.dhcp.thefacebook.com> References: <0a27b6fcbd1f7af104d7f4cf0adc6a31e0e7dd19.1582216294.git.schatzberg.dan@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sun, Feb 23, 2020 at 05:11:12PM -0800, Hugh Dickins wrote: > On Sun, 23 Feb 2020, Hugh Dickins wrote: > > On Thu, 20 Feb 2020, 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 > > > > Acked-by: Hugh Dickins > > > > Yes, internally we have some further not-yet-upstreamed complications > > here (mainly, the "memcg=" mount option for all charges on a tmpfs to > > be charged to that memcg); but what you're doing here does not obstruct > > adding that later, they fit in well with the hierarchy that you (and > > Johannes) mapped out above, and it's really an improvement for shmem > > not to be referring to current there - thanks. > > I acked slightly too soon. There are two other uses of "try_charge" in > mm/shmem.c: we can be confident that the userfaultfd one knows what mm > it's dealing with, but the shmem_swapin_page() instance has a similar > use of current->mm, that you also want to adjust to NULL, don't you? > > Hugh Yes, you're right. I'll change shmem_swapin_page as well