From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 2/6] kvm-s390: use hrtimer for clock wakeup from idle Date: Wed, 06 May 2009 15:10:07 +0300 Message-ID: <4A017E1F.6030908@redhat.com> References: <1241534358-32172-1-git-send-email-ehrhardt@linux.vnet.ibm.com> <1241534358-32172-3-git-send-email-ehrhardt@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, Christian Borntraeger , Carsten Otte To: ehrhardt@linux.vnet.ibm.com Return-path: Received: from mx2.redhat.com ([66.187.237.31]:45600 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759713AbZEFMKp (ORCPT ); Wed, 6 May 2009 08:10:45 -0400 In-Reply-To: <1241534358-32172-3-git-send-email-ehrhardt@linux.vnet.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: ehrhardt@linux.vnet.ibm.com wrote: > From: Christian Borntraeger > > This patch reworks the s390 clock comparator wakeup to hrtimer. The clock > comparator is a per-cpu value that is compared against the TOD clock. If > ckc <= TOD an external interrupt 1004 is triggered. Since the clock comparator > and the TOD clock have a much higher resolution than jiffies we should use > hrtimers to trigger the wakeup. This speeds up guest nanosleep for small > values. > > Since hrtimers callbacks run in hard-irq context, I added a tasklet to do > the actual work with enabled interrupts. > > > -void kvm_s390_idle_wakeup(unsigned long data) > +void kvm_s390_tasklet(unsigned long parm) > { > - struct kvm_vcpu *vcpu = (struct kvm_vcpu *)data; > + struct kvm_vcpu *vcpu = (struct kvm_vcpu *) parm; > > - spin_lock_bh(&vcpu->arch.local_int.lock); > + spin_lock(&vcpu->arch.local_int.lock); > vcpu->arch.local_int.timer_due = 1; > if (waitqueue_active(&vcpu->arch.local_int.wq)) > wake_up_interruptible(&vcpu->arch.local_int.wq); > - spin_unlock_bh(&vcpu->arch.local_int.lock); > + spin_unlock(&vcpu->arch.local_int.lock); > } > Why can't this be done from the timer context (after adjusting the locks)? -- Do not meddle in the internals of kernels, for they are subtle and quick to panic.