Message ID | 1439220437-23957-17-git-send-email-fred.konrad@greensocs.com |
---|---|
State | New |
Headers | show |
On 10/08/2015 17:27, fred.konrad@greensocs.com wrote: > + > +void tb_flush_safe(CPUState *cpu) > +{ > +#if 0 /* !MTTCG */ > + tb_flush(cpu); > +#else > + async_run_safe_work_on_cpu(cpu, tb_flush_work, cpu); > +#endif /* MTTCG */ > +} > + I think this can use first_cpu unconditionally; tb_flush only uses its argument for an error message. In fact, I think that by definition async_run_safe_work_on_cpu can use any CPU for its work; it locks out everyone else, so it does not matter which thread you're on. So async_run_safe_work_on_cpu could drop the @cpu argument (becoming async_run_safe_cpu_work) and use first_cpu unconditionally. Paolo
On 10/08/2015 17:27, fred.konrad@greensocs.com wrote: > From: KONRAD Frederic <fred.konrad@greensocs.com> > > tb_flush is not thread safe we definitely need to exit VCPUs to do that. > This introduces tb_flush_safe which just creates an async safe work which will > do a tb_flush later. > > Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> You could also allocate a new code buffer and free the old one with call_rcu. This should simplify things a lot. Paolo
On 12/08/2015 16:09, Paolo Bonzini wrote: > > On 10/08/2015 17:27, fred.konrad@greensocs.com wrote: >> From: KONRAD Frederic <fred.konrad@greensocs.com> >> >> tb_flush is not thread safe we definitely need to exit VCPUs to do that. >> This introduces tb_flush_safe which just creates an async safe work which will >> do a tb_flush later. >> >> Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> > You could also allocate a new code buffer and free the old one with > call_rcu. This should simplify things a lot. > > Paolo Depending the size of the code buffer this might be a good idea. :). Fred
On 12/08/2015 16:11, Frederic Konrad wrote: >> You could also allocate a new code buffer and free the old one with >> call_rcu. This should simplify things a lot. > > Depending the size of the code buffer this might be a good idea. :). 32 megabytes. Paolo
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index e9512df..246df68 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -200,6 +200,7 @@ struct TBContext { void tb_free(TranslationBlock *tb); void tb_flush(CPUState *cpu); +void tb_flush_safe(CPUState *cpu); void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr); #if defined(USE_DIRECT_JUMP) diff --git a/translate-all.c b/translate-all.c index fc5162a..7094bf0 100644 --- a/translate-all.c +++ b/translate-all.c @@ -818,6 +818,21 @@ static void page_flush_tb(void) } } +static void tb_flush_work(void *opaque) +{ + CPUState *cpu = opaque; + tb_flush(cpu); +} + +void tb_flush_safe(CPUState *cpu) +{ +#if 0 /* !MTTCG */ + tb_flush(cpu); +#else + async_run_safe_work_on_cpu(cpu, tb_flush_work, cpu); +#endif /* MTTCG */ +} + /* flush all the translation blocks */ /* XXX: tb_flush is currently not thread safe */ void tb_flush(CPUState *cpu)