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=-3.9 required=3.0 tests=BAYES_00,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 1F075C4363D for ; Thu, 24 Sep 2020 18:39:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 96C412311E for ; Thu, 24 Sep 2020 18:39:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="gWVZzyi+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96C412311E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 001CC6B005C; Thu, 24 Sep 2020 14:39:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF3D56B005D; Thu, 24 Sep 2020 14:39:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE39A8E0001; Thu, 24 Sep 2020 14:39:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0196.hostedemail.com [216.40.44.196]) by kanga.kvack.org (Postfix) with ESMTP id C80AD6B005C for ; Thu, 24 Sep 2020 14:39:56 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 84310180AD806 for ; Thu, 24 Sep 2020 18:39:56 +0000 (UTC) X-FDA: 77298819192.09.river44_4010b1527161 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 69A4B180AD802 for ; Thu, 24 Sep 2020 18:39:56 +0000 (UTC) X-HE-Tag: river44_4010b1527161 X-Filterd-Recvd-Size: 4627 Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Thu, 24 Sep 2020 18:39:55 +0000 (UTC) Received: by mail-qt1-f194.google.com with SMTP id y11so3797303qtn.9 for ; Thu, 24 Sep 2020 11:39:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=6kbTN227ky6se6GWSxv41w9bcLrPJYb+hPK0FBP3Lg8=; b=gWVZzyi+aAbtDvJswci5KIVx20vljopjCPq9XTRfZQcpoUp6L/NpC+o8fz/o8v+djp P8kwqc3LM0DEHmxKFsPUZn0HgipLID3Q4GATLkjQqmbbv8NXLgCRiHYbtP7OApNNAUFg taF2/VN5MUeTgDcMiVkcWoPS5GoFDY2cDEELqVmXJH3c4n5VtJVyUm/cw2y/0oHM+4Me rb1gw+R5+irhjXNZzpTV8tRKd0rh/IrYatrYQxI2GChtmQtogPnwvB0C2TZpu4Nhob3G q+TeJX6KHRT9tMbE+WAZHsWfS+OXEE6gb9jwyc6XrB40S8K+ksJOVhlOJdhqRNLtBdho 1bHg== 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=6kbTN227ky6se6GWSxv41w9bcLrPJYb+hPK0FBP3Lg8=; b=EV6O0hsyv+/0oXnEAinlXrj+arBPxQjYrblYweeomtLqsnqFNalEeA8ZhFsHUwFwHe wE94G/soijY7VbJt4wZ84WXYaLAgDcqpVCM+G55fs0g0XEJk6Rb0p+5K8WQZAI/Ru1Jb Vqpt1Ph39WVHFqeRS0jQIAla76l/ow6jnjrTR18OKCwoRlGLUxzb/cf3o553RQ6/oIxz GCLPMmzT5FQ+fiXRcm4F9YzHWvV7cmQQpbdUco71eYzKZKtMlgUTcJ/T+JGH11NjzByk VnSa8xs3XVFXPRUx09TmF86lyKIgK2Fy6oaz7Lxx+w8S+RdqwFxoVJ3UFKqIo3CEk+T9 aYTA== X-Gm-Message-State: AOAM530nHj9yuh59/WQWVCVLxF73hDGyE23TfoTUb/4bjRMXHRurIz+5 sjZfiJKC9lfzOnG8LPuMdiWSHQ== X-Google-Smtp-Source: ABdhPJx/nzPF1+mMk4wCyfDA/nz8skTDrljJDGUq+fRssNEpMom5E/VQfo1/HE+wA3mhVgTkXlbjYA== X-Received: by 2002:ac8:75d2:: with SMTP id z18mr504702qtq.346.1600972795287; Thu, 24 Sep 2020 11:39:55 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-48-30.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.48.30]) by smtp.gmail.com with ESMTPSA id n203sm193262qke.66.2020.09.24.11.39.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2020 11:39:54 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kLW9p-000RJr-PH; Thu, 24 Sep 2020 15:39:53 -0300 Date: Thu, 24 Sep 2020 15:39:53 -0300 From: Jason Gunthorpe To: Peter Xu 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: <20200924183953.GG9916@ziepe.ca> References: <20200922161046.GB731578@ziepe.ca> <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200924183418.GJ79898@xz-x1> 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 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. Jason