From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752867AbcGKTJk (ORCPT ); Mon, 11 Jul 2016 15:09:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33284 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751322AbcGKTJh (ORCPT ); Mon, 11 Jul 2016 15:09:37 -0400 Date: Mon, 11 Jul 2016 21:09:33 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Suravee Suthikulpanit Cc: joro@8bytes.org, pbonzini@redhat.com, alex.williamson@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, sherry.hurwitz@amd.com Subject: Re: [PART2 PATCH v3 10/11] svm: Introduce AMD IOMMU avic_ga_log_notifier Message-ID: <20160711190932.GB1375@potion> References: <1468231899-6987-1-git-send-email-suravee.suthikulpanit@amd.com> <1468231899-6987-11-git-send-email-suravee.suthikulpanit@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1468231899-6987-11-git-send-email-suravee.suthikulpanit@amd.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 11 Jul 2016 19:09:37 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2016-07-11 05:11-0500, Suravee Suthikulpanit: > From: Suravee Suthikulpanit > > This patch introduces avic_ga_log_notifier, which will be called > by IOMMU driver whenever it handles the Guest vAPIC (GA) log entry. > > Signed-off-by: Suravee Suthikulpanit > --- > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > @@ -928,6 +930,45 @@ static void svm_disable_lbrv(struct vcpu_svm *svm) > +static int avic_ga_log_notifier(int avic_tag, int vcpu_id, int vec) > +{ > + unsigned long flags; > + struct kvm_arch *ka = NULL; > + struct kvm_vcpu *vcpu = NULL; > + struct vcpu_svm *svm = NULL; > + > + pr_debug("SVM: %s: avic_tag=%#x, vcpu_id=%#x, vec=%#x\n", > + __func__, avic_tag, vcpu_id, vec); > + > + spin_lock_irqsave(&svm_vm_data_hash_lock, flags); > + hash_for_each_possible(svm_vm_data_hash, ka, hnode, avic_tag) { > + struct kvm *kvm = container_of(ka, struct kvm, arch); iommu_handle_ga_guest_nr_entry(), the caller, already performed a hash lookup to get ir_data. Cannot we store the vcpu pointer in ir_data, to avoid a second hash lookup and a vcpu lookup? Thanks.