From patchwork Tue Dec 22 19:19:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 58957 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3434343lbb; Tue, 22 Dec 2015 11:31:14 -0800 (PST) X-Received: by 10.98.71.154 with SMTP id p26mr37966925pfi.65.1450812674416; Tue, 22 Dec 2015 11:31:14 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sp7si5878359pac.230.2015.12.22.11.31.14; Tue, 22 Dec 2015 11:31:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933588AbbLVTbK (ORCPT + 29 others); Tue, 22 Dec 2015 14:31:10 -0500 Received: from mail-bn1on0087.outbound.protection.outlook.com ([157.56.110.87]:41604 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932172AbbLVTaZ (ORCPT ); Tue, 22 Dec 2015 14:30:25 -0500 Received: from CY1PR12MB0444.namprd12.prod.outlook.com (10.163.91.22) by CY1PR12MB0853.namprd12.prod.outlook.com (10.164.70.11) with Microsoft SMTP Server (TLS) id 15.1.361.13; Tue, 22 Dec 2015 19:30:21 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Suravee.Suthikulpanit@amd.com; Received: from ssuthiku-cz-dev.amd.com (165.204.77.1) by CY1PR12MB0444.namprd12.prod.outlook.com (10.163.91.22) with Microsoft SMTP Server (TLS) id 15.1.361.13; Tue, 22 Dec 2015 19:30:19 +0000 From: Suravee Suthikulpanit To: , , , , CC: , , Suravee Suthikulpanit Subject: [PATCH 4/6] perf/amd/iommu: Introduce data structure for tracking prev count. Date: Tue, 22 Dec 2015 13:19:15 -0600 Message-ID: <1450811957-1511-5-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1450811957-1511-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1450811957-1511-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BY2PR04CA0009.namprd04.prod.outlook.com (10.255.247.19) To CY1PR12MB0444.namprd12.prod.outlook.com (25.163.91.22) X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0444; 2:xhoWYF0KlcOMNTb/W+lVx20IeLE3+dJwXrAySMZa8ireMcyYzT0DNjozjKjN61k/j3Ep9KnQmhxunUdRU7wC6wNlmbhJqqajHZ9PtjbrIBshRopiaSKUJ76RONLEaG44x3ECpqWVq+0wfuSuWhaNkQ==; 3:fcO156V/seCTDl6a6sxuam0wOXHXirooafOeJJFausZTKuHs+0Rhr8s2J6KjLv3Uu1942FBUDbaUcsYeiV1ahPsMGpNsIlPSfc5uMTaf5B6FwTdinGcRThEBRpZEUClG; 25:D0DQW1/ccTi6x1neMqSLMUFdQ+gzEQHzqVlDVCbD1HHwRwVOC29I63S5+HVnCs41+YPVaHUXCh2Ouug88iVGzSG+VaIJhvMJUrISHMPetGI4q8VemvczbHYJHMlR4gVflCoQwtQoDJQo6a7xSA2rAJfpSnNisrOVF8R+Zv+yB2bjDacUPX2iCHwBLeh7Vl3qaQGGqNeesm4TztQcb/AqzqjmBlZm3MMFctjVQOYbSy4mub9bXzEUMgAyvztsOIH/HTf5JvIm1fUPJddW1INllQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR12MB0444; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0444; 20:8mtfbnop6l8lzFP4MvHGAjq8s9X7xWCp5GqdbiOX1NJaqM8Wyhf3+RQVbLmD660fBsaojFujLzNIdVaz29RrCl9vqO8/muwQNS6V08ukgjix+F16qkEqkTt0guD6xMdipIZw5F+P6H5WipDjjqinp69jAhdJ7XtjKQ7cyzrvbk8weS5XCEHxiZZfh+/T/DS3JFVAcNy0gkw3pzuZOUfxdnGm0gEVHVIDTd2TyJj2V8HPcXb8VOfJntLKKRTUYPoROeb1iId1Paey0ZJvx2b9YceMbK3Qq7oVFOrXWn8kKEf/i0/J6dxGI59dC6R1jNJY1uVQPzVvsyGYHPZlQLCryifbBjz0yOj40GZqFQvt8WuA7CWDU1BkCTGDj8UIHejOMDkws0E5QGUZP4umRRzAvQY9hRebX4xbUGvK1UsBwX+J9SdQJAussYlm5VJUaQCP+kcjbbtUArVaQkjIEMreLTrvmM8Ebrvgj+FdBDiaqSYAkuOOQiAiJoj8zD1uMmQt; 4:1lpEjBb8BVwiE2vCoCZNwE9Iskyq4xpn91iRWqvSo2hsw91w63wMQcVksSF5GlKb1SlyzJK7yxboxboKkh/ZC3GDEGLdRPKjUm0dUpP7r6xY7R1sRj6Du5U4ZM3c4c/uuK666pw03FJFLVZ2LY5E5+63dY8FCxMA/zOYuIYCCZIeYgurCbTutAniOq+2/Gi3B8avwn1m3UFk1ksCYTXzAkTxmh1ojBDkEnWvjYPlGPVR46b9gpAmtX22jYpJ7+7WdiV7sm9okrFLqhm62qC0gpbLFEtWVEUniecin546dDUbTAwdQs+eVFpQUolgZc2vajZ95LH4H5iVfZOGGS5VN+48j83tDHchoyj/uxm0sw5lX8vjSyvtNfFNIrlu+xoTXoHEjyvJbeQLMFkqX7BglaeHyEBdR9uLt2L+QQKgYLo= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(3002001)(10201501046); SRVR:CY1PR12MB0444; BCL:0; PCL:0; RULEID:; SRVR:CY1PR12MB0444; X-Forefront-PRVS: 0798146F16 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(189002)(199003)(105586002)(101416001)(53416004)(19580395003)(50466002)(40100003)(19580405001)(106356001)(5001770100001)(42186005)(97736004)(47776003)(50986999)(87976001)(2201001)(3846002)(48376002)(5003940100001)(76176999)(229853001)(66066001)(86362001)(189998001)(2950100001)(6116002)(36756003)(5004730100002)(50226001)(77096005)(586003)(5008740100001)(1096002)(92566002)(122386002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0444; H:ssuthiku-cz-dev.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR12MB0444; 23:4Z2ztHAwHNFgAvrStiYTiCPmHqMrAXE5ZOpSnNqvZ?= =?us-ascii?Q?1CiYoUql/TZWFPWSmSIp8BfLzFTZ2ndcuXERfpSKY6jOGj2ABZTh8ZMHdCYb?= =?us-ascii?Q?uAGjwjnQJPeFIfPvn4SpB2Nl+WsSgf5WYTnhcGUCJrVyJjhMccnXmqlNJY7m?= =?us-ascii?Q?1QjTzwE3qcF1BPg7p9CsPFHmsixkFU5YH1qmGO0lkvRZewHoRwrRvZgFHQ4e?= =?us-ascii?Q?KTpFpb7bHiSM13JwZW03V47TeGhuTaa20dOFSvq/8WuHcTvujaVoNvhBowpR?= =?us-ascii?Q?n/DTKPVZwrp6w0f+DMXLST+JFCs6H/3w9+hb1CrJElMW970eaqxLu6GysiXY?= =?us-ascii?Q?o2tMEVK2S8vBUVmKdY6y71Wc0KT9MrSKqpwil6yJOer/peDiKs9cSMMxzr0S?= =?us-ascii?Q?z1rRZy0md6KAPnY1TPGa/lCG8M+AJqq+mJjGdCRaWdqU1nPVqtlMW5kfZVln?= =?us-ascii?Q?PI27tYaf/aSxSZgCYBOu4augZi6HAINcChez1KEwnAfqXNhuK1cFcNM/SkR3?= =?us-ascii?Q?36qFPFObqXyGLobjbM0udgFNP34snmGttLOUp8ydTyFCJMyzuZwjiXG7Msco?= =?us-ascii?Q?4noLt/9+xs0bST6QhpKWjEqdN5YDoTzfLHR10qAYaPw/oDAZrAUWGfCvai44?= =?us-ascii?Q?J3E4WYIMJNXLYI/jU9wyTIfPon8dgXhdGkYeHaE4Z8euWfxP4dwx/6H5pf85?= =?us-ascii?Q?U0zFeTPs0pyyQbGQj/8Tnngzq4i+cUq0c9BfX/rX3Z4p7gC1uhiNY2NmRosR?= =?us-ascii?Q?aYJW4ChqRZhuMTDPYL07yzKPmAnKqD4S1RejtrprfwD8lvKhDS8HU9ExV73M?= =?us-ascii?Q?/n6iYcvz76nUwsaYrAgJP7WQauRoIdtYJsO2n/8jnWciVR4DIL68QSAgljrG?= =?us-ascii?Q?Dzh+kxzxiwHlr263haR/6B88RYO4oJVKNnyZCFswCktoBthDAkbfMGYs3uao?= =?us-ascii?Q?k3PS5B7E2dedp9aQY6xHksJaxQR5Q1vNyrc6hEaIFF07eFOsfNYfgAXR8si2?= =?us-ascii?Q?nw=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0444; 5:TStNDQM49y9EDWU8Z+APNmOInlSK2CiABTySXHOB/p1ynABBySHp4ZqIN3ePF6dlB+hHEksfiGs6op6+3HcRXs7AmZcOjH9QtPCce1caSkChJ4o7Qorw4Bb/0QxvWjlVvOn1MHMQw2s2xPFR1uGyKg==; 24:5zIgAFzOzmyubeTBsMVAihZHUaTeU0/n1cWs/MVVKle/cNZsyPzTogB/yjmPIcp4YBFp2Rzj+NrnbIpXI11wAS34w9h5dcUBOkFi5THx4Bg=; 20:W8ml62XccfHiryOkIOD/CFWjJNJcWW/aivgnmGjj/SHnSY9GH/V94tR/yF2wcc0HLW5ID9062yCD2xiRe94/p6P+vr5fGWU2IwbTyFAfTow2+EwDIC1HV7QVz3OSV8ibw76eJa34Skx8yJoBn0NWZKhBbjhCWWoy/4S4eJHOio3XykImNm//Y7iZnh1PHo/XeGxsUtKz4VgHFsz+Gfnk6KILOWml+Cf3Ns3x5Q+N4fvoveg3Wj9CStw83UV7AdtN X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2015 19:30:19.4854 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0444 X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0853; 2:k1EJ6WyRcaRvgkKqb+TJw2rVxuAQK0kkaVhOXVm1lSYeDRxeO9tHIslkaiabzoDOKK7pZA506tk70dGIKJnhxBIBLijg28IoB2trUSOUZgTAxi08CrPgdCni+yoEPJg+baT3Uyi4gauvDtPDFRXtqQ==; 23:9Igq/NUIIaH05/6HpUxJbPqDbhQQAxaH865h69q+6a9QOhOJrOiivN2LU3DEW7CxXgreVlDf/nZ6J4LXiwfDOoeT1ujlwAppXVNqQy/rxIDMQlldbPB9N+KLSg4ylnDuV+Mc7WQsm8RYX75tCSaNR+RnaVdwi644nG3nkgnd808spE00R5PhZfO5ANPvtXIY X-OriginatorOrg: amd.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To enable AMD IOMMU PMU to support multiple IOMMUs, this patch introduces a new data structure, perf_amd_iommu.prev_cnts, to track previous counts of IOMMU performance counters in multi-IOMMU environment. Also, this patch allocates perf_iommu_cnts for internal use when manages counters. Signed-off-by: Suravee Suthikulpanit --- arch/x86/kernel/cpu/perf_event_amd_iommu.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c index e6d2485..99fcd10 100644 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c @@ -42,6 +42,7 @@ struct perf_amd_iommu { u64 cntr_assign_mask; raw_spinlock_t lock; const struct attribute_group *attr_groups[4]; + local64_t *prev_cnts; }; #define format_group attr_groups[0] @@ -126,6 +127,8 @@ static struct amd_iommu_event_desc amd_iommu_v2_event_descs[] = { { /* end: all zeroes */ }, }; +static u64 *perf_iommu_cnts; + /*--------------------------------------------- * sysfs cpumask attributes *---------------------------------------------*/ @@ -423,10 +426,14 @@ static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu) static __init void amd_iommu_pc_exit(void) { - if (__perf_iommu.events_group != NULL) { - kfree(__perf_iommu.events_group); - __perf_iommu.events_group = NULL; - } + kfree(__perf_iommu.events_group); + __perf_iommu.events_group = NULL; + + kfree(__perf_iommu.prev_cnts); + __perf_iommu.prev_cnts = NULL; + + kfree(perf_iommu_cnts); + perf_iommu_cnts = NULL; } static __init int _init_perf_amd_iommu( @@ -456,6 +463,17 @@ static __init int _init_perf_amd_iommu( perf_iommu->null_group = NULL; perf_iommu->pmu.attr_groups = perf_iommu->attr_groups; + perf_iommu->prev_cnts = kzalloc(sizeof(*perf_iommu->prev_cnts) * + (amd_iommu_get_num_iommus() * perf_iommu->max_banks * + perf_iommu->max_counters), GFP_KERNEL); + if (!perf_iommu->prev_cnts) + return -ENOMEM; + + perf_iommu_cnts = kzalloc(sizeof(*perf_iommu_cnts) * + amd_iommu_get_num_iommus(), GFP_KERNEL); + if (!perf_iommu_cnts) + return -ENOMEM; + ret = perf_pmu_register(&perf_iommu->pmu, name, -1); if (ret) { pr_err("perf: amd_iommu: Failed to initialized.\n");