From patchwork Fri Jan 15 08:56:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 73113 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o0F8uox8005708 for ; Fri, 15 Jan 2010 08:56:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751257Ab0AOI4r (ORCPT ); Fri, 15 Jan 2010 03:56:47 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752154Ab0AOI4r (ORCPT ); Fri, 15 Jan 2010 03:56:47 -0500 Received: from fmmailgate03.web.de ([217.72.192.234]:45899 "EHLO fmmailgate03.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751061Ab0AOI4q (ORCPT ); Fri, 15 Jan 2010 03:56:46 -0500 Received: from smtp05.web.de (fmsmtp05.dlan.cinetic.de [172.20.4.166]) by fmmailgate03.web.de (Postfix) with ESMTP id 7798D13C1DF9D; Fri, 15 Jan 2010 09:56:44 +0100 (CET) Received: from [88.65.253.164] (helo=[192.168.1.10]) by smtp05.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #314) id 1NVhz1-0000kb-00; Fri, 15 Jan 2010 09:56:43 +0100 Message-ID: <4B502DCA.5010203@web.de> Date: Fri, 15 Jan 2010 09:56:42 +0100 From: Jan Kiszka 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 MIME-Version: 1.0 To: paulmck@linux.vnet.ibm.com CC: Avi Kivity , Lucas Meneghel Rodrigues , KVM mailing list , Michael Goldish , Eduardo Habkost , Dor Laor Subject: Re: qemu-kvm.git build problem References: <1262025646.2774.16.camel@localhost.localdomain> <1263014581.2439.207.camel@localhost.localdomain> <4B4AF9D2.3080100@siemens.com> <4B4AFAD9.3010604@redhat.com> <4B4AFBC7.1020801@siemens.com> <4B4BC0F3.2010507@web.de> <20100112005118.GO6632@linux.vnet.ibm.com> <4B4C329F.4010301@web.de> <20100112135018.GE6807@linux.vnet.ibm.com> <4B4E6135.8030206@web.de> <20100114234827.GC9077@linux.vnet.ibm.com> In-Reply-To: <20100114234827.GC9077@linux.vnet.ibm.com> X-Enigmail-Version: 0.95.7 X-Sender: jan.kiszka@web.de X-Provags-ID: V01U2FsdGVkX18+Qfv6ra5r93JvUwqAC6kuQYwHlZJgu680D3jh nbmHoxdHjHBLzZg80u8lEN7lzTe8P5x5H2sYci2RlFoAg84eUQ Jky9FWm1Q= Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/srcu.c b/srcu.c index 985d627..841394d 100644 --- a/srcu.c +++ b/srcu.c @@ -399,13 +399,66 @@ void kvm_synchronize_srcu_expedited(struct srcu_struct *sp) } EXPORT_SYMBOL_GPL(kvm_synchronize_srcu_expedited); +static struct sched_param sync_thread_param = { + .sched_priority = MAX_RT_PRIO-1 +}; + +#ifdef CONFIG_HOTPLUG_CPU +#include + +static int cpu_callback(struct notifier_block *nfb, unsigned long action, + void *hcpu) +{ + int hotcpu = (unsigned long)hcpu; + struct task_struct *p; + + switch (action) { + case CPU_UP_PREPARE: + case CPU_UP_PREPARE_FROZEN: + p = kthread_create(kvm_rcu_sync_thread, hcpu, + "kvmsrcusync/%d", hotcpu); + if (IS_ERR(p)) { + printk(KERN_ERR "kvm: kvmsrcsync for %d failed\n", + hotcpu); + return NOTIFY_BAD; + } + kthread_bind(p, hotcpu); + sched_setscheduler(p, SCHED_FIFO, &sync_thread_param); + per_cpu(sync_thread, hotcpu) = p; + break; + case CPU_ONLINE: + case CPU_ONLINE_FROZEN: + wake_up_process(per_cpu(sync_thread, hotcpu)); + break; + case CPU_UP_CANCELED: + case CPU_UP_CANCELED_FROZEN: + if (!per_cpu(sync_thread, hotcpu)) + break; + /* Unbind so it can run. Fall thru. */ + kthread_bind(per_cpu(sync_thread, hotcpu), + cpumask_any(cpu_online_mask)); + case CPU_DEAD: + case CPU_DEAD_FROZEN: + p = per_cpu(sync_thread, hotcpu); + per_cpu(sync_thread, hotcpu) = NULL; + kthread_stop(p); + break; + } + return NOTIFY_OK; +} + +static struct notifier_block cpu_nfb = { + .notifier_call = cpu_callback +}; +#endif /* CONFIG_HOTPLUG_CPU */ + int kvm_init_srcu(void) { - struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 }; struct task_struct *p; int cpu; int err; + get_online_cpus(); for_each_online_cpu(cpu) { p = kthread_create(kvm_rcu_sync_thread, (void *)(long)cpu, "kvmsrcusync/%d", cpu); @@ -413,13 +466,19 @@ int kvm_init_srcu(void) goto error_out; kthread_bind(p, cpu); - sched_setscheduler(p, SCHED_FIFO, ¶m); + sched_setscheduler(p, SCHED_FIFO, &sync_thread_param); per_cpu(sync_thread, cpu) = p; wake_up_process(p); } +#ifdef CONFIG_HOTPLUG_CPU + register_cpu_notifier(&cpu_nfb); +#endif /* CONFIG_HOTPLUG_CPU */ + put_online_cpus(); + return 0; error_out: + put_online_cpus(); printk(KERN_ERR "kvm: kvmsrcsync for %d failed\n", cpu); err = PTR_ERR(p); kvm_exit_srcu(); @@ -430,6 +489,7 @@ void kvm_exit_srcu(void) { int cpu; + unregister_cpu_notifier(&cpu_nfb); for_each_online_cpu(cpu) if (per_cpu(sync_thread, cpu)) kthread_stop(per_cpu(sync_thread, cpu));