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 C2F06C4727E for ; Wed, 23 Sep 2020 01:03:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2D08122262 for ; Wed, 23 Sep 2020 01:03:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YrjdyiEu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D08122262 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 639406B005A; Tue, 22 Sep 2020 21:03:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5EAD46B0062; Tue, 22 Sep 2020 21:03:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D90A6B0068; Tue, 22 Sep 2020 21:03:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0084.hostedemail.com [216.40.44.84]) by kanga.kvack.org (Postfix) with ESMTP id 379566B005A for ; Tue, 22 Sep 2020 21:03:41 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E228A8249980 for ; Wed, 23 Sep 2020 01:03:40 +0000 (UTC) X-FDA: 77292528600.03.game91_340bec127152 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id BB7B328A4EA for ; Wed, 23 Sep 2020 01:03:40 +0000 (UTC) X-HE-Tag: game91_340bec127152 X-Filterd-Recvd-Size: 5350 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Wed, 23 Sep 2020 01:03:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600823019; 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=tYTDkmTafNbJNdPtFz5RF6SE07Ft93O9frOXJeIZMpM=; b=YrjdyiEu+lj+bzZOE5AiWrxmuc2vg0oj5m+c9ZCKxYo01yrctyCKEJATIlcqQMX/m3ftkJ stt5f841egL+LmDQ2ISdCZB5AF1RTadxXvOR/G/hl1IAXd39Kx07nXUPVQoY0P2qYVvAgn z+p1A82RzV7L9IaPt6rEEK1DDEOwGAY= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-51-yY7JfbZpO3enpwHLoAs7Iw-1; Tue, 22 Sep 2020 21:03:36 -0400 X-MC-Unique: yY7JfbZpO3enpwHLoAs7Iw-1 Received: by mail-qk1-f200.google.com with SMTP id x191so15440720qkb.3 for ; Tue, 22 Sep 2020 18:03:35 -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=tYTDkmTafNbJNdPtFz5RF6SE07Ft93O9frOXJeIZMpM=; b=HUj71FTRmsxrloBkGtWs3+HtyhW6TLanzyvzuad4W0BFw/vU0HPsjADib23yTtKErY BvaaT2zRqtsQ5ruiecDyaUdOVqqaaZy+vFUF5E9/EX/qPYOfHdF+TMPpgaMvchChLC9v 3aNla/bQOV0i40QFAc1cEu+QBfB56kxuNNTnQXdvKpBWjbnYlH5I0HZSdJwwV0x+I757 +jxNv0j6ib9lmASZ7Pmg1eqRsTryKC0VSDk8U85n6gnra5li7tGee247id+6AMmJsjIb Izhcd+J4tGsfvK4o+btTFr4dpe/E6xRl+3BIeee5M9u4BKHGPgiGCiMkjIC+UGGSXZRw MubQ== X-Gm-Message-State: AOAM5325J2tk8OHJl1Q2LJzdMaSqpeaXrtGQeC7B/pibXkQ6ty8RdNH7 19v0+XGtyJDoQnR6Pi9xP6gyvGoeZPwZwezoRpmMwM1z5ZEXvm+KQ2QpCoNLbh6iXPzdMXbET0Q 48IJkrwRd054= X-Received: by 2002:ae9:e84c:: with SMTP id a73mr7482047qkg.432.1600823015463; Tue, 22 Sep 2020 18:03:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytLLPRvlF3rQEFDbUVECJiGXlt2EU/+dRSlt5GUHhN3hLqqHZmzrtwsnS8SNmMEmxQ0iLY4A== X-Received: by 2002:ae9:e84c:: with SMTP id a73mr7482019qkg.432.1600823015232; Tue, 22 Sep 2020 18:03:35 -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 w94sm13879882qte.93.2020.09.22.18.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 18:03:34 -0700 (PDT) Date: Tue, 22 Sep 2020 21:03:32 -0400 From: Peter Xu To: Oleg Nesterov Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Linus Torvalds , Michal Hocko , Kirill Shutemov , Jann Horn , Kirill Tkhai , Hugh Dickins , Leon Romanovsky , Jan Kara , John Hubbard , Christoph Hellwig , Andrew Morton , Jason Gunthorpe , Andrea Arcangeli Subject: Re: [PATCH 4/5] mm: Do early cow for pinned pages during fork() for ptes Message-ID: <20200923010332.GP19098@xz-x1> References: <20200921211744.24758-1-peterx@redhat.com> <20200921212028.25184-1-peterx@redhat.com> <20200922114839.GC11679@redhat.com> <20200922124013.GD11679@redhat.com> <20200922155842.GG19098@xz-x1> <20200922165216.GF11679@redhat.com> <20200922183438.GL19098@xz-x1> <20200922184359.GI11679@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200922184359.GI11679@redhat.com> 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 Tue, Sep 22, 2020 at 08:44:00PM +0200, Oleg Nesterov wrote: > On 09/22, Peter Xu wrote: > > > > Or I can also do it in inverted order if you think better: > > > > if (unlikely(copy_ret == COPY_MM_BREAK_COW)) { > > WARN_ON_ONCE(!data.cow_new_page); > > ... > > } > > Peter, let me say this again. I don't understand this code enough, you > can safely ignore me ;) Why? I appreciate every single comment from you! :) > > However. Personally I strongly prefer the above. Personally I really > dislike this part of 4/5: > > again: > + /* We don't reset this for COPY_MM_BREAK_COW */ > + memset(&data, 0, sizeof(data)); > + > +again_break_cow: > > If we rely on "copy_ret == COPY_MM_BREAK_COW" we can unify "again" and > "again_break_cow", we don't need to clear ->cow_new_page, this makes the > logic more understandable. To me at least ;) I see your point. I'll definitely try it out. I think I'll at least use what you preferred above since it's actually the same as before, logically. Then I'll consider drop the again_break_cow, as long as I'm still as confident after I do the change on not leaking anything :). Thanks, -- Peter Xu