From: Jason Wang Subject: Re: [RFC PATCH V2 5/5] vhost: access vq metadata through kernel virtual address Date: Fri, 8 Mar 2019 16:31:29 +0800 Message-ID: <92dfa6cc-a86c-0cef-6384-98aeb8b9e567@redhat.com> References: <1551856692-3384-1-git-send-email-jasowang@redhat.com> <1551856692-3384-6-git-send-email-jasowang@redhat.com> <20190306092837-mutt-send-email-mst@kernel.org> <15105894-4ec1-1ed0-1976-7b68ed9eeeda@redhat.com> <20190307101708-mutt-send-email-mst@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, peterx@redhat.com, linux-mm@kvack.org, aarcange@redhat.com To: "Michael S. Tsirkin" Return-path: In-Reply-To: <20190307101708-mutt-send-email-mst@kernel.org> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 2019/3/7 下午11:34, Michael S. Tsirkin wrote: > On Thu, Mar 07, 2019 at 10:45:57AM +0800, Jason Wang wrote: >> On 2019/3/7 上午12:31, Michael S. Tsirkin wrote: >>>> +static void vhost_set_vmap_dirty(struct vhost_vmap *used) >>>> +{ >>>> + int i; >>>> + >>>> + for (i = 0; i < used->npages; i++) >>>> + set_page_dirty_lock(used->pages[i]); >>> This seems to rely on page lock to mark page dirty. >>> >>> Could it happen that page writeback will check the >>> page, find it clean, and then you mark it dirty and then >>> invalidate callback is called? >>> >>> >> Yes. But does this break anything? >> The page is still there, we just remove a >> kernel mapping to it. >> >> Thanks > Yes it's the same problem as e.g. RDMA: > we've just marked the page as dirty without having buffers. > Eventually writeback will find it and filesystem will complain... > So if the pages are backed by a non-RAM-based filesystem, it’s all just broken. Yes, we can't depend on the pages that might have been invalidated. As suggested, the only suitable place is the MMU notifier callbacks. Thanks > one can hope that RDMA guys will fix it in some way eventually. > For now, maybe add a flag in e.g. VMA that says that there's no > writeback so it's safe to mark page dirty at any point? > > > > >