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=-6.8 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 77A49C43461 for ; Thu, 17 Sep 2020 18:13:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0998821973 for ; Thu, 17 Sep 2020 18:13:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600366399; bh=OGv5XjL3rftv2UhaKxMc+qBw4L0AL/m0ow6xMH3QKjA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=m7Vu7aXecVBUk+b6Jtx7dVHJQ1ApTZAzA6ygrhpj7HRQpnEqTXGiMdQquWR313RfX rElNRTrK8TuxM8TobNCcfGaTPRLaUuLMrZSBc2iD3jszF6b/JO8cvwzc4rLpIJsnBV Rnta8QCeKsjesryBXcJFVMYZfSBM8uOuBMV75PmE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726403AbgIQSNI (ORCPT ); Thu, 17 Sep 2020 14:13:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726576AbgIQSLf (ORCPT ); Thu, 17 Sep 2020 14:11:35 -0400 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77B0DC06174A for ; Thu, 17 Sep 2020 11:11:31 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id w11so3231039lfn.2 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=uIszgT36v3optH1JGlz88O4DfpYYAV56b89G+/mI7rsQFVVYaDu/ScSvBlYNSv+3D1 lYBJeA9CFHOkhRIedzhcXDiZ7fBOCNA/t2IC8DoYRynsabXpd0bA9diuj900MfrAdBRj erf6foIg9CH9j5HtsB2wf3SUueJ/XacjWFbPfRh5/Kix3wZ2Ydjxw+GP8xCQX8I4zLED F6bXfvT682IZwoWzr2qcX6PZWIY+sItj34T1DcMm1WBqq7Pu1nUIirFlqBo2JdIL6paK /AcWVdkx9OnqumlqZLvv1nwMEFJ1wXIa+5p6+JJ/NeIkRZ6yH/uMfJn4oVIrLcDwYpu7 rigw== X-Gm-Message-State: AOAM532e0H8J122mrFa4ACwiyrAgrdib6U2TbaU4FBkNhIX6M6iZaJW1 8ZbM9gfnognoxGsAzrfXc2eLdS/IbeYD1w== X-Google-Smtp-Source: ABdhPJwj8c5z+ztHWsGSQ4jMp7Ca7DZxcQrXzsPyAbppU06WXiYlbr8wAEn/A0TdJO950oPiQfi/CQ== X-Received: by 2002:a05:6512:31c4:: with SMTP id j4mr8972709lfe.323.1600366289214; Thu, 17 Sep 2020 11:11:29 -0700 (PDT) Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com. [209.85.167.42]) by smtp.gmail.com with ESMTPSA id 73sm58009lff.125.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-f42.google.com with SMTP id z19so3219894lfr.4 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 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