From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762379AbbA3PXr (ORCPT ); Fri, 30 Jan 2015 10:23:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59270 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752408AbbA3PXq (ORCPT ); Fri, 30 Jan 2015 10:23:46 -0500 Message-ID: <54CBA1F9.6070206@redhat.com> Date: Fri, 30 Jan 2015 16:23:37 +0100 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= CC: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Nadav Amit , Gleb Natapov Subject: Re: [PATCH 8/8] KVM: x86: simplify kvm_apic_map References: <1422568135-28402-1-git-send-email-rkrcmar@redhat.com> <1422568135-28402-9-git-send-email-rkrcmar@redhat.com> <54CB4C5C.6090706@redhat.com> <20150130151442.GC27414@potion.redhat.com> In-Reply-To: <20150130151442.GC27414@potion.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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