From patchwork Fri Aug 17 16:34:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Calvin Walton X-Patchwork-Id: 10569199 X-Patchwork-Delegate: lenb@kernel.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80A9313B6 for ; Fri, 17 Aug 2018 16:35:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 762912BB3D for ; Fri, 17 Aug 2018 16:35:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AB302BB70; Fri, 17 Aug 2018 16:35:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1885C2BB3D for ; Fri, 17 Aug 2018 16:35:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727854AbeHQTjG (ORCPT ); Fri, 17 Aug 2018 15:39:06 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:34708 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727817AbeHQTjF (ORCPT ); Fri, 17 Aug 2018 15:39:05 -0400 Received: by mail-it0-f67.google.com with SMTP id d70-v6so1998389ith.1 for ; Fri, 17 Aug 2018 09:35:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kepstin.ca; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=u1TrFWHy02RZ2+FgmBn2A1MObXh+m/iSNWFN4bbBlXw=; b=PE67LQCXGL4IZ06VI91G+g/0Lelh/CEpcUYQ/bnXDiU0DaPueS1ME9sxfGQF99qM67 W292JU9FCbZJcCqD/pO6lP1mBIZNLR9fXmxmxffda4ZUelQatNAJ8uEPgNzaikAUJe3X eGkr1Aa/reIsrIt9VTVxGc9EiIK0Q+9IH/NeM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=u1TrFWHy02RZ2+FgmBn2A1MObXh+m/iSNWFN4bbBlXw=; b=RYJ68F/KQjd+WjJlePKitdedpDQZUJrUnqeBOh8r2SnV2/efVM7NB/nduy3+326ixA jdD6rg32qqMIK+aE3k64Ok2e5TV90sJoEGQYCCN8TpNOYERS4aopfta2ckBze774tnOf DaWs89zPVW5+D+9Vkd81nM+aWzVYFjphtJjNEA7OEtOsQwrqQuy92hJ8f84NRg9MYUdQ lgWZFO2+1mJgfV45/d1D0DWF6Rd1kEGz9sdnnR0syLKQKivZ8uWWPt+acyjRj3lfQHQB AWet4nQ0wf1q5tadBz2An5peS/gGZ4N7gArNEvh+EjVPVSp0gw+EjhqjQsQfrfWc2sMf cQJQ== X-Gm-Message-State: AOUpUlH80N//QHSe//8dmnsf3PbCXuDXIJewyLv8MxgdaNQlvJgpPvW+ e9kuJqNYfolCw2f9jXofMGkpBg== X-Google-Smtp-Source: AA+uWPxPk2XeW2Sd4tY5oTpYS4chdb0TazMACLPHqYl1Rq4Uegio1mOA5SvHn/eI+lfgMhiPY+jFFA== X-Received: by 2002:a24:b54b:: with SMTP id j11-v6mr25988301iti.79.1534523703029; Fri, 17 Aug 2018 09:35:03 -0700 (PDT) Received: from fuko.kepstin.ca ([2001:470:b3f4::561]) by smtp.gmail.com with ESMTPSA id e140-v6sm1947974itc.24.2018.08.17.09.35.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Aug 2018 09:35:02 -0700 (PDT) From: Calvin Walton To: Len Brown , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Calvin Walton Subject: [PATCH v3 2/2] [WIP] tools/power turbostat: Also read package power on AMD F17h (Zen) Date: Fri, 17 Aug 2018 12:34:42 -0400 Message-Id: <20180817163442.10065-3-calvin.walton@kepstin.ca> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180817163442.10065-1-calvin.walton@kepstin.ca> References: <20180817163442.10065-1-calvin.walton@kepstin.ca> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The package power can also be read from an MSR. It's not clear exactly what is included, and whether it's aggregated over all nodes or reported separately. It does look like this is reported separately per CCX (I get a single value on the Ryzen R7 1700), but it might be reported separately per- die (node?) on larger processors. If that's the case, it would have to be recorded per node and aggregated for the socket. Note that although Zen has these MSRs reporting power, it looks like the actual RAPL configuration (power limits, configured TDP) is done through PCI configuration space. I have not yet found any public documentation for this. Signed-off-by: Calvin Walton --- tools/power/x86/turbostat/turbostat.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index 89d4e2e75774..675c894b8595 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -1973,6 +1973,11 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p) return -16; p->rapl_dram_perf_status = msr & 0xFFFFFFFF; } + if (do_rapl & RAPL_AMD_F17H) { + if (get_msr(cpu, MSR_PKG_ENERGY_STAT, &msr)) + return -13; + p->energy_pkg = msr & 0xFFFFFFFF; + } if (DO_BIC(BIC_PkgTmp)) { if (get_msr(cpu, MSR_IA32_PACKAGE_THERM_STATUS, &msr)) return -17; @@ -3986,10 +3991,13 @@ void rapl_probe_amd(unsigned int family, unsigned int model) switch (family) { case 0x17: /* Zen, Zen+ */ do_rapl = RAPL_AMD_F17H | RAPL_PER_CORE_ENERGY; - if (rapl_joules) + if (rapl_joules) { + BIC_PRESENT(BIC_Pkg_J); BIC_PRESENT(BIC_Cor_J); - else + } else { + BIC_PRESENT(BIC_PkgWatt); BIC_PRESENT(BIC_CorWatt); + } break; default: return;