On Thursday 08 January 2009 21:54:41 Mike Day wrote:
> On 07/01/09 18:42 +0800, Sheng Yang wrote:
> > Using kvm_set_irq to handle all interrupt injection.
> >
> > Signed-off-by: Sheng Yang <[email protected]>
> > ---
> >
> > +static void gsi_dispatch(struct kvm *kvm, u32 gsi)
>
> ...
>
> > +           case IOAPIC_FIXED:
> > +                   for (vcpu_id = 0; deliver_bitmask != 0; vcpu_id++) {
> > +                           if (!(deliver_bitmask & (1 << vcpu_id)))
> > +                                   continue;
> > +                           deliver_bitmask &= ~(1 << vcpu_id);
> > +                           vcpu = ioapic->kvm->vcpus[vcpu_id];
> > +                           if (vcpu)
> > +                                   kvm_apic_set_irq(vcpu, vector,
> > +                                                   trig_mode);
> > +                   }
> > +                   break;
> > +           default:
> > +                   break;
> > +           }
>
> In cases such as the for() loop above, which are numerous in the
> patchset, I wonder if using bitops would be slightly better:
>
>               case IOAPIC_FIXED:
>                       while (deliver_bitmask != 0) {
>                               vcpu_id = ffs(deliver_bitmask);
>                               __clear_bit(vcpu_id - 1, &deliver_bitmask);
>                               vcpu = ioapic->kvm->vcpus[vcpu_id - 1];
>                               if (vcpu)
>                                       kvm_apic_set_irq(vcpu, vector,
>                                                        trig_mode);
>                       } ;
>
>
> I did a quick check and the second example compiles to a more
> consise set of assembler instructions. The current code uses bitops in
> cases like this.
>

Yes, that's what I did for bitmap changing in the following patches. Please 
refer to "[PATCH 10/10] KVM: bit ops for deliver_bitmap" I sent before.

-- 
regards
Yang, Sheng

> Mike

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

Reply via email to