Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2001854pxj; Wed, 19 May 2021 20:21:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4L1Aa/WWxalEDqk8ehPzLw6cdBGAjuHK6xfpG9ebBu3NLXbr3I2L/zbx/+jabsDiuJEhi X-Received: by 2002:a05:6402:1207:: with SMTP id c7mr2571197edw.387.1621480905484; Wed, 19 May 2021 20:21:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621480905; cv=none; d=google.com; s=arc-20160816; b=npYc+wIFiSRPW9EqwfPfaZ+nIjMzmtpgHCo3xfu9GWsuJah9k8zooTvkZDxMKvgfMa iAEdCe0WjXK2NMJAwBW/ZI+JCbm04GnbqiEk9EME02BA2HWuo659jwNuzRqQ/H6hIpzg zaLAAfpCES2DVIQUXQNwuCwQDV0OR+bnxYASioyFsXLVY7iE06LD3D2MRfks4K0utq1a Yqx8SY8JnEb/Eci1kDGdNW6sdb0WqR1MBoUmfXs1kMFampRSzjBV5MQzZH8JZtBnXQkU bEnHCs4EAZ/i3xvRJ9GJs+wUZtX0wWbtFEn7OVF+fkBiPHFAYqqhkpYaJ6aZY6IfAzkV dOmw== 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 :ironport-sdr:ironport-sdr; bh=KhYCheOcbkUVdkWmMNqXwBjcBCDGN/8orM1f5uLON8o=; b=YY22fGfYp+/kwPAikNajB0QsK4v+DkDQJpZouSiIRM+n54ILC8WtamH+neSN1KPkuY VA5HdKl00z4S2FATKnoq0Q9P9+nkNJ/wSsru983CYsW1eYIMAxX6itcJtoi9b5Xs2Rrr XnZuM/KRHq/Wc96KqdbzPAHZZvKYQuLb6tjIWzsq4CQZ+hQIwxUjkNWmJ2AGfwylmUQQ MgKvvJMQvMu+VLew8gHUZ6UFD8q30KsVSgD3/sUJsCUA4B9footNG8g/hYkPr05ua8Ns 2lK6P+PTmzPer8osXQ8wqwEqUKS6ep0M7TE3+HmXWNYJKmh2UD/eAWRqbZbI9MalK/zO faJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t18si1012378edr.386.2021.05.19.20.21.21; Wed, 19 May 2021 20:21:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230369AbhETDSe (ORCPT + 99 others); Wed, 19 May 2021 23:18:34 -0400 Received: from mga05.intel.com ([192.55.52.43]:58855 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230350AbhETDSb (ORCPT ); Wed, 19 May 2021 23:18:31 -0400 IronPort-SDR: yJZl7AtVFn/7Ma3YjyMYndemxJLlDr9cqdmu5vRxIJ2Rl+wE725KT9MQ5cKUo0i8c4x9bPWM4a OwYONHrIvi/Q== X-IronPort-AV: E=McAfee;i="6200,9189,9989"; a="286659669" X-IronPort-AV: E=Sophos;i="5.82,313,1613462400"; d="scan'208";a="286659669" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2021 20:17:10 -0700 IronPort-SDR: wYzHUtD07xpb/Z5tvwmKVEb0jJVyC9FFZqjJk9AmnEw5Ivrtykt3SdQSNtM9b7+5FXWPv++7av eAKB5YCWEGTw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,313,1613462400"; d="scan'208";a="395527334" Received: from allen-box.sh.intel.com ([10.239.159.128]) by orsmga006.jf.intel.com with ESMTP; 19 May 2021 20:17:08 -0700 From: Lu Baolu To: Joerg Roedel Cc: ashok.raj@intel.com, kevin.tian@intel.com, jacob.jun.pan@intel.com, Jean-Philippe Brucker , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 11/11] iommu/vt-d: Add PRQ handling latency sampling Date: Thu, 20 May 2021 11:15:31 +0800 Message-Id: <20210520031531.712333-12-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210520031531.712333-1-baolu.lu@linux.intel.com> References: <20210520031531.712333-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The execution time for page fault request handling is performance critical and needs to be monitored. This adds code to sample the execution time of page fault request handling. Signed-off-by: Lu Baolu --- drivers/iommu/intel/svm.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index d3d028c6a727..6bff9a7f9133 100644 --- a/drivers/iommu/intel/svm.c +++ b/drivers/iommu/intel/svm.c @@ -24,6 +24,7 @@ #include #include "pasid.h" +#include "perf.h" #include "../iommu-sva-lib.h" static irqreturn_t prq_event_thread(int irq, void *d); @@ -838,8 +839,8 @@ static int prq_to_iommu_prot(struct page_req_dsc *req) return prot; } -static int -intel_svm_prq_report(struct device *dev, struct page_req_dsc *desc) +static int intel_svm_prq_report(struct intel_iommu *iommu, struct device *dev, + struct page_req_dsc *desc) { struct iommu_fault_event event; @@ -871,6 +872,12 @@ intel_svm_prq_report(struct device *dev, struct page_req_dsc *desc) event.fault.prm.flags |= IOMMU_FAULT_PAGE_REQUEST_PRIV_DATA; memcpy(event.fault.prm.private_data, desc->priv_data, sizeof(desc->priv_data)); + } else if (dmar_latency_enabled(iommu, DMAR_LATENCY_PRQ)) { + /* + * If the private data fields are not used by hardware, use it + * to monitor the prq handle latency. + */ + event.fault.prm.private_data[0] = ktime_to_ns(ktime_get()); } return iommu_report_device_fault(dev, &event); @@ -983,7 +990,7 @@ static irqreturn_t prq_event_thread(int irq, void *d) * If prq is to be handled outside iommu driver via receiver of * the fault notifiers, we skip the page response here. */ - if (intel_svm_prq_report(sdev->dev, req)) + if (intel_svm_prq_report(iommu, sdev->dev, req)) handle_bad_prq_event(iommu, req, QI_RESP_INVALID); trace_prq_report(iommu, sdev->dev, req->qw_0, req->qw_1, @@ -1172,6 +1179,9 @@ int intel_svm_page_response(struct device *dev, if (private_present) memcpy(&desc.qw2, prm->private_data, sizeof(prm->private_data)); + else if (prm->private_data[0]) + dmar_latency_update(iommu, DMAR_LATENCY_PRQ, + ktime_to_ns(ktime_get()) - prm->private_data[0]); qi_submit_sync(iommu, &desc, 1, 0); } -- 2.25.1