Am 25.02.2013 20:07, schrieb Alex Barcelo:
> I'm struggling with the code to understand the "duty and soul" of the
> "qemu_cpu_is_self" function (@cpus.c), and I quite not get it.
> 
> I see that this function is called from some points. E.g., from
> tcg_hangle_interrupt and run_on_cpu. Amongst others.
> 
> Sometimes, seems to me that this function duty is "returns if the
> actual thread is an VCPU thread" and sometimes the duty is "return if
> the actual thread is specifically this VCPU thread".
> 
> On non-KVM QEMU vanilla, this makes no difference because of a unique
> VCPU thread. But imagine that there is an emulation thread which
> controls multiple VCPU threads...
> 
> ... then I'm stuck. Somebody can enlighten me? The in-code comments
> don't help me anymore, and I'm a little thick following the code
> logic.

Quite simply, TCG is not multi-threaded except for NPTL today. (And at
least some such linux-user use cases are known broken.)
Xen and qtest don't actually use the CPU AFAIK.

The function should give you two hints, "self" and CPUState *cpu.
The implementation further checks against a per-CPUState variable.

So if you are changing TCG code to multi-threaded and run into wrong
assumptions there, then you will need to fix them. According to my own
commit message there was a qemu_in_vcpu_thread() function introduced ~Q2
2012.

Regards,
Andreas

http://git.qemu.org/?p=qemu.git;a=commit;h=b7680cb6078bd7294a3dd86473d3f2fdee991dd0

http://git.qemu.org/?p=qemu.git;a=commit;h=60e82579c75068cb49af95595aa99d727e657a0a

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

Reply via email to