Il 29/07/2012 22:29, Michael S. Tsirkin ha scritto:
> On Sun, Jul 29, 2012 at 10:03:45PM +0200, Paolo Bonzini wrote:
>> Il 29/07/2012 22:00, Michael S. Tsirkin ha scritto:
>>> 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.
>>
>> seqlock?
> 
> AFAIK seqlock only works if uses of stale data have no side-effects,
> this is not the case here. We could use an rwlock I think.

If you can inject an interrupt using stale data (I think so, that would
be a race in the guest between setting the route and getting the
interrupt) you can use seqlock to get a consistent copy of the entry:

  struct kvm_irq_cache ent, *list;

  rcu_read_lock();
  ...
  do {
    seq = read_seqcount_begin(&list->cnt);
    ent = *list;
  } while (!read_seqcount_retry(&list->cnt, seq));
  rcu_read_unlock();

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to