Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1253305yba; Wed, 24 Apr 2019 18:26:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnuo4I9GzDQIY3ciGMRWIhZ0BDTbKdhoTRekufr1aaph5NLx1/fseY6gtcXXO/imlaFzat X-Received: by 2002:a65:424a:: with SMTP id d10mr33494720pgq.335.1556155587755; Wed, 24 Apr 2019 18:26:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556155587; cv=none; d=google.com; s=arc-20160816; b=Q/xg2PVR3JBpsjp0JQsiyfqu/eLhsPuEr40WVayCN1loLAA9q2CHkBVAJkCDBRw/MS nvh5+XF7Lz7TDfK98rxWpHPIurJ2P9lvkXnWXMAkzRErw6iIKEICn/LuHFW3LampcKNh c871HOGFeN80AddJHhK6uCNsn2v0lhP6SR8W4Y1rdz0RbWqRosna6azpN+OYAEqIZNcn KHMqICnPI74WJRT9wROqyMwkFsejINmcC7G14fjNGvm6ShKtjFzVWJ6pNMT0ACqGpIMt HP0XsJGFDvHz649ZB4I+Xj8iRyugdpik3VrWF+TCGtMtddlpRFaRrFju9z7zaLNOrJmq tP9A== 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=+QHJ1Afazj40N3obB4LsMwsmkplpc+xT7UdDIFPF4ZU=; b=Y3W0aVOWkmVTFr5osq7YpFFcIZuwjAs10tDshLWLgCcKALJjo0aK8Ton5XS7xmJnuI lhZpVqhkVG0h0Kei/P9kpbudTwd4eOLTPLBR84bJt1QQM5Z4FaUPRzfc8Bq9z+pMybLi k4/W37q0XlUrEd4NITQjkrpoPtuZIfC4SPo5uEU0vgxJV8kNWEjc2yaxLWhtWerpjxnj hBKPYS076RHCOmmY+ve5qbDVnfRPGDNS+srRGgwbtMznDUwKUDuIrZjQ8ufjSN7tL1N3 XHhqQdqITijV3FXO6PKTplFZyKA/hb5ZVBYgmfn0EcuJhh99ZSEtM1vm6lgYgKzdIbFX khfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kS9UmtEE; 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 q12si20546083plr.434.2019.04.24.18.26.09; Wed, 24 Apr 2019 18:26:27 -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=kS9UmtEE; 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 S2403840AbfDXRcK (ORCPT + 99 others); Wed, 24 Apr 2019 13:32:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:58720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390116AbfDXRcI (ORCPT ); Wed, 24 Apr 2019 13:32:08 -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 89C6D2077C; Wed, 24 Apr 2019 17:32:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556127127; bh=YE1EgZeukspEzv6MCxasg31Wtb1pIL9dwAGoNgFUUdE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kS9UmtEE1up20f7QoukbtW2yD/fpiBnNHG/x5cvwbxhXBZxgznct7CSq9Y2hz7nZ7 IE2w6KGCR9w4frUX4k65m0iCol0xyRanoPL/HTOIx6BSOfqZprrSSXbGk1sXWeXbN1 qvt6V3DXoybZUtz4WMmIELHC6wnSNJpg0BnEbc/w= 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.19 72/96] perf/x86/amd: Add event map for AMD Family 17h Date: Wed, 24 Apr 2019 19:10:17 +0200 Message-Id: <20190424170924.624388859@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170919.829037226@linuxfoundation.org> References: <20190424170919.829037226@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 @@ -117,22 +117,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]; }