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,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 DF5D7C433E2 for ; Thu, 17 Sep 2020 19:58:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A7F4B206DB for ; Thu, 17 Sep 2020 19:58:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600372707; bh=LrAVCl2TqeYzoD7mngmhzOKD5IgU6is16EJkQUv/F10=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=dw1U8Q27aubtI6sfGx/1zwBvSffbaGdLMCivemSJ8oX7m6CO2b0cFqWXEbD/TQOUS buOIJFqSZx3+5j3DrxT7+aCxUd4aTiURXPH9Pellxn1L0uQ2jirWQhc5pROR/NfpWS CUjWGsPx1J3SD686Ey9nIPQMnyJCtiA5IBK7rTtM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726426AbgIQT60 (ORCPT ); Thu, 17 Sep 2020 15:58:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726469AbgIQT57 (ORCPT ); Thu, 17 Sep 2020 15:57:59 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7494DC0611C2 for ; Thu, 17 Sep 2020 12:52:09 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id z19so3529986lfr.4 for ; Thu, 17 Sep 2020 12:52:09 -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=32bcgpldYXbmLkD9PAPTV/r5I9yvArjUAJrUez/8fCw=; b=VOlzEfJuZB9Z+OwJNOchIJXDkd0bTa9i+wPMaYSxT6D0dAH/K7Ga73jt3/YtjGTVK4 sVlY9P9deW7WIX2Nd152ey3/qPcCEHpblJw+UwDlDNRH2yhqCE0SHAuB/jZEQ2s1KDp6 q34MhREhlKcWU3KC+0AmTV4BHtmSJ7oVUjShk= 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=32bcgpldYXbmLkD9PAPTV/r5I9yvArjUAJrUez/8fCw=; b=bcqsVUDeucNcg4i4g/M3cVB1Q0V2Fwj8nTgi2Fi0APLbrWJ7Ru50ys99kJh1aolKOW Qt8UX79acUNP4mmtemIl+Xde0qJQMj2Ks5XE4sY+gYNa66Xhdhlc1Mc3nEWtq9uV42Y8 cQ/rItdlEqT+OOk8zKGc5mO440xuen3QmqksOQdHRNobEwoosi/UR/QykGXW+q4gbX5r xopXGvXjS19ds9+seAjjmw3U7Rr3p/tRPRf0Ya6RX5OtUwMyWi00dHMZbDvfgGGcrU43 59YwcpesMHNdawXaRw5c30vu42vAegAFlxXJ4ZHzQ/pea/WfQTZtw4Uf/b6J6+GnDCBI 09BA== X-Gm-Message-State: AOAM533uqLYBPitmQBiJRWgNWBzFHZEvCSsGvXY41IX8hX/pUgqPuvg3 r5qGFJCQ7QsvR675VJjOkFIdeb9zp6ttyg== X-Google-Smtp-Source: ABdhPJwzNTnS8fum/nyuSmL1+gfqzodnpyq4+OQHsUKu7BrcuPEp4bykjqj4s46kq2G/sWg1OMeJtg== X-Received: by 2002:a19:4284:: with SMTP id p126mr9217957lfa.393.1600372327219; Thu, 17 Sep 2020 12:52:07 -0700 (PDT) Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com. [209.85.167.44]) by smtp.gmail.com with ESMTPSA id f2sm105525lfd.103.2020.09.17.12.52.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Sep 2020 12:52:06 -0700 (PDT) Received: by mail-lf1-f44.google.com with SMTP id y11so3521817lfl.5 for ; Thu, 17 Sep 2020 12:52:06 -0700 (PDT) X-Received: by 2002:a19:4186:: with SMTP id o128mr9365158lfa.148.1600372325687; Thu, 17 Sep 2020 12:52:05 -0700 (PDT) MIME-Version: 1.0 References: <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> <20200917193824.GL8409@ziepe.ca> In-Reply-To: <20200917193824.GL8409@ziepe.ca> From: Linus Torvalds Date: Thu, 17 Sep 2020 12:51:49 -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 On Thu, Sep 17, 2020 at 12:38 PM Jason Gunthorpe wrote: > > Looking for awhile, this now looks reasonable and > doable. page_maybe_dma_pinned() was created for exactly this kind of > case. > > I've attached a dumb sketch for the pte level (surely wrong! I have > never looked at this part of the mm before!) at the end of this > message. This looks conceptually fine to me. But as mentioned, I think I'd be even happier if we added a "thsi vma has seen a page pin event" flag to the vma flags, and didn't rely _just_ on the page_maybe_dma_pinned() check, which migth be triggered by those fork-happy loads. Side note: I wonder if that COW mapping check could be entirely within that vm_normal_page() path. Because how could a non-normal page be a COW page and not already write-protected? But that's a separate issue, it's just how your patch makes that odd case more obvious. 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=-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,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 22FF8C43461 for ; Thu, 17 Sep 2020 19:52:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 76C9F235F7 for ; Thu, 17 Sep 2020 19:52:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="VOlzEfJu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 76C9F235F7 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 C4C306B0037; Thu, 17 Sep 2020 15:52:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BFCC76B0055; Thu, 17 Sep 2020 15:52:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEBCA6B005C; Thu, 17 Sep 2020 15:52:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0090.hostedemail.com [216.40.44.90]) by kanga.kvack.org (Postfix) with ESMTP id 96F886B0037 for ; Thu, 17 Sep 2020 15:52:10 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 50AE23638 for ; Thu, 17 Sep 2020 19:52:10 +0000 (UTC) X-FDA: 77273599620.06.flag85_3900d3527125 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 01185100E1C1E for ; Thu, 17 Sep 2020 19:52:09 +0000 (UTC) X-HE-Tag: flag85_3900d3527125 X-Filterd-Recvd-Size: 4925 Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Thu, 17 Sep 2020 19:52:09 +0000 (UTC) Received: by mail-lf1-f65.google.com with SMTP id q8so3517708lfb.6 for ; Thu, 17 Sep 2020 12:52:09 -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=32bcgpldYXbmLkD9PAPTV/r5I9yvArjUAJrUez/8fCw=; b=VOlzEfJuZB9Z+OwJNOchIJXDkd0bTa9i+wPMaYSxT6D0dAH/K7Ga73jt3/YtjGTVK4 sVlY9P9deW7WIX2Nd152ey3/qPcCEHpblJw+UwDlDNRH2yhqCE0SHAuB/jZEQ2s1KDp6 q34MhREhlKcWU3KC+0AmTV4BHtmSJ7oVUjShk= 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=32bcgpldYXbmLkD9PAPTV/r5I9yvArjUAJrUez/8fCw=; b=UrYoSuzt7199kPOigDhtZRWKTyL+10href+2QPxgVX4AU6pHPfV3WLkxEh3PaoIEU8 22IgodbH8hYBik8AKkOfT1jwy2pTf/RTfSMAkfYaFf4V1JiAZwY/khvOgDdFd3/zo7n9 20Na7kGjHkezrWqSTknkItFJQYgPocqpiSVTESVYhwM4wbNKSH3qPwaI7Wa3JxuEzWMk 6YUC5XJD/CmUTCsD7aOgROEV0E9HcPs2xJ5JHJ0dkylwtJq4r1Sz7Ch9Y0Q5sBa+NZZH LD0KNPAnrZCMJZkDzglYkmSVMDKt1LFgCpvvuapLbG9xUQocCqI1YVKxuAsbgQoeJRk0 LzlQ== X-Gm-Message-State: AOAM532pBvVpx8ugjaA9o/4kfkyqi4Ri5gMy6Wb/bO1eoKQSLHcDkHN2 PkmZccjm0EtoEjyo4h0BlBlBT0wrlrgnqQ== X-Google-Smtp-Source: ABdhPJyC1eOm/bQ41S1L1LbkRO14b6vAiAE+gtoWQQFav56Y30LSe7Ntl/xWjYq1oHCvkxKPPIcZGQ== X-Received: by 2002:ac2:491e:: with SMTP id n30mr9204676lfi.395.1600372327412; Thu, 17 Sep 2020 12:52:07 -0700 (PDT) Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com. [209.85.167.53]) by smtp.gmail.com with ESMTPSA id m6sm104006lfl.159.2020.09.17.12.52.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Sep 2020 12:52:06 -0700 (PDT) Received: by mail-lf1-f53.google.com with SMTP id z19so3529896lfr.4 for ; Thu, 17 Sep 2020 12:52:06 -0700 (PDT) X-Received: by 2002:a19:4186:: with SMTP id o128mr9365158lfa.148.1600372325687; Thu, 17 Sep 2020 12:52:05 -0700 (PDT) MIME-Version: 1.0 References: <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> <20200917193824.GL8409@ziepe.ca> In-Reply-To: <20200917193824.GL8409@ziepe.ca> From: Linus Torvalds Date: Thu, 17 Sep 2020 12:51:49 -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: On Thu, Sep 17, 2020 at 12:38 PM Jason Gunthorpe wrote: > > Looking for awhile, this now looks reasonable and > doable. page_maybe_dma_pinned() was created for exactly this kind of > case. > > I've attached a dumb sketch for the pte level (surely wrong! I have > never looked at this part of the mm before!) at the end of this > message. This looks conceptually fine to me. But as mentioned, I think I'd be even happier if we added a "thsi vma has seen a page pin event" flag to the vma flags, and didn't rely _just_ on the page_maybe_dma_pinned() check, which migth be triggered by those fork-happy loads. Side note: I wonder if that COW mapping check could be entirely within that vm_normal_page() path. Because how could a non-normal page be a COW page and not already write-protected? But that's a separate issue, it's just how your patch makes that odd case more obvious. Linus