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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64D3BC04A6A for ; Thu, 3 Aug 2023 13:02:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A2CAF280248; Thu, 3 Aug 2023 09:02:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B4F328022C; Thu, 3 Aug 2023 09:02:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 82F70280248; Thu, 3 Aug 2023 09:02:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 6C6C128022C for ; Thu, 3 Aug 2023 09:02:48 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1D7141A1154 for ; Thu, 3 Aug 2023 13:02:48 +0000 (UTC) X-FDA: 81082808016.24.BFEAFC5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 5DC9F400E5 for ; Thu, 3 Aug 2023 13:02:27 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bh1x4ltI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691067748; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eJz+/0G2mEv6SI+dWI2RYHCp9SYOk0dQT4zCRlQD1ZE=; b=5st5vZiqzyAoxRyhGBzNGeG+0qZ/RObGFEaMDNqNRt0XFN8iZEMNI87FdWfhtIn+3vBMS8 4t3gqX0i6XtbiBNTjz1K6oltjAESg5fjmtT1lro+/jarlO32cs5ldQizpRETTZnIVX2KZg grz1TUGDPD5VGY5UkU4RE7kKK2vGkfs= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bh1x4ltI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691067748; a=rsa-sha256; cv=none; b=ZVLcH6JKruIAoEPkUSjkxyk38O0fJAanR2s4Ischl0ToWAwXnskvKFALP664Rfq2SqfQpW A6EUiUAyhB7EDqZ3HcLyGTrLdTsEktYRs/s5MO9IIcMKy+O8/7SWjCqdN3BoI3ChwAwe/3 oW8vyAcRubRBIaUfFMeYoFJZC8Wnp/M= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691067747; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=eJz+/0G2mEv6SI+dWI2RYHCp9SYOk0dQT4zCRlQD1ZE=; b=bh1x4ltIydpWaHU+1xWZZQurqwyCZO6j5fXJy7iiV0T7ULHha1HHpK7KmygmqnqDia6IF+ jE2vnXnc6qLJBl83WQZKvu7Wz2EaC6+6lNMiN6uZ0cEPlqocswGVkHMRz+4RBjeUrOYAdR bo2UD5nYd3eAXgm+mknzC0teaKEYslU= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-657-pvp4SLKiO9exaNgzI-sBGw-1; Thu, 03 Aug 2023 09:02:26 -0400 X-MC-Unique: pvp4SLKiO9exaNgzI-sBGw-1 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-40fed04ea2aso1140731cf.0 for ; Thu, 03 Aug 2023 06:02:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691067745; x=1691672545; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=eJz+/0G2mEv6SI+dWI2RYHCp9SYOk0dQT4zCRlQD1ZE=; b=dI6O476FFvlxN+RAP5uWf7Op6dcpyCIIdw64VncmOr/uVnaD7M1WqxJldvh8aqMWRf XsR1XWJaOW08cZyxl06m9rlnmqjI+CB+y73edUCpe1jJ7NC1GavA/7KuIWT4atqwtd2w fdP6XjG3JZoMZZzAQyBXTbeqU1codqE9cn96xpZwNYXy/k7phS+3OtF2CXCom6sGyldV tbluOpt/MP9GzL8euEp3CNiqhayd+g+jMXAl7EA7e4Z9IR2+n/KsihlC6OD9tqT+5XUV XrwMnvZ/YFtJ6U0WMoE6Oc0n+JqAIZ8WonhWNXqmoBrydtPKKsZnhA4MwbT9HKgcixPx o1tg== X-Gm-Message-State: ABy/qLbDAIXK5Bs88U2UHalLiGIp9C9vACfgoXDBfverfwIsA5LqXWVH wgKMmitih2+ocQFIqib8LJMAQgbIm7Z+0NcBmHIKI1WE1Zljgeb0oxNPgAqApW6gm2TZRJM+dgd mTcZ+67QJldc= X-Received: by 2002:a05:622a:13ce:b0:403:c2fa:83b with SMTP id p14-20020a05622a13ce00b00403c2fa083bmr22178490qtk.4.1691067745579; Thu, 03 Aug 2023 06:02:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlEFOQ3sw787k0lCO6xjA4QS65YLiEbg9JCaPwNWB3hN/9LsAvELPwMJgbLfqIg5ZsX++XxHpw== X-Received: by 2002:a05:622a:13ce:b0:403:c2fa:83b with SMTP id p14-20020a05622a13ce00b00403c2fa083bmr22178455qtk.4.1691067745121; Thu, 03 Aug 2023 06:02:25 -0700 (PDT) Received: from x1n (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id bq22-20020a05622a1c1600b0040331a24f16sm6129081qtb.3.2023.08.03.06.02.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 06:02:24 -0700 (PDT) Date: Thu, 3 Aug 2023 09:02:23 -0400 From: Peter Xu To: "Kasireddy, Vivek" Cc: Hugh Dickins , Jason Gunthorpe , Alistair Popple , Gerd Hoffmann , "Kim, Dongwon" , David Hildenbrand , "Chang, Junxiao" , "linux-mm@kvack.org" , "dri-devel@lists.freedesktop.org" , Mike Kravetz Subject: Re: [RFC v1 1/3] mm/mmu_notifier: Add a new notifier for mapping updates (new pages) Message-ID: References: <75e3a74a-68f5-df-9a49-a0553c04320@google.com> MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspamd-Queue-Id: 5DC9F400E5 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: od7qbhf9da9te7on1hn1khz8srusfg4b X-HE-Tag: 1691067747-866944 X-HE-Meta: U2FsdGVkX19Z1BhPzLyOX9F87SsVX+agC+8dzlhg1SudfvtMLNiHOJ3PU0VJ2S97z3r9ibGzHv322aDZxRrsDjqMCLK8RHeMsEiP2Y6PJ0j9/ZqKHct8+MRl+S0kmIyF/genJLN2h5+CLBjzEEVxB2GArt8VAwONBwyEw1NnkFN3snZPPGEjRUhsTcZK0aHw2QzRIbqJrUC3yJcoHrL/fY6h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zNOt0VT6Tyd0zZEefl321jIahmbgLE1Vn2cPOvsDRpy2DJrTGL9WqHY0Pr97ssXJwhtWUzsne6btMf9FPtF6cnZjpoCrsg9CZz9BweNRaguqEFBk9z/h+WsYAkH1y2uA26t7IAJ8pLmscNnjaYhCfxn4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.005513, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi, Vivek, On Thu, Aug 03, 2023 at 08:08:41AM +0000, Kasireddy, Vivek wrote: > > Isn't it already too late though to wait that notification until page is > > installed? Because here you pinned the page for DMA, I think it means > > before a new page installed (but after the page is invalidated) the device > > can DMA to an invalid buffer. > > The page is only invalidated in the memfd. Until the hole is written to, > we (udmabuf) can choose to handle any reads (or DMA) using old pages > if needed. But what happens if there's DMA writes? I don't see anything that will stop the device from doing so - the whole design looks fully transparent, I just still don't see how it can be done without synchronizing with the device. IIUC, we need to e.g. quiesce the device when any page got invalidated in some way like hole punching, and should happen right before it happens (comparing to the notification of new page update which should be right after the installation OTOH). I think the vfio use case currently face the same condition and challenge, assuming there's currently no easy solution so that was just prohibited. I guess people are just waiting for hardware vendors to support device page faults, like processors - then we can synchronize with the device using the device IOMMU page tables (by clearing it at proper time and blocks DMA writes). Thanks, -- Peter Xu