From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: mmu_notifers, pte_dirty questions Date: Sun, 06 Jun 2010 15:07:27 +0300 Message-ID: <4C0B8F7F.507@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , KVM list To: Andrea Arcangeli Return-path: Received: from mx1.redhat.com ([209.132.183.28]:24451 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754647Ab0FFMH3 (ORCPT ); Sun, 6 Jun 2010 08:07:29 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o56C7TUv030573 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 6 Jun 2010 08:07:29 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o56C7Sle029901 for ; Sun, 6 Jun 2010 08:07:28 -0400 Sender: kvm-owner@vger.kernel.org List-ID: Why no notifer when testing and clearing the dirty bit? (*clear_flush_dirty)(...). > static int page_mkclean_one(struct page *page, struct vm_area_struct *vma, > unsigned long address) > { > struct mm_struct *mm = vma->vm_mm; > pte_t *pte; > spinlock_t *ptl; > int ret = 0; > > pte = page_check_address(page, mm, address, &ptl, 1); > if (!pte) > goto out; > > if (pte_dirty(*pte) || pte_write(*pte)) { > pte_t entry; > > flush_cache_page(vma, address, pte_pfn(*pte)); > entry = ptep_clear_flush_notify(vma, address, pte); > entry = pte_wrprotect(entry); > entry = pte_mkclean(entry); > set_pte_at(mm, address, pte, entry); set_pte_at_notify()? without this (or clear_flush_dirty) Linux will assume all ptes are now clean; if the guest writes to a page nothing will catch it. -> with set_pte_at_notify(), we can drop the spte and mark the page as dirty, so the next write will re-instantiate the spte -> with ->clear_flush_dirty(), we can track the dirty state without dropping the spte. > ret = 1; > } > > pte_unmap_unlock(pte, ptl); > out: > return ret; I'm probably missing something big as I can't see how this works. -- error compiling committee.c: too many arguments to function