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 53AA5C433E2 for ; Thu, 17 Sep 2020 18:26:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 91E1E221F1 for ; Thu, 17 Sep 2020 18:26:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="hCD7+WAu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 91E1E221F1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 95E276B0055; Thu, 17 Sep 2020 14:26:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 90DD16B005A; Thu, 17 Sep 2020 14:26:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7FBD46B005C; Thu, 17 Sep 2020 14:26:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0102.hostedemail.com [216.40.44.102]) by kanga.kvack.org (Postfix) with ESMTP id 67A546B0055 for ; Thu, 17 Sep 2020 14:26:23 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 287C13654 for ; Thu, 17 Sep 2020 18:26:23 +0000 (UTC) X-FDA: 77273383446.08.balls24_1a0224127124 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id 0D0A71819E76B for ; Thu, 17 Sep 2020 18:26:23 +0000 (UTC) X-HE-Tag: balls24_1a0224127124 X-Filterd-Recvd-Size: 5395 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Thu, 17 Sep 2020 18:26:22 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id u21so2875279ljl.6 for ; Thu, 17 Sep 2020 11:26:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+mpoyqx3mxsDyuRiiNHu6NufBQVIYLoY1L/3VBEofe4=; b=hCD7+WAuUU01eFe1Jc50npe5xb7OtkBBbWJ6mCXZrO2bBS8k+KZahRQRDycsdra938 OOiI10P4yId0P07N+qEKZ1H2LSRKMnm9Sc41SuHORgPw8g2eGGXHHduC/t8zGy7bZeIC H1noIOp7B5z/HdZvYg7VUXZeGcTMvgZdLaxfQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+mpoyqx3mxsDyuRiiNHu6NufBQVIYLoY1L/3VBEofe4=; b=N0rYGhVlfXs46jbyWrjwDnvAIEaKqAZcc6pAzF1zd+T0FVUb9ajDp6YzJ91yhX4x7p 6rbX8D27luUtdlkTXhsIVC27o7xTPnXsidfl+R/fKY/hVCfAu6phDNDLBUJnU5FDZ7yA Zd9yb/zCKSakGuBaRJaG4nXKWbHjXjhu+4g9c99ZmvgTS4otK60PfjWuyOPMjdeRxlYx TjwXcP7jTFyXpwrUiQLACpi4MPVlFg+9AznRcw/lbQRlB1Rr7rxWVb4z6UdB6H+iti7Z Fkz49eVq5KVO7TjjUyYjzP7C0skkT5ReC+W7yuHBz4UvRpUS1eAWShA2qH8mTqLaRpR8 +Q7g== X-Gm-Message-State: AOAM531J+f4ecFyml4EvQJXfhjzAy5ssZZ64yYkh6j7h62+JzZoinh9w b5l7LMIyt7BJv12G8Jzf7li15pUF7udpbg== X-Google-Smtp-Source: ABdhPJxfI2RQjbsOuOmjZzUmeCaoYwzBccrBR7HXPBpi2zSXUNsjVe3w2lIPpiIcBLGQcVl2ZQoLWw== X-Received: by 2002:a2e:99cb:: with SMTP id l11mr10334838ljj.123.1600367180343; Thu, 17 Sep 2020 11:26:20 -0700 (PDT) Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com. [209.85.167.45]) by smtp.gmail.com with ESMTPSA id m13sm63403lfb.172.2020.09.17.11.26.18 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Sep 2020 11:26:18 -0700 (PDT) Received: by mail-lf1-f45.google.com with SMTP id z17so3230749lfi.12 for ; Thu, 17 Sep 2020 11:26:18 -0700 (PDT) X-Received: by 2002:ac2:4ec7:: with SMTP id p7mr8620939lfr.352.1600367177963; Thu, 17 Sep 2020 11:26:17 -0700 (PDT) MIME-Version: 1.0 References: <20200915160553.GJ1221970@ziepe.ca> <20200915182933.GM1221970@ziepe.ca> <20200915191346.GD2949@xz-x1> <20200915193838.GN1221970@ziepe.ca> <20200915213330.GE2949@xz-x1> <20200915232238.GO1221970@ziepe.ca> <20200916174804.GC8409@ziepe.ca> <20200916184619.GB40154@xz-x1> <20200917112538.GD8409@ziepe.ca> <20200917181411.GA133226@xz-x1> In-Reply-To: <20200917181411.GA133226@xz-x1> From: Linus Torvalds Date: Thu, 17 Sep 2020 11:26:01 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/4] mm: Trial do_wp_page() simplification To: Peter Xu 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 Content-Type: text/plain; charset="UTF-8" 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 17, 2020 at 11:14 AM Peter Xu wrote: > > In my humble opinion, the real solution is still to use MADV_DONTFORK properly > so we should never share the DMA pages with others when we know the fact. Is this all just because somebody does a fork() after doing page pinning? If so, I feel this should be trivially fixed in copy_one_pte(). That's where we currently do /* * If it's a COW mapping, write protect it both * in the parent and the child */ if (is_cow_mapping(vm_flags) && pte_write(pte)) { ptep_set_wrprotect(src_mm, addr, src_pte); pte = pte_wrprotect(pte); } and I feel that that is where we could just change the code to do a COW event for pinned pages (and *not* mark the parent write protected, since the parent page now isn't a COW page). Because if that's the case that Jason is hitting, then I feel that really is the correct fix: make sure that the pinning action is meaningful. As mentioned, I really think the whole (and only) point of page pinning is that it should keep the page locked in the page tables. And by "locked" I mean exactly that: not just present, but writable. And then the "we never COW a pinned page" comes not from the COW code doing magic, but by it simply never becoming non-writable - because the page table entry is locked! Linus