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=-16.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 6A345C433DB for ; Tue, 9 Feb 2021 02:56:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C862164E0B for ; Tue, 9 Feb 2021 02:56:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C862164E0B 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 3287A6B0005; Mon, 8 Feb 2021 21:56:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D8036B006C; Mon, 8 Feb 2021 21:56:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1544C6B006E; Mon, 8 Feb 2021 21:56:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0225.hostedemail.com [216.40.44.225]) by kanga.kvack.org (Postfix) with ESMTP id F3D0A6B0005 for ; Mon, 8 Feb 2021 21:56:02 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B877C824805A for ; Tue, 9 Feb 2021 02:56:02 +0000 (UTC) X-FDA: 77797214964.04.bear76_0d14a4d27603 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 9CBCA80162CE for ; Tue, 9 Feb 2021 02:56:02 +0000 (UTC) X-HE-Tag: bear76_0d14a4d27603 X-Filterd-Recvd-Size: 5718 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Tue, 9 Feb 2021 02:56:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612839361; 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=ZCPgOdo0sguJV+CnbMbF2hM5SDTI0aKdRJzqe0KmNUc=; b=fkW0IKlYRuvnaUvqPf44Yq2iubsVVZ3YkzvY1MKSLlNzA+h5VIt33RpZ7HJeOBmYswl6NU HLbSI43X0nYPgO9gOb+fa4ubGsqW7/skcOwd5Co+1YiOV+N4ML5fTsLVo+Uum+I1Vnq2Zb cQU9WH/T1Jpe+ef9Kg/tDkiK3DdoP7Q= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-276-19aPORRYNDe10LBC2gcgQA-1; Mon, 08 Feb 2021 21:55:59 -0500 X-MC-Unique: 19aPORRYNDe10LBC2gcgQA-1 Received: by mail-qk1-f199.google.com with SMTP id p185so14681485qkc.9 for ; Mon, 08 Feb 2021 18:55:59 -0800 (PST) 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=ZCPgOdo0sguJV+CnbMbF2hM5SDTI0aKdRJzqe0KmNUc=; b=NFi3XO/6umSO8B0ZMlUCfY2ezp7rJxwsqnEVDt3xS8hFLlIZWRUigCnXGZ+b3RI9VM MIz9KSAdVCZELMhap3INzwGMtxb8I0BO1nY7rr9vBgAbulWE+Cl47VDbhBTdyiOlc4CR LqM3qpJuu33gRekOUKvRMAABDhO/3g4+u6jpT7GgV0/wIzo2Dsnjn3ojoiEnrGwbrlPV zLnk9Mbp6H3iyDIRLilAymhwGEApkoZUleYJdo6pOQY4L5tuIUTfpAZ3sVJYvxJ9PpyC uk8p1PzFf+2u6c6rnQ2QABaWWX9exedBTRuXqWHdvoc2N3b8jDRDGXxFA2fiGq8+Qfoq lkIg== X-Gm-Message-State: AOAM531hKpyX1HpbxynR+rFmIjDk7kpZ/oZIH34pq/s8hPlENib8qk2d mNAm3TWUOCZWvjDGA0Kb+zQOdSzcZ3akBA+kQQ4ez8JWyTMbWc4NF9xY5oqeVaXx/dWmmJz0WnI qLhieq9HZDTo= X-Received: by 2002:a05:6214:118e:: with SMTP id t14mr18876783qvv.50.1612839359380; Mon, 08 Feb 2021 18:55:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJzw+JQUTVQ5YYbkf1TNWGMyrE7IvTpldV4OfemnnYjq2iJrzhzieq28T220Dnmd4gQiQ116Og== X-Received: by 2002:a05:6214:118e:: with SMTP id t14mr18876771qvv.50.1612839359161; Mon, 08 Feb 2021 18:55:59 -0800 (PST) Received: from xz-x1 (bras-vprn-toroon474qw-lp130-20-174-93-89-182.dsl.bell.ca. [174.93.89.182]) by smtp.gmail.com with ESMTPSA id u45sm13510077qte.3.2021.02.08.18.55.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 18:55:58 -0800 (PST) Date: Mon, 8 Feb 2021 21:55:56 -0500 From: Peter Xu To: Mike Kravetz Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Gal Pressman , Andrea Arcangeli , Christoph Hellwig , Miaohe Lin , Kirill Shutemov , Jann Horn , Matthew Wilcox , Jan Kara , Jason Gunthorpe , Linus Torvalds , Mike Rapoport , David Gibson , Kirill Tkhai , Wei Zhang , Andrew Morton Subject: Re: [PATCH v3 5/5] hugetlb: Do early cow when page pinned on src mm Message-ID: <20210209025556.GA82021@xz-x1> References: <20210205165406.4655-1-peterx@redhat.com> <20210205165406.4655-6-peterx@redhat.com> 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 Mon, Feb 08, 2021 at 04:09:26PM -0800, Mike Kravetz wrote: > On 2/5/21 8:54 AM, Peter Xu wrote: > > This is the last missing piece of the COW-during-fork effort when there're > > pinned pages found. One can reference 70e806e4e645 ("mm: Do early cow for > > pinned pages during fork() for ptes", 2020-09-27) for more information, since > > we do similar things here rather than pte this time, but just for hugetlb. > > Thanks for all the changes, the patch looks much better. > > I did not look at 70e806e4e645 in detail until now. That commit had the > 'write protect trick' which was removed in subsequent commits. It took me > a bit of git history tracking to figure out the state of that code today and > the reasons for the subsequent changes. I guess that was a good way to > educate me. :) Thanks for looking into those details. I didn't expect that to happen since after Jason's rework with 57efa1fe5957 ("mm/gup: prevent gup_fast from racing with COW during fork", 2020-12-15) we can ignore the whole wr-protect idea as a whole. I referenced 70e806e4e645 more for the idea of why we do that, and also copy_present_page() on how it is generally implemented. That gup-fast race is definitely tricky on its own. > > > > > Signed-off-by: Peter Xu > > --- > > mm/hugetlb.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++---- > > 1 file changed, 62 insertions(+), 4 deletions(-) > > Reviewed-by: Mike Kravetz Thanks! I'll post a new version very soon with your r-b, and also a compile warning fixed in the other patch as reported by Gal. -- Peter Xu