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 77C54C04A6A for ; Tue, 1 Aug 2023 21:58:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 96E5F2800FD; Tue, 1 Aug 2023 17:58:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 91F102800C8; Tue, 1 Aug 2023 17:58:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E6852800FD; Tue, 1 Aug 2023 17:58:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 6B1DA2800C8 for ; Tue, 1 Aug 2023 17:58:01 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 383911A0D1B for ; Tue, 1 Aug 2023 21:58:01 +0000 (UTC) X-FDA: 81076899162.18.435C4BB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 1DE6DC001C for ; Tue, 1 Aug 2023 21:57:58 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=W3p9eFHI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.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=1690927079; 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=/5jP/Uu+OO6juLyXLyEuCWWvaHANLE401zJH/WXu0vI=; b=c+g64E6FZGIFLgChBJL8UssZLCs3oY7HMpNbClSKEN6PQy8ruq0ZYhpwtp8tShVbK53WbT vZKmD4x7FkI8ZVemkTxNSye3dv6kTjNFJFzH0Co32xsquWIjTKObSIi66JmjV7hQW0FIG0 glfwBVYHcWn8iYO2zePiz8q9cqSkDlE= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=W3p9eFHI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690927079; a=rsa-sha256; cv=none; b=S2lfZk73YDESPvUqd29ZeQxm0x661AK84xy7cop6x21C82jPLIsFGVRjzyTTHu+gwX1SIB 2t9XuzQ4I5mFSmtxrmh7Fjin8HfmBxeHi0howQyq4mO4VyRKU5LpQRcIA/a//xdN+y+/JR cvHuA0LFGiahFrIM9X0c2onduPGydHc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690927078; 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=/5jP/Uu+OO6juLyXLyEuCWWvaHANLE401zJH/WXu0vI=; b=W3p9eFHIA23d04oQxzFAM/BNZA4vBWTJ47zH5QZYx/rG1K7VCk7J5ylzs8T8hgeyXh5eb2 teUicFVo0MDL46cZgIgjYmbfx3e8k51KdZ7hQjnuit47nFj3+LtSyATwsHtzO1u5g8qttr gxmynvAxmd4qS185JEMqEGOKnMYYfAQ= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-418-r1NZjHg3PhWSGKdyTbENiQ-1; Tue, 01 Aug 2023 17:57:56 -0400 X-MC-Unique: r1NZjHg3PhWSGKdyTbENiQ-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-76c7cffef41so123323085a.1 for ; Tue, 01 Aug 2023 14:57:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690927076; x=1691531876; 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=/5jP/Uu+OO6juLyXLyEuCWWvaHANLE401zJH/WXu0vI=; b=iPY3RMmL82cPOudRukoi4myI5vP/iVqvJ6W/kG4M05g/JyPNT4djdYC0QmaxnN9Lhk UC94UFZQEDYM6orhhc3QJJH+nvrW6J52XEoGQ42xm2TlCBF5gCunCWS0NYwYCvx0CFPN /sOSpETQur5ddCZPwp6UyEjFXGILVRBV0kjaVIh5Zy9f3iWEpwuAbbxc++5xaLI78q4T mbaDAt/eH92l/ANStiLNvtlXeMvQMpIFfcSIe54+UcfhJDiHGIVo+K+W/VohiToG0P04 anb65O6tnRnByXtLRpRM4NE0FckcrvfAKPqHcFMChYp/AT+XBs2A6gK261r4M4BJnMJC x1cw== X-Gm-Message-State: ABy/qLa1YIoZTPvRoiscTL5yweQKjMW93qWOB5v4HvSe05VQ/I2wTMud uZiiL9a0z1xR762b0VD9lFVOC7pOIQxNQ/8SsHRo8hqzP7M3aOVl+Q2WvkDXHZh72IbSeI/d+1Z CN7WPOV1dRpQ= X-Received: by 2002:a05:620a:430a:b0:767:346c:4b37 with SMTP id u10-20020a05620a430a00b00767346c4b37mr12848382qko.7.1690927076147; Tue, 01 Aug 2023 14:57:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlFazEvf4bQmOL9hX+Oa0KAgFYC+ldTguiGGQJvZBm9XGzTkuKrWjBnYqk48Nd5hj5M/jsxZAg== X-Received: by 2002:a05:620a:430a:b0:767:346c:4b37 with SMTP id u10-20020a05620a430a00b00767346c4b37mr12848363qko.7.1690927075876; Tue, 01 Aug 2023 14:57:55 -0700 (PDT) Received: from x1n (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id pc22-20020a05620a841600b00767cbd5e942sm4481519qkn.72.2023.08.01.14.57.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Aug 2023 14:57:55 -0700 (PDT) Date: Tue, 1 Aug 2023 17:57:53 -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: <87pm4nj6s5.fsf@nvdebian.thelocal> <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: 1DE6DC001C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: m8ohd8ifs7p9y588uhjg5b6x6r48bzai X-HE-Tag: 1690927078-241596 X-HE-Meta: U2FsdGVkX18kREwwGgmaedPGRnSx/D5ajHnqUChR08NtCbtuWnBnH+GPEkKQce4Qe5NpSshPM0AZs+UzIl0E0yahjKsz9VSDpczh704Ou/jm3l1a4aqH5G3/tPTl6piQddgIcqCRkK7sXHxXcHhV0Cf0sDfcH0cFUHsXVN26LsxDjGwMNeBm/iAh2ZX1qyAmv+dbMY3fy/z/xzRc4QNU5/zOjgoHzS4r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ZmoKhlrfIRmpGxPxCLRM75l1ig4auxE5DBApsxeSHRO9lefNoH/XEs2e8vLy7b/4vMMHCKmgkrHvgu9ShezT3z7z2fdxrKZ0GYfpwZvsm93ar1xAR4LZ3EIE5GCXkTwjO4c1YoXcDhezxoJpfhIwtAxbj/cqAQ1co= X-Bogosity: Ham, tests=bogofilter, spamicity=0.005435, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Aug 01, 2023 at 07:11:09AM +0000, Kasireddy, Vivek wrote: > Ok, I'll keep your use-case in mind but AFAICS, the process that creates > the udmabuf can be considered the owner. So, I think it makes sense that > the owner's VMA range can be registered (via mmu_notifiers) for updates. No need to have your special attention on this; my use case is not anything useful with details, just wanted to show the idea that virtual address range based notification might not work. [...] > What limitation do you see with the usage of mmu notifiers for this use-case? > And, if using mmu notifiers is not the right approach, how do you suggest we > can solve this problem? AFAIU, even if there'll be a notification chanism, it needs to be at least in per-file address space (probably in file offsets) rather than per-mm for a shmem backend, so that any mapping of the file should notify that. 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. To come back to the original question: I don't know how that could work at all, the userapp should just never do that invalidation, because right after it does, the dma buffer will be invalid, and the device can update data into trash. So.. I don't have an easy way to do this right.. besides disabling ram discard just like what vfio does already. Thanks, -- Peter Xu