Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp873076yba; Wed, 24 Apr 2019 10:59:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9b5Ml01m263rqmxXbHHSc3/CJF6qowppebVEi8qrpop4vTTLozZgJv8aq2OzmqfPA3L6F X-Received: by 2002:a63:f115:: with SMTP id f21mr31735896pgi.65.1556128789280; Wed, 24 Apr 2019 10:59:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556128789; cv=none; d=google.com; s=arc-20160816; b=FfbkH0nZ9/1hsBhUaTXo8QIuEAr9RAPpaen407/i2TvyDi6RHYnq8qgEkTbMPlJ7SM JUM+00jYR3QmQfR/vaGBGNUrr8sSXt+v1hz9qXAMDA0HSrCR8jxKfBwMVyFwyTGhxgPw umY8/JsTfZVqIkh4Fg/bO4HS4NRbo5ABLbB5RWeKMFH4+5pOfp3XLRAIKhDFQSuDySlw KAKpS61ItCUrObSKSS7T40JGsA4t8MebN15x0bVCwz8ycqx2YBrZPScMMaeV7WXdBpmc LpBNgGuDT3W7Ahr8Kp/9XeY7+lO9/ajoM0JHeozvec44jaz2zxT/ru2PJFfcJ13f6weN 6h3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yBb1i6ZLGILk2KLIv/1yI4d11HaGMceRd22Hqzr6V1M=; b=1E3lLwtomrGQ9agdlGxsC3pxicDfEdwe7FGjGvUUk7Ol8MXriU5zPhYjh/tRDOIwaa uAXwB/zRbO4khgPkbFnx/vzHJWw3QaWq+cYmb1p6H39Nx+TFT7NFGbxN8g2JX4zL9+5V KPvqaVdAK7hVYndPsVSSPBXBZrWjwR09EZSb6SZivVpqG7AbHbBSYt/V//b7j57EKGp7 nyFRcLw0CEIKcQC285WH4o2UC8mxYQehhJSnbQuqd5IdWQ68bpJWxBduMI8Zx64i7qtj SJJLiDbgfp/JXJFUFE+b79JrxNuEzd4eqldgQb/xUfk0iJlTuY3WISEUH1ATfNGTTEfy DBdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gIWNTnCl; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cn16si20377974plb.174.2019.04.24.10.59.33; Wed, 24 Apr 2019 10:59:49 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=gIWNTnCl; 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 S2391146AbfDXR57 (ORCPT + 99 others); Wed, 24 Apr 2019 13:57:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:51296 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390023AbfDXRZY (ORCPT ); Wed, 24 Apr 2019 13:25:24 -0400 Received: from localhost (62-193-50-229.as16211.net [62.193.50.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 745BA205ED; Wed, 24 Apr 2019 17:25:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556126723; bh=kZzlM+teg2cU093if+vR6a5sFUxlD7aQx2guqyJVss8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gIWNTnClY8DS9gSfNCGRdW/j3XS5QmuOAOQPPiVsjbIP5hUg+lkGrRQh0uwpyE0Ox N3SbADnqm9t7CnncpU+x7qZJRYtCOOhZrxufBIVWH/IC5l7obQOgrCiaMvPwhnfo+j tAZT7z/0mpkGjJ9VqLmHM4hdcSu6APz0aSNyI4Zo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kim Phillips , Alexander Shishkin , Arnaldo Carvalho de Melo , Borislav Petkov , "H. Peter Anvin" , Janakarajan Natarajan , Jiri Olsa , Linus Torvalds , =?UTF-8?q?Martin=20Li=C5=A1ka?= , Namhyung Kim , Peter Zijlstra , Pu Wen , Suravee Suthikulpanit , Thomas Gleixner , Ingo Molnar Subject: [PATCH 4.9 37/44] perf/x86/amd: Add event map for AMD Family 17h Date: Wed, 24 Apr 2019 19:10:15 +0200 Message-Id: <20190424170900.511642990@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170839.924291114@linuxfoundation.org> References: <20190424170839.924291114@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kim Phillips commit 3fe3331bb285700ab2253dbb07f8e478fcea2f1b upstream. Family 17h differs from prior families by: - Does not support an L2 cache miss event - It has re-enumerated PMC counters for: - L2 cache references - front & back end stalled cycles So we add a new amd_f17h_perfmon_event_map[] so that the generic perf event names will resolve to the correct h/w events on family 17h and above processors. Reference sections 2.1.13.3.3 (stalls) and 2.1.13.3.6 (L2): https://www.amd.com/system/files/TechDocs/54945_PPR_Family_17h_Models_00h-0Fh.pdf Signed-off-by: Kim Phillips Cc: # v4.9+ Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Borislav Petkov Cc: H. Peter Anvin Cc: Janakarajan Natarajan Cc: Jiri Olsa Cc: Linus Torvalds Cc: Martin Liška Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Pu Wen Cc: Suravee Suthikulpanit Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Fixes: e40ed1542dd7 ("perf/x86: Add perf support for AMD family-17h processors") [ Improved the formatting a bit. ] Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- arch/x86/events/amd/core.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) --- a/arch/x86/events/amd/core.c +++ b/arch/x86/events/amd/core.c @@ -113,22 +113,39 @@ static __initconst const u64 amd_hw_cach }; /* - * AMD Performance Monitor K7 and later. + * AMD Performance Monitor K7 and later, up to and including Family 16h: */ static const u64 amd_perfmon_event_map[PERF_COUNT_HW_MAX] = { - [PERF_COUNT_HW_CPU_CYCLES] = 0x0076, - [PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0, - [PERF_COUNT_HW_CACHE_REFERENCES] = 0x077d, - [PERF_COUNT_HW_CACHE_MISSES] = 0x077e, - [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c2, - [PERF_COUNT_HW_BRANCH_MISSES] = 0x00c3, - [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x00d0, /* "Decoder empty" event */ - [PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = 0x00d1, /* "Dispatch stalls" event */ + [PERF_COUNT_HW_CPU_CYCLES] = 0x0076, + [PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0, + [PERF_COUNT_HW_CACHE_REFERENCES] = 0x077d, + [PERF_COUNT_HW_CACHE_MISSES] = 0x077e, + [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c2, + [PERF_COUNT_HW_BRANCH_MISSES] = 0x00c3, + [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x00d0, /* "Decoder empty" event */ + [PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = 0x00d1, /* "Dispatch stalls" event */ +}; + +/* + * AMD Performance Monitor Family 17h and later: + */ +static const u64 amd_f17h_perfmon_event_map[PERF_COUNT_HW_MAX] = +{ + [PERF_COUNT_HW_CPU_CYCLES] = 0x0076, + [PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0, + [PERF_COUNT_HW_CACHE_REFERENCES] = 0xff60, + [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c2, + [PERF_COUNT_HW_BRANCH_MISSES] = 0x00c3, + [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x0287, + [PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = 0x0187, }; static u64 amd_pmu_event_map(int hw_event) { + if (boot_cpu_data.x86 >= 0x17) + return amd_f17h_perfmon_event_map[hw_event]; + return amd_perfmon_event_map[hw_event]; }