On Sun, 08 Jan 2012 16:21:08 +0200 Avi Kivity <avi@xxxxxxxxxx> wrote: > On 01/08/2012 03:58 PM, Takuya Yoshikawa wrote: > > Check how long it takes to get dirty log according to the number of > > dirty pages, like: > > > > get dirty log: 49 us for 1 dirty pages > > get dirty log: 49 us for 2 dirty pages > > get dirty log: 45 us for 4 dirty pages > > get dirty log: 41 us for 8 dirty pages > > get dirty log: 40 us for 16 dirty pages > > get dirty log: 44 us for 32 dirty pages > > get dirty log: 39 us for 64 dirty pages > > get dirty log: 42 us for 128 dirty pages > > get dirty log: 45 us for 256 dirty pages > > get dirty log: 53 us for 512 dirty pages > > get dirty log: 72 us for 1024 dirty pages > > get dirty log: 99 us for 2048 dirty pages > > get dirty log: 132 us for 4096 dirty pages > > get dirty log: 224 us for 8192 dirty pages > > get dirty log: 383 us for 16384 dirty pages > > get dirty log: 725 us for 32768 dirty pages > > get dirty log: 1412 us for 65536 dirty pages > > get dirty log: 2746 us for 131072 dirty pages > > get dirty log: 5455 us for 262144 dirty pages > > Nice! I forgot to add warming up, letting the guest scan the memory, before starting the test. So the number of shadow pages was increasing during the test. > > > + > > +void write_mem(volatile bool& running, volatile int& nr_dirty_pages, > > + void* logged_slot_virt) > > +{ > > + while (nr_dirty_pages >= 0) { > > + char* var = static_cast<char*>(logged_slot_virt); > > + > > + while (!running) { > > + delay_loop(1000); > > + } > > + for (int i = 0; i < nr_dirty_pages; ++i) { > > + ++(*var); > > + var += page_size; > > + } > > + running = false; > > You use running both to start this loop, and signal its end. Better to > use two variables. > > But why use threads at all? Just call this before reading the dirty > log, no need for synchronization. I re-used your dirty-log code a lot, will update. > > > + } > > +} > > + > > +void check_dirty_log(mem_slot& slot, > > + volatile bool& running, > > + volatile int& nr_dirty_pages) > > +{ > > + slot.set_dirty_logging(true); > > + slot.update_dirty_log(); > > + > > + for (int i = 1; i <= nr_pages; i *= 2) { > > + struct timeval start_time, end_time; > > + long time_usec; > > + > > + nr_dirty_pages = i; > > + running = true; > > + // wait until the guest finishes writing > > + while (running) { > > + delay_loop(1000); > > + } > > + > > + gettimeofday(&start_time, NULL); > > + slot.update_dirty_log(); > > + gettimeofday(&end_time, NULL); > > Nicer to have a function that returns time in nanoseconds. I don't know such an API which can be used in userspace. If we can use nano-precision timer, I want to check other things too, e.g. emulation. Takuya -- Takuya Yoshikawa <takuya.yoshikawa@xxxxxxxxx> -- 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