[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <54CBA1F9.6070206@redhat.com>
Date: Fri, 30 Jan 2015 16:23:37 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: Radim Krčmář <rkrcmar@...hat.com>
CC: linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
Nadav Amit <namit@...technion.ac.il>,
Gleb Natapov <gleb@...nel.org>
Subject: Re: [PATCH 8/8] KVM: x86: simplify kvm_apic_map
On 30/01/2015 16:14, Radim Krčmář wrote:
> > > + case KVM_APIC_MODE_XAPIC_FLAT:
> > > + *cid = 0;
> > > + *lid = ldr & 0xff;
> > > + return true;
> > > + case KVM_APIC_MODE_XAPIC_CLUSTER:
> > > + *cid = (ldr >> 4) & 0xf;
> > > + *lid = ldr & 0xf;
> > > + return true;
> > > + case KVM_APIC_MODE_X2APIC:
> > > + *cid = ldr >> 16;
> > > + *lid = ldr & 0xffff;
> > > + return true;
> > > + }
>
>> > lid_bits = mode;
>> > cid_bits = mode & (16 | 4);
>> > lid_mask = (1 << lid_bits) - 1;
>> > cid_mask = (1 << cid_bits) - 1;
>> >
>> > *cid = (ldr >> lid_bits) & cid_mask;
>> > *lid = ldr & lid_mask;
> Would jump predictor fail on the switch? Or is size of the code that
> important? This code is shorter, but is going to execute far more
> operations, so I think it would be slower ... (And harder to read.)
Considering the additional comparisons for the switch, I don't think
it's going to execute far more operations...
Paolo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists