Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3594985rdh; Thu, 28 Sep 2023 17:21:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNL3xutWsKOVJaRelywuOVyKJycyQnM216uHGMfVLY6gF4IVzIKVyZw83ECi4+4Xv01TA6 X-Received: by 2002:a05:6830:1e66:b0:6b9:a926:4a12 with SMTP id m6-20020a0568301e6600b006b9a9264a12mr2772007otr.28.1695946874091; Thu, 28 Sep 2023 17:21:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695946874; cv=none; d=google.com; s=arc-20160816; b=StjrKBifWQbOYcNax+416cLoXaYjx7jXZO40pR+eKcR42vFWA0/EOqQjhvAxoNq1u7 SHYU2R9CYTH1RWqw4rLlO7/JJSeGjj8aiY+STFdyo4z1zUdsO0vZgbNwmeQFIaVBFmV1 CR46cfgABCjnzm3wAa1Ykvrguf1QiO5yWLqmzUfkvRVPvbmN4QR3Mg2AHooj02GG3Vl3 j6TYeovvTYQ0mJAiN29H7/kTL21r4ZXBkKm33Jci1i7sJWFZcnSSGYsbtLyWST9Oo76E iYQ4VjcvHFC1iONkqJADt9sNQtzt76Rv+lcARse4UtEjWMq3t5LnVKfmgKNeLfeSXCSL VqBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yyT2AmMvLLxljrFvJMSDRCezFgTSL0+kRV0V1GII1YQ=; fh=9LbWkm2mGYyT4VgR7tbmPx1+hF6afcdiHJr0enuOIz0=; b=vpxI8CEoQCu7+4keLWUAKOeN+dETZmv8zt4f5z8QatWpNMoiKnd4efmszCS0VvImNS ljb9+UprHH5ptYcyLWIzabcPDtXcSMG40m1kgUb7fSabF3mA9mcVh3MjuFfu8Ulw+ebF qtiYMP7QC206rE/4Z9UpYZwCssWuLTHv4hw7oMnrEowLhKOvIve7tyt+Fr6f9ApTdH/W Q8vPsH2HeIMe42Zy4zeMg5llUYeNBwWblVinKCofey2UYNJdXZJxJJNn/nVzZqyy24A5 BfeoMBYxyioFbCt58LzVbgEXpyq1x84KV/BYip8PAdxyxiKkJsKDeiGcS7CQovsdUbMF uPYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZGjROXmv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id k3-20020a633d03000000b00585a4fc83fbsi109312pga.255.2023.09.28.17.21.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 17:21:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZGjROXmv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 782438388901; Thu, 28 Sep 2023 08:06:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231634AbjI1PFr (ORCPT + 99 others); Thu, 28 Sep 2023 11:05:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231537AbjI1PFl (ORCPT ); Thu, 28 Sep 2023 11:05:41 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6B23F9 for ; Thu, 28 Sep 2023 08:04:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695913494; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yyT2AmMvLLxljrFvJMSDRCezFgTSL0+kRV0V1GII1YQ=; b=ZGjROXmvUa7ySlZMcZuEgJw7jwAVZA8duIl4TkUrIfVa5rUxaFpzO5k06p2mWP0H3ue6Ot ZOo/e/2Zr3nB5/D+6vqDyzfciN9rPKlgqJOdD0ZBm6IkAs9OcjDuvuNTF6QaqqwPUkHiRF fCfGDMMVBZOh/ZoZLITUNfcEQ2d+bp4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-195-0K3VyQymPgyYVl7SZgYxGA-1; Thu, 28 Sep 2023 11:04:50 -0400 X-MC-Unique: 0K3VyQymPgyYVl7SZgYxGA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 95190101A53B; Thu, 28 Sep 2023 15:04:48 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.141]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A8B540C6E76; Thu, 28 Sep 2023 15:04:45 +0000 (UTC) From: Maxim Levitsky To: kvm@vger.kernel.org Cc: Will Deacon , Borislav Petkov , Dave Hansen , Suravee Suthikulpanit , Thomas Gleixner , Paolo Bonzini , x86@kernel.org, Robin Murphy , iommu@lists.linux.dev, Ingo Molnar , Joerg Roedel , Sean Christopherson , "H. Peter Anvin" , linux-kernel@vger.kernel.org, Maxim Levitsky Subject: [PATCH 4/5] iommu/amd: skip updating the IRTE entry when is_run is already false Date: Thu, 28 Sep 2023 18:04:27 +0300 Message-Id: <20230928150428.199929-5-mlevitsk@redhat.com> In-Reply-To: <20230928150428.199929-1-mlevitsk@redhat.com> References: <20230928150428.199929-1-mlevitsk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 28 Sep 2023 08:06:36 -0700 (PDT) When vCPU affinity of an IRTE which already has is_run == false, is updated and the update also sets is_run to false, there is nothing to do. The goal of this patch is to make a call to 'amd_iommu_update_ga()' to be relatively cheap if there is nothing to do. Signed-off-by: Maxim Levitsky --- drivers/iommu/amd/iommu.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 95bd7c25ba6f366..10bcd436e984672 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -3774,6 +3774,15 @@ int amd_iommu_update_ga(int cpu, bool is_run, void *data) entry->hi.fields.destination = APICID_TO_IRTE_DEST_HI(cpu); } + + if (!is_run && !entry->lo.fields_vapic.is_run) { + /* + * No need to notify the IOMMU about an entry which + * already has is_run == False + */ + return 0; + } + entry->lo.fields_vapic.is_run = is_run; return modify_irte_ga(ir_data->iommu, ir_data->irq_2_irte.devid, -- 2.26.3