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 D3A5EC433E2 for ; Thu, 17 Sep 2020 18:11:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3F9BD21D7F for ; Thu, 17 Sep 2020 18:11:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="ebZpe94e" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3F9BD21D7F 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 73B9C6B0003; Thu, 17 Sep 2020 14:11:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6EA566B0037; Thu, 17 Sep 2020 14:11:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6292D6B0055; Thu, 17 Sep 2020 14:11:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0106.hostedemail.com [216.40.44.106]) by kanga.kvack.org (Postfix) with ESMTP id 4D84C6B0003 for ; Thu, 17 Sep 2020 14:11:32 -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 0A06A3651 for ; Thu, 17 Sep 2020 18:11:32 +0000 (UTC) X-FDA: 77273346024.08.tray58_500123927124 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id DC0BD1819E76B for ; Thu, 17 Sep 2020 18:11:31 +0000 (UTC) X-HE-Tag: tray58_500123927124 X-Filterd-Recvd-Size: 5374 Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Thu, 17 Sep 2020 18:11:31 +0000 (UTC) Received: by mail-lf1-f68.google.com with SMTP id x69so3218901lff.3 for ; Thu, 17 Sep 2020 11:11:31 -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=CvhYrXTQ7P1PpPJneriFY/N4fH6cu5PCNfejoxCMfjU=; b=ebZpe94emC58OChvJb6ZM/Lfv6J4RQjpddoqdFXFgpn5nQwns+cim1TIIPoMi913bU pPqAGC9UjlAo4pGFpVTz9MAzxmkQYqgUthKSwOP5an1HSaD/lIhSFVjOxv+pKuMqxBXu QPJtWnomu+ikDHtTtN2WJd+Q8J1NFpOyixo9E= 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=CvhYrXTQ7P1PpPJneriFY/N4fH6cu5PCNfejoxCMfjU=; b=glaBKu6JhgmNEdYYoOCN8wMfmy0ashV1DP1y621IxW8wdFOBFufHj5QRDKYNC1reXi Iszr1WZqyrvGSFgCys4qkFg/hsaq/V/B1Z10+cLl9/CmPLNjoSTFDyF974ezTJ9AkRfj SsdSP1ttVT8MJYtTzE3jTRgXMalpdPKV8EoJKipUOKftOu0njIzBs38nrWxmAwYeqOCC uTx3eZ4y1v71oW0LmEoVDl6H2/Fh3g4jg6c1JexrSZT/MJLwfV91/OCL8wdJ/Wg94FE6 BSFZGZ2f+SFuHOgNOC2OhDQhH7edGID+NEYfRDNK+eNSvWYHFfe4P5ICud/eVJ2OnYZN j1xA== X-Gm-Message-State: AOAM533mR48+mc6yW0AtJCGBjjJ0gNvXiH25J3LGpZQfzTLrXt7gr8DW w6WkpPRi1JFs5IrAlokLYwLCbunk9hxatA== X-Google-Smtp-Source: ABdhPJwr+XarKbZg822O1ddvtkZyiZs69/Z8abPOwQQoyhJM/vCG5CBL/JldqfavFaEjhb2+W/+A9g== X-Received: by 2002:ac2:489c:: with SMTP id x28mr10491919lfc.544.1600366289164; Thu, 17 Sep 2020 11:11:29 -0700 (PDT) Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com. [209.85.167.50]) by smtp.gmail.com with ESMTPSA id c10sm62879lfc.4.2020.09.17.11.11.23 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Sep 2020 11:11:23 -0700 (PDT) Received: by mail-lf1-f50.google.com with SMTP id y11so3211685lfl.5 for ; Thu, 17 Sep 2020 11:11:23 -0700 (PDT) X-Received: by 2002:ac2:4ec7:: with SMTP id p7mr8604753lfr.352.1600366282941; Thu, 17 Sep 2020 11:11:22 -0700 (PDT) MIME-Version: 1.0 References: <20200915145040.GA2949@xz-x1> <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> In-Reply-To: <20200917112538.GD8409@ziepe.ca> From: Linus Torvalds Date: Thu, 17 Sep 2020 11:11:06 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/4] mm: Trial do_wp_page() simplification To: Jason Gunthorpe Cc: Peter Xu , 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: > I botched the last version of the patch, here is something a bit > better. So I'd like to understand why this problem happens. Myt argument to Hugh a few weeks ago was that page pinning should take care of all this: (a) if the pinner is going to change the page, it will have to get the pin with FOLL_WRITE in addition to FOLL_PIN (b) that means it will do the COW and mark the page writable and dirty (c) the whole _point_ of the FOLL_PIN is that subsequent operations shouldn't make it non-writable any more (ie it can't be unmapped, and we should synchronize on fork etc) So I get the strong feeling that this whole approach to "fix" COW is really papering over the real problem. To me, the whole point of pinning is to avoid issues like this. If it didn't fix this issue, then why did we go to all the effort of treating pinned pages differently? Your patch may avoid the problem, but I think it implies things are horribly horribly broken in pinning land. I also note that the _only_ user of page_maybe_dma_pinned() right now is a debug check in gup_benchmark. I think your patch may _work_, and I think that thanks to page_maybe_dma_pinned() it might even avoid the horrible case, but I feel we should just truly fix pinning to be meaningful instead. IOW, in addition to keeping the page mapped, it should keep the page writable. Why isn't it? Linus