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.8 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,URIBL_BLOCKED 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 1E2DAC433DB for ; Thu, 7 Jan 2021 22:01:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D8D7B23447 for ; Thu, 7 Jan 2021 22:01:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727177AbhAGWBg (ORCPT ); Thu, 7 Jan 2021 17:01:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726326AbhAGWBf (ORCPT ); Thu, 7 Jan 2021 17:01:35 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F414FC0612F4 for ; Thu, 7 Jan 2021 14:00:54 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id o13so18274473lfr.3 for ; Thu, 07 Jan 2021 14:00:54 -0800 (PST) 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=7yW+3vajLGH+6lau4Q23t7xOzJcMOieZX8ybzR0BAfk=; b=Ier3MNYKecyOt6NN3c4HC+zbSyJNg5S/LMzTJRu9UzjfRfd4yCgJJajS1vHgj/pDZM duBpzqUn+N0s2xULB/3TJqG0SEFi4UIGolIVBAEOY5Uu5Yvl8eZwCESToBDTsyCUBfok eXLpLnkORwHroIjZ/lNheQln8l8l4nBN2sj8g= 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=7yW+3vajLGH+6lau4Q23t7xOzJcMOieZX8ybzR0BAfk=; b=fYhgZdzF+4q7UhB+pkArKI0+hngxuwhOC6R22dVprXh9ESMJHEqEJuCohobu54hGus MccH+AiFiKi82fZJmymfA8vtqlACLbeaItwCQkkr1n9O2lnSJ3zv0Wz0kGcNoTfcYUL/ KR/DMO1wnNrF3kTMjZnvtvqovfSqnwoXmu7KzHdmu1sRyxnMZF6AKIdN/cw/jSE+2wyk sxr0eTkBQCVyhc0UEEJOfn+jKSAEZodaUS5qkR3adDEGL6n9Rr8OxAV2IQ9wcpPcQDCw mwiSoQKeWBD8EYUaLn63JhdCxXpZ7T7qFGCwoHCRtkupINrDbpGlIN34M8Fgdt1Tkoo5 2m/A== X-Gm-Message-State: AOAM533FN2vQPrvWHKrW4K0ktVtDFwvegYKyPeltbZsqPiy8ysnJhJ4x F2UOvtspsvD4i/8ABb5tNl4+rS3CvMhaLg== X-Google-Smtp-Source: ABdhPJyYGJ21VvIodxsPyWyDEvILbb7YZRuw9ZZ3dEMgi89atndVP4uiKn8Ix/vVv5DASZBu/VRH/g== X-Received: by 2002:a05:651c:200a:: with SMTP id s10mr200482ljo.492.1610056852941; Thu, 07 Jan 2021 14:00:52 -0800 (PST) Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com. [209.85.167.41]) by smtp.gmail.com with ESMTPSA id h21sm1581749lji.89.2021.01.07.14.00.51 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 07 Jan 2021 14:00:52 -0800 (PST) Received: by mail-lf1-f41.google.com with SMTP id m12so18217567lfo.7 for ; Thu, 07 Jan 2021 14:00:51 -0800 (PST) X-Received: by 2002:a2e:6f17:: with SMTP id k23mr213194ljc.411.1610056851206; Thu, 07 Jan 2021 14:00:51 -0800 (PST) MIME-Version: 1.0 References: <20210107200402.31095-1-aarcange@redhat.com> <20210107200402.31095-3-aarcange@redhat.com> <4100a6f5-ab0b-f7e5-962f-ea1dbcb1e47e@nvidia.com> In-Reply-To: <4100a6f5-ab0b-f7e5-962f-ea1dbcb1e47e@nvidia.com> From: Linus Torvalds Date: Thu, 7 Jan 2021 14:00:35 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/2] mm: soft_dirty: userfaultfd: introduce wrprotect_tlb_flush_pending To: John Hubbard Cc: Andrea Arcangeli , Linux-MM , Linux Kernel Mailing List , Yu Zhao , Andy Lutomirski , Peter Xu , Pavel Emelyanov , Mike Kravetz , Mike Rapoport , Minchan Kim , Will Deacon , Peter Zijlstra , Hugh Dickins , "Kirill A. Shutemov" , Matthew Wilcox , Oleg Nesterov , Jann Horn , Kees Cook , Leon Romanovsky , Jason Gunthorpe , Jan Kara , Kirill Tkhai Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 7, 2021 at 1:53 PM John Hubbard wrote: > > > > > Now, I do agree that from a QoI standpoint, it would be really lovely > > if we actually enforced it. I'm not entirely sure we can, but maybe it > > would be reasonable to use that > > > > mm->has_pinned && page_maybe_dma_pinned(page) > > > > at least as the beginning of a heuristic. > > > > In fact, I do think that "page_maybe_dma_pinned()" could possibly be > > made stronger than it is. Because at *THAT* point, we might say "we > > What exactly did you have in mind, to make it stronger? I think the > answer is in this email but I don't quite see it yet... Literally just adding a " && page_mapcount(page) == 1" in there (probably best done inside page_maybe_dma_pinned() itself) > Direct IO pins, on the other hand, are more transient. We can probably live > without tagging Direct IO pages as FOLL_PIN. I think. Yes. I think direct-IO writes should be able to just do a transient GUP, and if it causes a COW fault that isn't coherent, that's the correct semantics, I think (ie the direct-IO will see the original data, the COW faulter will get it's own private copy to make changes to). I think pinning should be primarily limited to things that _require_ coherency (ie you pin because you're going to do some active two-way communication using that page) Does that match your thinking? Linus 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.8 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,URIBL_BLOCKED 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 8077CC433E0 for ; Thu, 7 Jan 2021 22:00:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1F52623435 for ; Thu, 7 Jan 2021 22:00:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F52623435 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 6C9318D0151; Thu, 7 Jan 2021 17:00:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 653DF8D0150; Thu, 7 Jan 2021 17:00:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 51D058D0151; Thu, 7 Jan 2021 17:00:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0226.hostedemail.com [216.40.44.226]) by kanga.kvack.org (Postfix) with ESMTP id 383E88D0150 for ; Thu, 7 Jan 2021 17:00:56 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id EF33F440B for ; Thu, 7 Jan 2021 22:00:55 +0000 (UTC) X-FDA: 77680349670.15.sign59_5c174b3274ed Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id C24151814B0C8 for ; Thu, 7 Jan 2021 22:00:55 +0000 (UTC) X-HE-Tag: sign59_5c174b3274ed X-Filterd-Recvd-Size: 5634 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Thu, 7 Jan 2021 22:00:55 +0000 (UTC) Received: by mail-lf1-f50.google.com with SMTP id m25so18102732lfc.11 for ; Thu, 07 Jan 2021 14:00:54 -0800 (PST) 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=7yW+3vajLGH+6lau4Q23t7xOzJcMOieZX8ybzR0BAfk=; b=Ier3MNYKecyOt6NN3c4HC+zbSyJNg5S/LMzTJRu9UzjfRfd4yCgJJajS1vHgj/pDZM duBpzqUn+N0s2xULB/3TJqG0SEFi4UIGolIVBAEOY5Uu5Yvl8eZwCESToBDTsyCUBfok eXLpLnkORwHroIjZ/lNheQln8l8l4nBN2sj8g= 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=7yW+3vajLGH+6lau4Q23t7xOzJcMOieZX8ybzR0BAfk=; b=l5ZORNlnTNw75XfWIv7MMTW/cd+iVLnzh4qHBKUre4lru3ZmJd7HM+mj+2e/6p43d9 k1JFtpYDii9JI9B/FYawnL80Xp7D2JHMfsOj0ysL6c8J5tpdxGEQ6NpBbxqDPtRFthQv 9bNvVmQwuif0fiijoXWHKxb//u6uXzuoNzkLIYBeEnSfenE8U/7EpRkXbJplreanPQMl 0E0ZYiALze/1FNmpBsqd/VAfalmWlh+OMGGs2v1WrnY0zwRDNM1TBAGED+ZFElD5GYy0 DliNrdxu+FtDbzNzgUGg8ObRAnVYfCoWQB3rc2kFENv3p00XdI8glpyTdgIWdy3Y0G+D ZsMg== X-Gm-Message-State: AOAM5338FEYkDT0hP6Ra8hDMi05D1VbPoBqY91sgyFPfE5ogSK5RBaHX xWRx9hjuu65BDMet7YEQ4H2P2iu7yXBAHg== X-Google-Smtp-Source: ABdhPJzNUuYU0UOjIAnOAWnBRuiB7Nq/6MAlJSRnW0vMpbx8BYj9l7nvat13V46t2tIoP9pwtmEzqg== X-Received: by 2002:ac2:446d:: with SMTP id y13mr293136lfl.615.1610056853039; Thu, 07 Jan 2021 14:00:53 -0800 (PST) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com. [209.85.167.47]) by smtp.gmail.com with ESMTPSA id 68sm1561349ljj.23.2021.01.07.14.00.51 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 07 Jan 2021 14:00:52 -0800 (PST) Received: by mail-lf1-f47.google.com with SMTP id 23so18161568lfg.10 for ; Thu, 07 Jan 2021 14:00:51 -0800 (PST) X-Received: by 2002:a2e:6f17:: with SMTP id k23mr213194ljc.411.1610056851206; Thu, 07 Jan 2021 14:00:51 -0800 (PST) MIME-Version: 1.0 References: <20210107200402.31095-1-aarcange@redhat.com> <20210107200402.31095-3-aarcange@redhat.com> <4100a6f5-ab0b-f7e5-962f-ea1dbcb1e47e@nvidia.com> In-Reply-To: <4100a6f5-ab0b-f7e5-962f-ea1dbcb1e47e@nvidia.com> From: Linus Torvalds Date: Thu, 7 Jan 2021 14:00:35 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/2] mm: soft_dirty: userfaultfd: introduce wrprotect_tlb_flush_pending To: John Hubbard Cc: Andrea Arcangeli , Linux-MM , Linux Kernel Mailing List , Yu Zhao , Andy Lutomirski , Peter Xu , Pavel Emelyanov , Mike Kravetz , Mike Rapoport , Minchan Kim , Will Deacon , Peter Zijlstra , Hugh Dickins , "Kirill A. Shutemov" , Matthew Wilcox , Oleg Nesterov , Jann Horn , Kees Cook , Leon Romanovsky , Jason Gunthorpe , Jan Kara , Kirill Tkhai 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, Jan 7, 2021 at 1:53 PM John Hubbard wrote: > > > > > Now, I do agree that from a QoI standpoint, it would be really lovely > > if we actually enforced it. I'm not entirely sure we can, but maybe it > > would be reasonable to use that > > > > mm->has_pinned && page_maybe_dma_pinned(page) > > > > at least as the beginning of a heuristic. > > > > In fact, I do think that "page_maybe_dma_pinned()" could possibly be > > made stronger than it is. Because at *THAT* point, we might say "we > > What exactly did you have in mind, to make it stronger? I think the > answer is in this email but I don't quite see it yet... Literally just adding a " && page_mapcount(page) == 1" in there (probably best done inside page_maybe_dma_pinned() itself) > Direct IO pins, on the other hand, are more transient. We can probably live > without tagging Direct IO pages as FOLL_PIN. I think. Yes. I think direct-IO writes should be able to just do a transient GUP, and if it causes a COW fault that isn't coherent, that's the correct semantics, I think (ie the direct-IO will see the original data, the COW faulter will get it's own private copy to make changes to). I think pinning should be primarily limited to things that _require_ coherency (ie you pin because you're going to do some active two-way communication using that page) Does that match your thinking? Linus