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.1 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 D8668C4727E for ; Thu, 24 Sep 2020 21:30:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 25E682399A for ; Thu, 24 Sep 2020 21:30:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QA8iFnBs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25E682399A 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 324416B005C; Thu, 24 Sep 2020 17:30:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2ADCA6B005D; Thu, 24 Sep 2020 17:30:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 176516B0062; Thu, 24 Sep 2020 17:30:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0253.hostedemail.com [216.40.44.253]) by kanga.kvack.org (Postfix) with ESMTP id F1FC86B005C for ; Thu, 24 Sep 2020 17:30:17 -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 B2BC63641 for ; Thu, 24 Sep 2020 21:30:17 +0000 (UTC) X-FDA: 77299248474.06.title24_2b015e027162 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 74C821017A602 for ; Thu, 24 Sep 2020 21:30:17 +0000 (UTC) X-HE-Tag: title24_2b015e027162 X-Filterd-Recvd-Size: 5146 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Thu, 24 Sep 2020 21:30:16 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600983016; 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=GHZX7ZQSsiuVO3F0KOGNC6cDMHJGjkdiBXGbF9uY1qg=; b=QA8iFnBsTpDuqDUBF6x5PhYYn9jxu9KXWbbwUrr+tittjzhlw3fF+/NSh7s1ScB9sX6pZX 2h+AUw6EBJWX+ho/dg823Un8+uNKxhWo/al1jWoimuSudTK3b+dJdzV/bAtSV5JinEg0GO JBIS/UxLjJfs28bCQig1E1qjXIEE4Os= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-327-XoqCIoCpPRONO2_6UdEtog-1; Thu, 24 Sep 2020 17:30:13 -0400 X-MC-Unique: XoqCIoCpPRONO2_6UdEtog-1 Received: by mail-qv1-f69.google.com with SMTP id t7so382583qvz.5 for ; Thu, 24 Sep 2020 14:30:13 -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=GHZX7ZQSsiuVO3F0KOGNC6cDMHJGjkdiBXGbF9uY1qg=; b=fwoocGVOUEpGlE0f1mNYIBMdBhI6CuygKe5km7dFR5cOc879h8BRsFgiJsoarnE3E0 uJxE4XhG6BuvDxnUmZUWKFTrKfUn+/0eEyzXjL9S6+UPCFubhFil/DxijTS1R8RApwyz 0lhvR2HPDhRrO7NVLGP180J+tiS4lq3q8DG5lQJwBRhhhF6TXsy+93b0oakkmL2imz+f xUnOgOz2JkEfjk9A5T8837xXmp4uy+UT/YvCF+hcCKv7FFAWFEIxbmu4PgVmyk3w1s8V 4lepNu/fJtKvTVBCFIQYpxdu9mLfgIUsFW/gMQN859y8hDljTbe47Q6Ir1mvfxYD4GiM CESQ== X-Gm-Message-State: AOAM532rqjNT89r1sVXF1jjL3Lou04c2u7OKRtJM2PSkdSqCQyVhyt6n FhXiS42ucP4rER+1hLw3gnWTzmh/mwsj5H9d6j7l3DNeUywyyLxrad99k0BJGdQd+JZ757WPYhU olgdAhR89aNI= X-Received: by 2002:a05:620a:546:: with SMTP id o6mr1197897qko.296.1600983013476; Thu, 24 Sep 2020 14:30:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGdv9aQEFGeLxroRNPZ6s4EbIA5GgM4mhynzklei3yx+Gk8JqoQYvZjf7XJEiBcK/q3FcaCw== X-Received: by 2002:a05:620a:546:: with SMTP id o6mr1197874qko.296.1600983013220; Thu, 24 Sep 2020 14:30:13 -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 c28sm610766qtk.18.2020.09.24.14.30.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2020 14:30:12 -0700 (PDT) Date: Thu, 24 Sep 2020 17:30:10 -0400 From: Peter Xu To: Jason Gunthorpe Cc: John Hubbard , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Jan Kara , Michal Hocko , Kirill Tkhai , Kirill Shutemov , Hugh Dickins , Christoph Hellwig , Andrea Arcangeli , Oleg Nesterov , Leon Romanovsky , Linus Torvalds , Jann Horn Subject: Re: [PATCH 1/5] mm: Introduce mm_struct.has_pinned Message-ID: <20200924213010.GL79898@xz-x1> References: <20200922175415.GI19098@xz-x1> <20200922191116.GK8409@ziepe.ca> <20200923002735.GN19098@xz-x1> <20200923170759.GA9916@ziepe.ca> <20200924143517.GD79898@xz-x1> <20200924165152.GE9916@ziepe.ca> <20200924175531.GH79898@xz-x1> <20200924181501.GF9916@ziepe.ca> <20200924183418.GJ79898@xz-x1> <20200924183953.GG9916@ziepe.ca> MIME-Version: 1.0 In-Reply-To: <20200924183953.GG9916@ziepe.ca> 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 Thu, Sep 24, 2020 at 03:39:53PM -0300, Jason Gunthorpe wrote: > On Thu, Sep 24, 2020 at 02:34:18PM -0400, Peter Xu wrote: > > > > > // RDONLY gup > > > > pin_user_pages(buf, !WRITE); > > > > // pte of buf duplicated on both sides > > > > fork(); > > > > mprotect(buf, WRITE); > > > > *buf = 1; > > > > // buf page replaced as cow triggered > > > > > > > > Currently when fork() we'll happily share a pinned read-only page with the > > > > child by copying the pte directly. > > > > > > Why? This series prevents that, the page will be maybe_dma_pinned, so > > > fork() will copy it. > > > > With the extra mprotect(!WRITE), I think we'll see a !pte_write() entry. Then > > it'll not go into maybe_dma_pinned() at all since cow==false. > > Hum that seems like a problem in this patch, we still need to do the > DMA pinned logic even if the pte is already write protected. Yes I agree. I'll take care of that in the next version too. -- Peter Xu