On Sun, 15 Jan 2023 14:50:55 +0000, Shivam Kumar <shivam.kumar1@xxxxxxxxxxx> wrote: > > >> Thank you Marc for the suggestion. We can make dirty quota count > >> dirtied memory rather than faults. > >> > >> run->dirty_quota -= page_size; > >> > >> We can raise a kvm request for exiting to userspace as soon as the > >> dirty quota of the vcpu becomes zero or negative. Please let me know > >> if this looks good to you. > > > > It really depends what "page_size" represents here. If you mean > > "mapping size", then yes. If you really mean "page size", then no. > > > > Assuming this is indeed "mapping size", then it all depends on how > > this is integrated and how this is managed in a generic, cross > > architecture way. > > > > Thanks, > > > > M. > > > > Yes, it is "mapping size". I can see that there's a "npages" variable > in "kvm_memory_slot" which determines the number of bits we need to > track dirtying for a given memory slot. And this variable is computed > by right shifting the memory size by PAGE_SHIFT. Each arch defines the > macro PAGE_SHIFT, and another macro PAGE_SIZE as the left shift of 1 > by PAGE_SHIFT. Does it make sense to use this macro? I don't think it makes any sense. There is nothing in the memslot structure that you can make use of. The information you need is the page table structure itself (the level, precisely), which tells you how big the mapping is for this particular part of the memslot. This is dynamic information, not defined at memslot creation. Which is why it can only be captured at fault time (with the exception of HugeTLBFS backed memslots for which the mapping size is cast into stone). M. -- Without deviation from the norm, progress is not possible.