Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1079242ybm; Wed, 27 May 2020 15:49:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrBOlI3LkntPS/p8FicFj+6rKE6QecJY3PfLiYTsDdRwJWecDcWIlcAO5XnB4s0xpkmZmf X-Received: by 2002:a17:906:edbd:: with SMTP id sa29mr555639ejb.128.1590619793339; Wed, 27 May 2020 15:49:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590619793; cv=none; d=google.com; s=arc-20160816; b=tpz7zPRVG4sy1dcR65/MXgc8GBuEUHHE6y7eUBsjC983SHKlRt2XQKEC5gm3Xu1oAb 7NgLrAABHMhM8tadExvgr5tFgJcv+F9LRQpSl3N+FZAiEARYUgu3exmRciYoDndvnYcK z5/Qpoj7TyxkVFE/2gmCV9iqCwqe3RmZYLdwI9FFEBMLSkr8jY7DK9maodVQIUpxcQur 3qE7/FNab2xC1GII+J2bgyWdBJUURT3zsGFcYVm2QOpGIvtMrE78l/vUKXKaJ5qicnRK QDDPdKmWgzG+dxx/JqgWNdB6KFVfFmBVxnBBYFZNY8D8XIhXei7qgsP7d6Tbrlt+aoIk REnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=YQlMleJvTCYdzPc5tUzXYuVHdCb2672LVpK+yCo0EI8=; b=YABTkeGTJuBfoOiVtyQKNAZyc3F9qDtITlfsz7hvV9CslrsHGMUo4he4vvMH/PCAR5 evGwNO8oQvjbnYIHKw2Wim0RAY5aVD4pZ6abSBGenf6kogZ6gZbWMbCjaqNGXs5T3+R2 rtDVr/tJM0m+mCOEBWYHvRW+QYmlWriVD1NBXihvJWbABUVRup+89pYpveSMi+q+h/Nl G+mX0zrQQmf1zL34RiGmpz4Hc3GXh5IRAMWSsa9Tg252aAxc8wv8KqpDw1ASVzxdSCEO 9UhrzouLwnwSMY86d9ltl8WCLSl0Re0s7ql8j/d//eNkaD5fgq4s8s3JuU9N/tv54LJ6 A9ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=KIt1yYkf; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sd5si2723796ejb.194.2020.05.27.15.49.30; Wed, 27 May 2020 15:49:53 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=KIt1yYkf; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726373AbgE0WrJ (ORCPT + 99 others); Wed, 27 May 2020 18:47:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725836AbgE0WrJ (ORCPT ); Wed, 27 May 2020 18:47:09 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B4B4C08C5C1 for ; Wed, 27 May 2020 15:47:08 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id m10so858055ybk.7 for ; Wed, 27 May 2020 15:47:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=YQlMleJvTCYdzPc5tUzXYuVHdCb2672LVpK+yCo0EI8=; b=KIt1yYkfDoujQU/q2+6yUL12rwYUtycfMzefXGKvpV1scm516Y2Er7P4WL//vv7Oby MbssnS7TWdNVjjLcJ/iEHXYhCAz5LZ+IqwmoaHNyZ0uIn3y39Ez4ZS6vMeB2jRQAJjYZ tR9WFXGeV/UZsOeQw4TohrdYRu1geha6vHMYsl7qiMRW5IB2v8tDVE01Z5aW8AkihhR1 nmw3/VDAXd0cCMpoNbCTMF85apYM1K4Qie1t+B34E3naqC5oGX2vxtPiYIQRrBe8c1V3 ttfC6Nxl2eV0EwI8etkQ9Pj4MPsZIDjH2v2111lEw191NGKk1GgiZKs27yrb8M+nfhMW cn9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=YQlMleJvTCYdzPc5tUzXYuVHdCb2672LVpK+yCo0EI8=; b=kSpHM/O8F1zt3frmmaSD7cKSi+WxZNiqit6H+vaq8B8cm5cErZd1fEfuHw5X5enZMe OoexlDNwwGbD8yt7g0VDTNAvhskQDR0D4Q6vREL4qrwprHH3BiKZy1ZDo25uTE94gqPg T1TTsgUdxW/L9Fh6TUP8xdMFykV1jfrIB1xUCe5HvHAEVqU9oRg3ahfpbCS0iFpVDfdg PkUu7NgA6jaGV1o95LCE2M7WkHFdwQr6S+LJYqODbUwxt2rgyf1Smnhhjuoh5rAQ6TG9 TD5AUsbsATwtf/9gvrctn3KvKrBtQkxGU0uWMxWn5gowe4Gr4wMfot6nbAwJyw1hClOT uX1Q== X-Gm-Message-State: AOAM532iyEf1ueqA9fAOfcZA9mZFLsXHPLEFIZg3NkEP3sDoornEhV7v rmFSwN4vLlue95bJz626G9mEZC1AV11UJITul0lkWd7Ww6g7dXyLSgfDAGuilsczsVAaNDX4mh5 0aYB1wJTPWHgsqP6zge5s900Oh2rh2HzefJ0Y1LpEl18rGeRNfGV6FYM5bVOp6D76nf1Aqd3O X-Received: by 2002:a25:35d5:: with SMTP id c204mr782416yba.292.1590619627706; Wed, 27 May 2020 15:47:07 -0700 (PDT) Date: Wed, 27 May 2020 15:46:54 -0700 Message-Id: <20200527224659.206129-1-eranian@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.rc0.183.gde8f92d652-goog Subject: [PATCH v2 0/5] perf/x86/rapl: Enable RAPL for AMD Fam17h From: Stephane Eranian To: linux-kernel@vger.kernel.org Cc: peterz@infradead.org, mingo@elte.hu, irogers@google.com, kim.phillips@amd.com, jolsa@redhat.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch series adds support for AMD Fam17h RAPL counters. As per AMD PPR, Fam17h support Package RAPL counters to monitor power usage. The RAPL counter operates as with Intel RAPL. As such, it is beneficial to share the code. The series first moves the rapl.c file to common perf_events x86 and then adds the support. From the user's point of view, the interface is identical with /sys/devices/power. The energy-pkg event is the only one supported. $ perf stat -a --per-socket -I 1000 -e power/energy-pkg/ In V2, we integrated Peter's comments: - keep the same CONFIG_PERF_EVENTS_INTEL_RAPL for both Intel and AMD support - msr is unsigned int - cleanup initialization of the *_rapl_msrs[] arrays In particular, we split the patch some more to clearly identify the changes. We flip the visibility logic to work around the behavior of perf_msr_probe(). We improve that function to handle msrs[] array with unpopulated entries. This help RAPL on AMD, because only one MSR (PKG) is define. That way we can initialize the amd_rapl_msrs[] array just with that entry. But because we prefer having the same encoding for the same RAPL event between AMD and Intel this means, we need to handle unpopulated entries in the array and in perf_msr_probe() which is what patch 4 does. Signed-off-by: Stephane Eranian Stephane Eranian (5): perf/x86/rapl: move RAPL support to common x86 code perf/x86/rapl: refactor code for Intel/AMD sharing perf/x86/rapl: flip logic on default events visibility perf/x86: make perf_probe_msr() more robust and flexible perf/x86/rapl: add AMD Fam17h RAPL support arch/x86/events/Kconfig | 6 +-- arch/x86/events/Makefile | 1 + arch/x86/events/intel/Makefile | 2 - arch/x86/events/probe.c | 13 ++++++ arch/x86/events/{intel => }/rapl.c | 67 ++++++++++++++++++++++++++---- arch/x86/include/asm/msr-index.h | 3 ++ 6 files changed, 78 insertions(+), 14 deletions(-) rename arch/x86/events/{intel => }/rapl.c (92%) -- 2.27.0.rc0.183.gde8f92d652-goog