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=-6.8 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 49641C43463 for ; Fri, 18 Sep 2020 19:57:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9137E22208 for ; Fri, 18 Sep 2020 19:57:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i/Tn5CQ1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9137E22208 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 E4F88900003; Fri, 18 Sep 2020 15:57:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E01418E0001; Fri, 18 Sep 2020 15:57:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D158E900003; Fri, 18 Sep 2020 15:57:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0221.hostedemail.com [216.40.44.221]) by kanga.kvack.org (Postfix) with ESMTP id BABEA8E0001 for ; Fri, 18 Sep 2020 15:57:46 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 80723362D for ; Fri, 18 Sep 2020 19:57:46 +0000 (UTC) X-FDA: 77277242532.06.toad62_170076d2712d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 5BECE100FB24F for ; Fri, 18 Sep 2020 19:57:46 +0000 (UTC) X-HE-Tag: toad62_170076d2712d X-Filterd-Recvd-Size: 6942 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Fri, 18 Sep 2020 19:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600459065; 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=/g7ZSNROlpJMrEUtWDRpRe5vjuvZ4Kcl9hqq8QxtxyA=; b=i/Tn5CQ16xbxaiYs6VntWtxbL9yMvfNa3w2rFt+/F841302X3X5d82iW2jOtkcr0rBEb3C SDDaKcc5mSIHykUyiKHcii7lUxi+YIZUm2s6t7qZ3cAM5c7UiYwPvgFPmBt0+1czHCSZqI 4pb6ihp6xNmQPmylEE/FJticu8LeK8Y= 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-55-n3o2wuzIOLO8VyAigcj9dA-1; Fri, 18 Sep 2020 15:57:43 -0400 X-MC-Unique: n3o2wuzIOLO8VyAigcj9dA-1 Received: by mail-qk1-f197.google.com with SMTP id o28so5490360qkm.23 for ; Fri, 18 Sep 2020 12:57:43 -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=/g7ZSNROlpJMrEUtWDRpRe5vjuvZ4Kcl9hqq8QxtxyA=; b=LQ0og5HcbJHVvDOK8iJGjIcO374gUQo2uaQeJcqwsLQo+6/9kLS3M4MY90jPls/3Fo aHHq2JF8I2IlMo1nNy+2OyLO5lTMd25Bxm9yS+NeUk+9Oz1jbifebW6B9GfYPwZBEFtC FrPaTZ4AAAjianXwlfb+CpLCCEugu65+1SRTVm89h2M8IsQRM69y7RblQ7K8KTacN3J8 D5cCC0CAxJFEK54NnNBBTdyYuw4/X9ioI8zlFbklvUhpRIqqkqJQr9fAMcO5Y+OOYJbA bq55AVqjV4rAggVujlw2I+jQLhlbPZtH7DylDBsa3P1523Sge5xq+Rf2hxtxCdb9ujGC C8oA== X-Gm-Message-State: AOAM531U3heX3ipBSCCXKU2k/1OX+hGDVbcxfyj6fVch8ujnHSmZUbX4 O6PDzKm4mybUMAVMYJKbdhgb44hdIxKqrvoVNLCLWfnMY41NSs5n4Rr3TBDOh65w3Xepa5Iyc01 f5Zu4DA+jbvA= X-Received: by 2002:a37:aca:: with SMTP id 193mr35797832qkk.149.1600459062902; Fri, 18 Sep 2020 12:57:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrSCIo7RHMYY3CDjs/ANl3bd11aNIAfLAaxeB9KNGSSGUQAU8xnC5IuWMh44vt17aA9xbXdg== X-Received: by 2002:a37:aca:: with SMTP id 193mr35797817qkk.149.1600459062592; Fri, 18 Sep 2020 12:57:42 -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 n7sm2919885qtf.27.2020.09.18.12.57.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2020 12:57:41 -0700 (PDT) Date: Fri, 18 Sep 2020 15:57:40 -0400 From: Peter Xu To: Linus Torvalds Cc: 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: <20200918195740.GB5962@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> MIME-Version: 1.0 In-Reply-To: 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: On Fri, Sep 18, 2020 at 10:16:19AM -0700, Linus Torvalds wrote: > The only change I'd make is to make it a "int" and put it next to the > "int map_count", since that will pack better on 64-bit (assuming you > don't do the randomize_layout thing, in which case it's all moot). Will do. [...] > > 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(). > > That cannot possibly matter as far as I can see. > > Copying the page in between those two calls is already possible since > we've already dropped the mmap_lock by the time copy_namespaces() is > called. So if the parent was threaded, and another thread did a write > access, the parent would have caused that COW that we did early. > > And any page copying cost should be to the parent anyway, since that > is who did the pinning that caused the copy in the first place. > > So for both of those reasons - the COW can already happen between > copy_mm() and copy_namespaces(), *and* charging it to the parent > namespace is proper anyway - I think your cgroup worry is not > relevant. > > I'm not even sure anything relevant to accounting is created, but my > point is that even if it is, I don't see how it could be an issue. The parent process should be fine to do any COW and do its accounting right, which I agree. But the new COW that we're adding here is for the child process rather than the parent. I'm just afraid the parent process's accounting number could go very high after it pinned some pages and fork()ed a few more times, since those extra accountings will accumulate even after the children die, if I'm not wrong... Actually I tend to move copy_namespaces() to be before copy_mm() now.. I know nothing about namespaces, however I see that copy_namespaces() seems to be quite self-contained. But I'm always ready for a "no, you can't"... > > > The other thing is on how to fail. E.g., when COW failed due to either > > charging of cgroup or ENOMEM, ideally we should fail fork() too. Though that > > might need more changes - current patch silently kept the shared page for > > simplicity. > > We already can fail forkind due to memory allocations failing. Again, > not an issue. It happens. Yes. I didn't change this only because I thought it could save quite a few lines of codes. However after I notice the fact that this patch will probably grow bigger no matter what, I'm kind of not worrying on this any more.. -- Peter Xu