From: Yacine HEBBAL Subject: Re: Difference between =?utf-8?b?dmNwdV9sb2Fk?= and =?utf-8?b?a3ZtX3NjaGVkX2lu?= ? Date: Wed, 21 Oct 2015 10:20:02 +0000 (UTC) Message-ID: References: <56266175.4030409@redhat.com> <562734BF.2020806@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: kvm@vger.kernel.org Return-path: Received: from plane.gmane.org ([80.91.229.3]:47707 "EHLO plane.gmane.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932472AbbJUKUQ (ORCPT ); Wed, 21 Oct 2015 06:20:16 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZoqV8-0002br-5A for kvm@vger.kernel.org; Wed, 21 Oct 2015 12:20:10 +0200 Received: from machine107.orange-labs.com ([161.106.0.5]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 21 Oct 2015 12:20:10 +0200 Received: from y_hebbal by machine107.orange-labs.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 21 Oct 2015 12:20:10 +0200 Sender: kvm-owner@vger.kernel.org List-ID: Paolo Bonzini redhat.com> writes: > > > On 21/10/2015 00:57, Wanpeng Li wrote: > >> kvm_sched_out and kvm_sched_in are part of KVM's preemption hooks. The > >> hooks are registered only between vcpu_load and vcpu_put, therefore they > >> know that the mutex is taken. The sequence will go like this: > >> > >> vcpu_load > >> kvm_sched_out > >> kvm_sched_in > >> kvm_sched_out > >> kvm_sched_in > >> ... > >> vcpu_put > > > > If this should be: > > > > vcpu_load > > kvm_sched_in > > kvm_sched_out > > kvm_sched_in > > kvm_sched_out > > ... > > vcpu_put > > No, because vcpu_load is called while the thread is running. Therefore, > the first preempt notifier call will be a sched_out notification, which > calls kvm_arch_vcpu_put. Extending the picture above: > > vcpu_load -> kvm_arch_vcpu_load > kvm_sched_out -> kvm_arch_vcpu_put > kvm_sched_in -> kvm_arch_vcpu_load > kvm_sched_out -> kvm_arch_vcpu_put > kvm_sched_in -> kvm_arch_vcpu_load > ... > kvm_sched_out -> kvm_arch_vcpu_put > kvm_sched_in -> kvm_arch_vcpu_load > vcpu_put -> kvm_arch_vcpu_put > > Thanks, > > Paolo > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > > Thanks for the explanation, it's very clear. I tired that but I didn't succeed to send the ioctl from "run_on_cpu" function, I didn't find how to set the right CPUStat I've tried "current_cpu" kvm_main.c: // yacine.begin static void do_vmi_start_kvm_ioctl(void *type) { printf("do_vmi_start_kvm_ioctl\n"); kvm_vm_ioctl(kvm_state, type); } int vmi_start_kvm_ioctl(int type) { <- called from hmp.c printf("vmi_start_kvm_ioctl\n"); run_on_cpu(current_cpu, do_vmi_start_kvm_ioctl, (void *) &type); return 0; } // yacine.end This gives me a segmentation fault Then I tired to replace current_cpu with ENV_GET_CPU(mon_get_cpu()), it didn't work, I get nothing, no error but doesn't work I tried also to pass mon->mon_cpu through int vmi_start_kvm_ioctl(int type) by adding a first parameter as CPUStat, i get compiler error "dereference pointer to incomplete type" I'm beginner to qemu and kvm code, can you please orient me to fix this problem ? Thanks in advance Yacine