From patchwork Thu May 7 20:55:11 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 22394 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n47LAG0o015269 for ; Thu, 7 May 2009 21:10:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754660AbZEGVKK (ORCPT ); Thu, 7 May 2009 17:10:10 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751084AbZEGVKK (ORCPT ); Thu, 7 May 2009 17:10:10 -0400 Received: from mx2.redhat.com ([66.187.237.31]:45208 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753416AbZEGVJ7 (ORCPT ); Thu, 7 May 2009 17:09:59 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n47LA0D7016592 for ; Thu, 7 May 2009 17:10:00 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n47L9xEg013876; Thu, 7 May 2009 17:09:59 -0400 Received: from amt.cnet (vpn-10-52.str.redhat.com [10.32.10.52]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n47L9vM5017560; Thu, 7 May 2009 17:09:58 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 1A5D3682004; Thu, 7 May 2009 18:00:02 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id n47Kxebe007665; Thu, 7 May 2009 17:59:40 -0300 Message-Id: <20090507205536.747958391@amt.cnet> User-Agent: quilt/0.47-1 Date: Thu, 07 May 2009 17:55:11 -0300 From: mtosatti@redhat.com To: kvm@vger.kernel.org Cc: avi@redhat.com, Marcelo Tosatti Subject: [patch 2/4] kvm-kmod: smp_send_reschedule compat References: <20090507205509.522421993@amt.cnet> Content-Disposition: inline; filename=kvm-kmod-compat-smp-send-reschedule X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org smp_send_reschedule was exported (via smp_ops) in v2.6.24. Create a compat function which schedules the IPI to keventd context, in case interrupts are disabled, for kernels < 2.6.24. Signed-off-by: Marcelo Tosatti --- 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 Index: kvm-kmod/ia64/hack-module.awk =================================================================== --- kvm-kmod.orig/ia64/hack-module.awk +++ kvm-kmod/ia64/hack-module.awk @@ -1,4 +1,4 @@ -BEGIN { split("INIT_WORK on_each_cpu smp_call_function " \ +BEGIN { split("INIT_WORK on_each_cpu smp_call_function smp_send_reschedule " \ "hrtimer_add_expires_ns hrtimer_get_expires " \ "hrtimer_get_expires_ns hrtimer_start_expires " \ "hrtimer_expires_remaining " \ Index: kvm-kmod/x86/hack-module.awk =================================================================== --- kvm-kmod.orig/x86/hack-module.awk +++ kvm-kmod/x86/hack-module.awk @@ -1,7 +1,7 @@ BEGIN { split("INIT_WORK desc_struct ldttss_desc64 desc_ptr " \ "hrtimer_add_expires_ns hrtimer_get_expires " \ "hrtimer_get_expires_ns hrtimer_start_expires " \ - "hrtimer_expires_remaining " \ + "hrtimer_expires_remaining smp_send_reschedule " \ "on_each_cpu relay_open request_irq free_irq" , compat_apis); } /^int kvm_init\(/ { anon_inodes = 1 } Index: kvm-kmod/external-module-compat-comm.h =================================================================== --- kvm-kmod.orig/external-module-compat-comm.h +++ kvm-kmod/external-module-compat-comm.h @@ -224,6 +224,10 @@ int kvm_smp_call_function_mask(cpumask_t #define smp_call_function_mask kvm_smp_call_function_mask +void kvm_smp_send_reschedule(int cpu); + +#define smp_send_reschedule kvm_smp_send_reschedule + #endif /* empty_zero_page isn't exported in all kernels */ Index: kvm-kmod/external-module-compat.c =================================================================== --- kvm-kmod.orig/external-module-compat.c +++ kvm-kmod/external-module-compat.c @@ -221,6 +221,58 @@ out: return 0; } +#include + +static void vcpu_kick_intr(void *info) +{ +} + +struct kvm_kick { + int cpu; + struct work_struct work; +}; + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) +static void kvm_do_smp_call_function(void *data) +{ + int me; + struct kvm_kick *kvm_kick = data; +#else +static void kvm_do_smp_call_function(struct work_struct *work) +{ + int me; + struct kvm_kick *kvm_kick = container_of(work, struct kvm_kick, work); +#endif + me = get_cpu(); + + if (kvm_kick->cpu != me) + smp_call_function_single(kvm_kick->cpu, vcpu_kick_intr, + NULL, 0); + kfree(kvm_kick); + put_cpu(); +} + +void kvm_queue_smp_call_function(int cpu) +{ + struct kvm_kick *kvm_kick = kmalloc(sizeof(struct kvm_kick), GFP_ATOMIC); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + INIT_WORK(&kvm_kick->work, kvm_do_smp_call_function, kvm_kick); +#else + INIT_WORK(&kvm_kick->work, kvm_do_smp_call_function); +#endif + + schedule_work(&kvm_kick->work); +} + +void kvm_smp_send_reschedule(int cpu) +{ + if (irqs_disabled()) { + kvm_queue_smp_call_function(cpu); + return; + } + smp_call_function_single(cpu, vcpu_kick_intr, NULL, 0); +} #endif /* manually export hrtimer_init/start/cancel */