On 01/04/16 14:11, Alex Bennée wrote: > Sergey Fedorov <serge.f...@gmail.com> writes: > >> On 31/03/16 16:37, Alex Bennée wrote: >>> Sergey Fedorov <serge.f...@gmail.com> writes: >>>> Looks like no matter which approach we use, it's ultimately necessary to >>>> ensure all CPUs have exited from translated code before the translation >>>> buffer may be safely flushed. >>> One approach would be to have multiple translation contexts with their >>> own buffers and then you can safely flush TBs if no vCPUs are currently >>> executing in those regions. But I suspect that is a much more complex >>> future optimisation. >> Yes, this is much more complex and its performance impact should be >> investigated. >> >>> Having said that is it safe to flush TBs from a given page if we know >>> no vCPUs are currently executing in that page? As the execution loop has >>> to exit the chained TBs as we cross page boundaries we could just keep >>> account of which vCPUs are currently in which page. >> It should be safe to invalidate a TB while some other CPU is executing >> its translated code. But it should be guaranteed that no CPU execute any >> old TB after tb_flush() since we're going to start reusing those TBs. >> >> I see how TB cannot be patched if it spans two pages, is there any on >> when TCG goto_tb can be generated? > Do you mean tcg_gen_goto_tb? > > AFAIUI all blocks end with goto_tb post-ambles but they should only > directly jump to another TB if they are in the same page.
Thanks, I see the checks. Regards, Sergey