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=-5.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 13CFBC43468 for ; Mon, 21 Sep 2020 14:18:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8E16520BED for ; Mon, 21 Sep 2020 14:18:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UFS8ZxSv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8E16520BED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DE99E6B00CE; Mon, 21 Sep 2020 10:18:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D99D06B00CF; Mon, 21 Sep 2020 10:18:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C8ADB6B00D0; Mon, 21 Sep 2020 10:18:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0217.hostedemail.com [216.40.44.217]) by kanga.kvack.org (Postfix) with ESMTP id AF4006B00CE for ; Mon, 21 Sep 2020 10:18:37 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 6D51E180AD811 for ; Mon, 21 Sep 2020 14:18:37 +0000 (UTC) X-FDA: 77287274274.10.gate42_610dcc327145 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 4703816A4AB for ; Mon, 21 Sep 2020 14:18:37 +0000 (UTC) X-HE-Tag: gate42_610dcc327145 X-Filterd-Recvd-Size: 7134 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Mon, 21 Sep 2020 14:18:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600697916; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Kc3JtLhbC99DIB1MGA9gsNfzzfbDbT5HNfRaQ0VV0ag=; b=UFS8ZxSvrxsV8QphnvJTcq4qhgpOEKNaVqu4keCCTRbF28U8etOeNo5KAQLPEbYFO34efm pU6yIqZ/1QhygmO45xSv/2UKhMWeQ4kc74PUk54viE83zOJc5jo1o/+dDVMFr1xPy8dt65 SdYHZCxRiJt+90ezXBRoJiDYgoSBU2E= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-71-BdIl2oBIMEq5TM7t_vaa9A-1; Mon, 21 Sep 2020 10:18:34 -0400 X-MC-Unique: BdIl2oBIMEq5TM7t_vaa9A-1 Received: by mail-qk1-f197.google.com with SMTP id a136so8048645qkb.18 for ; Mon, 21 Sep 2020 07:18:34 -0700 (PDT) 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=Kc3JtLhbC99DIB1MGA9gsNfzzfbDbT5HNfRaQ0VV0ag=; b=GKCAmFI785VB7pFb/q2ciL5QUJGWj0P6yqgI9EEel4BCVw1wAfjol6uHz0fq48Qz2o Rr6qzrvebZVExYP6auubY1T9M8jH2p6GzNVfnFi5rrEpnVh2RbkVF/218s+XsapcquKF dW9eI2djr7VJqsJTbK5Ph0CYaOEybAkjgiLQGZXZUYYsnahEKKy9IdFo47eCk1Zaygkg xH3YJpt0gpfvwDEPKeWjROSVGjU7qHOOB+dOstuBGQ1EqAUCUpirNTeyBSUCy9VPQ99S p4JqJKezOWM1+/eSz9NuTGN2JBMbbtcSZ6lgHiUfBDOXsXZ875G8b/YMmipG3DmTBQ2l UjjA== X-Gm-Message-State: AOAM532CsGC0tbTPTbYkUVOfy7tIF6kOfji6NElUfYGgwC5iLjgqHJfp 23kkW5g3XXmDTZoPoheHlY2aao9aCVs4CLAFeDNARw7EL4MskU6yTuqni5jX+YrCsQYscYhjZqz yLIKIOF7YZUw= X-Received: by 2002:a0c:9142:: with SMTP id q60mr114204qvq.13.1600697913975; Mon, 21 Sep 2020 07:18:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6ccKm9BmtEHfecT9fiekz74G47EtfQogzuefL3Myj9gAvsauASmDwjZk7yiMlLcXPgS5ULg== X-Received: by 2002:a0c:9142:: with SMTP id q60mr114162qvq.13.1600697913640; Mon, 21 Sep 2020 07:18:33 -0700 (PDT) Received: from xz-x1 (bras-vprn-toroon474qw-lp130-11-70-53-122-15.dsl.bell.ca. [70.53.122.15]) by smtp.gmail.com with ESMTPSA id c11sm9620762qkb.58.2020.09.21.07.18.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 07:18:32 -0700 (PDT) Date: Mon, 21 Sep 2020 10:18:30 -0400 From: Peter Xu To: Michal Hocko Cc: Tejun Heo , Christian Brauner , Linus Torvalds , Jason Gunthorpe , John Hubbard , Leon Romanovsky , Linux-MM , Linux Kernel Mailing List , "Maya B . Gokhale" , Yang Shi , Marty Mcfadden , Kirill Shutemov , Oleg Nesterov , Jann Horn , Jan Kara , Kirill Tkhai , Andrea Arcangeli , Christoph Hellwig , Andrew Morton Subject: Re: [PATCH 1/4] mm: Trial do_wp_page() simplification Message-ID: <20200921141830.GE5962@xz-x1> References: <20200915232238.GO1221970@ziepe.ca> <20200916174804.GC8409@ziepe.ca> <20200916184619.GB40154@xz-x1> <20200917112538.GD8409@ziepe.ca> <20200917193824.GL8409@ziepe.ca> <20200918164032.GA5962@xz-x1> <20200921134200.GK12990@dhcp22.suse.cz> MIME-Version: 1.0 In-Reply-To: <20200921134200.GK12990@dhcp22.suse.cz> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline 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: Hi, Michal, On Mon, Sep 21, 2020 at 03:42:00PM +0200, Michal Hocko wrote: > [Cc Tejun and Christian - this is a part of a larger discussion which is > not directly related to this particular question so let me trim the > original email to the bare minimum.] > > On Fri 18-09-20 12:40:32, Peter Xu wrote: > [...] > > One issue is when we charge for cgroup we probably can't do that onto the new > > mm/task, since copy_namespaces() is called after copy_mm(). I don't know > > enough about cgroup, I thought the child will inherit the parent's, but I'm not > > sure. Or, can we change that order of copy_namespaces() && copy_mm()? I don't > > see a problem so far but I'd like to ask first.. > > I suspect you are referring to CLONE_INTO_CGROUP, right? Thanks for raising this question up to a broader audience. I was not referring to that explicilty, but it would definitely be good to know this new feature before I post the (probably stupid :) patch. Because I noticed it's only done until cgroup_can_fork() or later, so it's definitely also later than copy_mm() even if I do the move. > I have only now > learned about this feature so I am not deeply familiar with all the > details and I might be easily wrong. Normally all the cgroup aware > resources are accounted to the parent's cgroup. For memcg that includes > all the page tables, early CoW and other allocations with __GFP_ACCOUNT. > IIUC CLONE_INTO_CGROUP properly then this hasn't changed as the child is > associated to its new cgroup (and memcg) only in cgroup_post_fork. If > that is correct then we might have quite a lot of resources bound to > child's lifetime but accounted to the parent's memcg which can lead to > all sorts of interesting problems (e.g. unreclaimable memory - even by > the oom killer). Right that's one of the things that I'm confused too, on that if we always account to the parent, then when the child quits whether we uncharge them or not, and how.. Not sure whether the accounting of the parent could steadily grow as it continues the fork()s. So is it by design that we account all these to the parents? > > Christian, Tejun is this the expected semantic or I am just misreading > the code? I'll try to summarize the question here too - what we'd like to do right now is to do cgroup accounting (e.g., mem_cgroup_charge()) upon the newly created process within copy_mm(). A quick summary of why we want to do this is to "trigger early copy-on-write for pinned pages during fork()". Initially I thought moving copy_mm() to be after copy_namespaces() would be the right thing to do, but now I highly doubt it.. Thanks, -- Peter Xu