All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] Semantics of tcg_enabled() and what it means for multi-arch
@ 2015-07-11 20:46 Peter Crosthwaite
  2015-07-11 22:23 ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Crosthwaite @ 2015-07-11 20:46 UTC (permalink / raw
  To: Paolo Bonzini, Richard Henderson,
	qemu-devel@nongnu.org Developers

Hi Paolo, Richard and all,

What is the exact semantic of tcg_enabled() supposed to be and is it
ill-defined in multi-arch?

Currently, tcg_enabled is defined as:

bool tcg_enabled(void)
{
    return tcg_ctx.code_gen_buffer != NULL;
}

In the multi-arch work, the tcg_ctx is now multiple per-arch. So lets
assume that we virtualise tcg_enabled as a CPU hook. This handles a
good number of cases, where there is a sense of a current CPU to which
the tcg_enabled is being queried. All uses in target-foo are trivially
handled as they will link against their local tcg_enabled
implementation. This per-cpu approach has the added advantage of
preparing support for mixed KVM/TCG multi-arch systems.

But tcg_enabled() is used in the memory API for dirty code tracking
where there is no sense of a current tcg_ctx:

include/exec/ram_addr.h:                if (tcg_enabled()) {
include/exec/ram_addr.h:        uint8_t clients = tcg_enabled() ?
DIRTY_CLIENTS_ALL : DIRTY_CLIENTS_NOCODE;
memory.c:    mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
memory.c:    mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
memory.c:    mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
memory.c:    mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;

So what is the correct logic for populating dirty_log_mask and friends
when there are 0. 1, or more TCG engines?

Regards,
Peter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] Semantics of tcg_enabled() and what it means for multi-arch
  2015-07-11 20:46 [Qemu-devel] Semantics of tcg_enabled() and what it means for multi-arch Peter Crosthwaite
@ 2015-07-11 22:23 ` Paolo Bonzini
  2015-07-11 22:45   ` Peter Crosthwaite
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2015-07-11 22:23 UTC (permalink / raw
  To: Peter Crosthwaite, Richard Henderson,
	qemu-devel@nongnu.org Developers



On 11/07/2015 22:46, Peter Crosthwaite wrote:
> include/exec/ram_addr.h:                if (tcg_enabled()) {
> include/exec/ram_addr.h:        uint8_t clients = tcg_enabled() ?
> DIRTY_CLIENTS_ALL : DIRTY_CLIENTS_NOCODE;
> memory.c:    mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
> memory.c:    mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
> memory.c:    mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
> memory.c:    mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
> 
> So what is the correct logic for populating dirty_log_mask and friends
> when there are 0. 1, or more TCG engines?

I think it should be set if there's at least one TCG engine.

Have you checked BTW it the DIRTY_MEMORY_CODE stuff works with multiple
tcg_ctxs _and_ the same page hosts code for more than one CPU type?
Offhand I have no idea of the answer...

Paolo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] Semantics of tcg_enabled() and what it means for multi-arch
  2015-07-11 22:23 ` Paolo Bonzini
@ 2015-07-11 22:45   ` Peter Crosthwaite
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Crosthwaite @ 2015-07-11 22:45 UTC (permalink / raw
  To: Paolo Bonzini; +Cc: qemu-devel@nongnu.org Developers, Richard Henderson

On Sat, Jul 11, 2015 at 3:23 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
>
> On 11/07/2015 22:46, Peter Crosthwaite wrote:
>> include/exec/ram_addr.h:                if (tcg_enabled()) {
>> include/exec/ram_addr.h:        uint8_t clients = tcg_enabled() ?
>> DIRTY_CLIENTS_ALL : DIRTY_CLIENTS_NOCODE;
>> memory.c:    mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
>> memory.c:    mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
>> memory.c:    mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
>> memory.c:    mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
>>
>> So what is the correct logic for populating dirty_log_mask and friends
>> when there are 0. 1, or more TCG engines?
>
> I think it should be set if there's at least one TCG engine.
>

Thanks. So translate-common.c will implement a global
tcg_any_enabled() for these cases, while others will use a
virtualised/local tcg_enabled().

> Have you checked BTW it the DIRTY_MEMORY_CODE stuff works with multiple
> tcg_ctxs _and_ the same page hosts code for more than one CPU type?
> Offhand I have no idea of the answer...
>

No, I haven't progressed that far. I have a basic test for shared data
area but not shared code.

Regards,
Peter

> Paolo
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-11 22:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-11 20:46 [Qemu-devel] Semantics of tcg_enabled() and what it means for multi-arch Peter Crosthwaite
2015-07-11 22:23 ` Paolo Bonzini
2015-07-11 22:45   ` Peter Crosthwaite

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.