On 11/14/2011 12:07 PM, Avi Kivity wrote: > On 11/14/2011 11:23 AM, Takuya Yoshikawa wrote: > > Needed for the next patch which uses this number to decide how to write > > protect a slot. > > > > /* If nothing is dirty, don't bother messing with page tables. */ > > - if (is_dirty) { > > + if (memslot->nr_dirty_pages) { > > struct kvm_memslots *slots, *old_slots; > > unsigned long *dirty_bitmap; > > > > @@ -3504,6 +3500,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, > > goto out; > > memcpy(slots, kvm->memslots, sizeof(struct kvm_memslots)); > > slots->memslots[log->slot].dirty_bitmap = dirty_bitmap; > > + slots->memslots[log->slot].nr_dirty_pages = 0; > > slots->generation++; > > > > #endif /* !CONFIG_S390 */ > > @@ -1491,7 +1492,8 @@ void mark_page_dirty_in_slot(struct kvm *kvm, struct kvm_memory_slot *memslot, > > if (memslot && memslot->dirty_bitmap) { > > unsigned long rel_gfn = gfn - memslot->base_gfn; > > > > - __set_bit_le(rel_gfn, memslot->dirty_bitmap); > > + if (!__test_and_set_bit_le(rel_gfn, memslot->dirty_bitmap)) > > + memslot->nr_dirty_pages++; > > } > > } > > > > The two assignments to ->nr_dirty_pages can race, no? Nothing protects it. > er, it can't, it's before the rcu_assign_pointer(). -- error compiling committee.c: too many argumen ts to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html