From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [v3 23/26] KVM: Update Posted-Interrupts Descriptor when vCPU is preempted Date: Wed, 17 Dec 2014 18:11:00 +0100 Message-ID: <5491B924.3090200@redhat.com> References: <1418397300-10870-1-git-send-email-feng.wu@intel.com> <1418397300-10870-24-git-send-email-feng.wu@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: "iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org" , "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , KVM list , Eric Auger To: "Wu, Feng" , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org" , Gleb Natapov , Paolo Bonzini , "dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org" , "joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org" , Alex Williamson , public-jiang.liu-VuQAYsv1563Yd54FQh9/CA-wOFGN7rlS/M9smdsby/KFg@public.gmane.org Return-path: In-Reply-To: <1418397300-10870-24-git-send-email-feng.wu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org List-Id: kvm.vger.kernel.org On 12/12/2014 16:14, Feng Wu wrote: > + if (irq_remapping_cap(IRQ_POSTING_CAP)) { > + struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu); > + struct pi_desc old, new; > + unsigned int dest; > + > + memset(&old, 0, sizeof(old)); > + memset(&new, 0, sizeof(new)); This is quite expensive. Just use an u64 for old_control and new_control, instead of a full struct. > > + pi_clear_sn(&new); This can be simply new.sn = 0. It does not need atomic operations. Same in patch 24 (if needed at all there---see the reply there). > > + if (irq_remapping_cap(IRQ_POSTING_CAP)) { > + struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu); > + struct pi_desc old, new; > + > + memset(&old, 0, sizeof(old)); > + memset(&new, 0, sizeof(new)); > + Here you do not need old/new at all because... > + if (vcpu->preempted) { > + do { > + old.control = new.control = pi_desc->control; > + pi_set_sn(&new); > + } while (cmpxchg(&pi_desc->control, old.control, > + new.control) != old.control); this can do pi_set_sn directly on pi_desc, without the cmpxchg. Paolo