[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 1/8] kvm: Set cpu_single_env only once
From: |
Jan Kiszka |
Subject: |
Re: [Qemu-devel] [PATCH v2 1/8] kvm: Set cpu_single_env only once |
Date: |
Sat, 11 Feb 2012 13:41:48 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 |
On 2012-02-11 12:25, Blue Swirl wrote:
> On Sat, Feb 11, 2012 at 10:06, Jan Kiszka <address@hidden> wrote:
>> On 2012-02-11 11:02, Blue Swirl wrote:
>>> On Fri, Feb 10, 2012 at 18:31, Jan Kiszka <address@hidden> wrote:
>>>> As we have thread-local cpu_single_env now and KVM uses exactly one
>>>> thread per VCPU, we can drop the cpu_single_env updates from the loop
>>>> and initialize this variable only once during setup.
>>>
>>> I don't think this is correct. Maybe you missed the part that sets
>>> cpu_single_env to NULL, which I think is to annoy broken code that
>>> assumes that some CPU state is always globally available. This is not
>>> true for monitor context.
>>
>> I did check this before changing, and I see no such need. Particularly
>> as this old debugging help prevents valid use case.
>
> It looks like monitor code is safe now. But in several places there
> are checks like this in pc.c:
> DeviceState *cpu_get_current_apic(void)
> {
> if (cpu_single_env) {
> return cpu_single_env->apic_state;
> } else {
> return NULL;
> }
> }
>
> In cpu-exec.c, there are these lines:
> /* fail safe : never use cpu_single_env outside cpu_exec() */
> cpu_single_env = NULL;
That's legacy stuff from the pre-io-thread times. Nowadays,
cpu_single_env is logically either always valid (KVM) or switching
seamlessly between the VCPUs (TCG).
>
> I think using cpu_single_env is an indication of a problem, like poor
> code, layering violation or poor API (vmport). What is your use case?
We have a few poor ABIs like the VMware stuff or the KVM VAPIC, so we
have to live with it already for that use cases. Moreover, cpus.c use it
internally, like for vm_stop, to find out the caller context.
Jan
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH v2 1/8] kvm: Set cpu_single_env only once, (continued)
- Re: [Qemu-devel] [PATCH v2 1/8] kvm: Set cpu_single_env only once, Paolo Bonzini, 2012/02/13
- Re: [Qemu-devel] [PATCH v2 1/8] kvm: Set cpu_single_env only once, Blue Swirl, 2012/02/11
- Re: [Qemu-devel] [PATCH v2 1/8] kvm: Set cpu_single_env only once, Jan Kiszka, 2012/02/11
- Re: [Qemu-devel] [PATCH v2 1/8] kvm: Set cpu_single_env only once, Blue Swirl, 2012/02/11
- Re: [Qemu-devel] [PATCH v2 1/8] kvm: Set cpu_single_env only once, Jan Kiszka, 2012/02/11
- Re: [Qemu-devel] [PATCH v2 1/8] kvm: Set cpu_single_env only once, Blue Swirl, 2012/02/11
- Re: [Qemu-devel] [PATCH v2 1/8] kvm: Set cpu_single_env only once,
Jan Kiszka <=
[Qemu-devel] [PATCH v2 6/8] kvmvapic: Simplify mp/up_set_tpr, Jan Kiszka, 2012/02/10
[Qemu-devel] [PATCH v2 2/8] Allow to use pause_all_vcpus from VCPU context, Jan Kiszka, 2012/02/10
[Qemu-devel] [PATCH v2 5/8] kvmvapic: Introduce TPR access optimization for Windows guests, Jan Kiszka, 2012/02/10