From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH stub] kvm: caching API for interrupts Date: Mon, 30 Jul 2012 11:34:23 +0300 Message-ID: <5016470F.5000101@redhat.com> References: <20120729200058.GA13557@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: "Michael S. Tsirkin" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:64069 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752024Ab2G3Ie1 (ORCPT ); Mon, 30 Jul 2012 04:34:27 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6U8YRM5023755 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 30 Jul 2012 04:34:27 -0400 In-Reply-To: <20120729200058.GA13557@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 07/29/2012 11:00 PM, Michael S. Tsirkin wrote: > I've been looking at adding caching for IRQs so that we don't need to > scan all VCPUs on each interrupt. One issue I had a problem with, is > how the cache structure can be used from both a thread (to fill out the > cache) and interrupt (to actually send if cache is valid). > > For now just added a lock field in the cache so we don't need to worry > about this, and with such a lock in place we don't have to worry about > RCU as cache can be invalidated simply under this lock. > > For now this just declares the structure and updates the APIs > so it's not intended to be applied, but just to give you > the idea. > > Comments, flames wellcome. I hope you aren't expecting any of the latter. > > +struct kvm_irq_cache { > + spinlock_t lock; > + bool valid; > + struct kvm_vcpu *dest; > + /* For now we only cache lapic irqs */ > + struct kvm_lapic_irq irq; > + /* Protected by kvm->irq_cache_lock */ > + struct list_head list; > +}; > + Why an external structure? Why not add something to kvm_kernel_irq_routing_entry? It is already protected by rcu. The atomic context code could look like this: if (kire->cache.valid) { kvm_apic_set_irq(kire->cache.vcpu, &kire->cache.irq); return; } queue_work(process_irq_slowpath); The slow path tries to fills the cache, and processes the interrupt in any case. -- error compiling committee.c: too many arguments to function