Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3350018pxb; Tue, 20 Apr 2021 06:29:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuI0Jzt2n7ZwVsXH1VOlw9ew4dMUG3wX0s3EPPvC2Y6IVZUsKNFTyy68GKQTKETppmqZvR X-Received: by 2002:a17:902:fe8c:b029:ec:a2ef:4e3f with SMTP id x12-20020a170902fe8cb02900eca2ef4e3fmr11415375plm.36.1618925377454; Tue, 20 Apr 2021 06:29:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618925377; cv=none; d=google.com; s=arc-20160816; b=mDMhdmeqvw20gdtITC33QYorDXB2sePL7W9PjBsTW5uSb6V5nm4kowZDUQQWI1lw1E 38ThP4LbyRYREAYu5fvKCp20oFCsUrOQKtp6tr/lFL4n2IZ/fLgst2RutBTaaPCKgT+c 2uItSoeQJ56LU7gYg7GcnDwa0/I+PcaVRetXLTAiIBWKhbCHLk8v8ZoErYuSDbzINSJn s+v63A+eSpdVdkrsAzDila27oAKJGwOU8f5CzOa5TjLV2ZN9rbTV1KJTwgtllmF5N6KV 9+ZeK/wC9ujrhRY2889rKyNmNKWbdE/GPnzR6JRpZh53J9DB6pgF3iQX8nOmTTIw+RYi TA8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=J/YrRJCz3Qya2ecpGn1yqFyHTDzbSdU1ZISqo4g1zcw=; b=Opj/4/5gCivrcah598/6+iCyBr8O+o+gNaMMuhU1o7RSWF6PfIX+37LSSJgHQ9uUvp EIrcOTavZO1NIwZusTQFfKiAMwfK9d3oaHacx6ucwo8gXCiC0X8e/Da9790ldMIaN5H8 G4iR0RrZGhmvr79fMU/khwTiVQomFQq0N3KXeO9hwhcIpLHhDn7sIb9klxuzBVDUosEv UD9xCxXcEwXZVnsP1PBCQu48nqzszfnQzL0gjk3TKWFczpS1N9JbIH09rB/SPhluzCB5 pg3nP2LZ6upiFRYuATI5OB20o9+Bap2+NxxnQU6X9vR/xE7FnOCrLKpIUNZtn6wk5kUg cRrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kepstin.ca header.s=google header.b="odK1x/sV"; 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=NONE sp=REJECT dis=NONE) header.from=kepstin.ca Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w5si3047216pjh.156.2021.04.20.06.29.25; Tue, 20 Apr 2021 06:29:37 -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=@kepstin.ca header.s=google header.b="odK1x/sV"; 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=NONE sp=REJECT dis=NONE) header.from=kepstin.ca Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232094AbhDTN2m (ORCPT + 99 others); Tue, 20 Apr 2021 09:28:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232142AbhDTN2l (ORCPT ); Tue, 20 Apr 2021 09:28:41 -0400 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6D3AC06174A for ; Tue, 20 Apr 2021 06:28:09 -0700 (PDT) Received: by mail-qt1-x835.google.com with SMTP id y12so28626816qtx.11 for ; Tue, 20 Apr 2021 06:28:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kepstin.ca; s=google; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=J/YrRJCz3Qya2ecpGn1yqFyHTDzbSdU1ZISqo4g1zcw=; b=odK1x/sVcgFM3hT8erFQ0CAG+e72BD9kBGWC3wvpf6UFqxEs+Yk9JMdnqB0hvBpiAM BLz0QPw55dhcOOC9e62yroHiTaRC93zPa5S6wBegSxxSCe1X+qZnl+8eGhgezGEZ4JYv lrcWybIbiXN3qVr06x+nqIXCK38ZbdR8a6tCY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=J/YrRJCz3Qya2ecpGn1yqFyHTDzbSdU1ZISqo4g1zcw=; b=WQFWVRz31Ii/q9PvzwuFsH78wrF3VGu+Ms/B0613eMYgJ4J696UCA+QqDll8NhB6PW NEweT9u9TWKh/zAy8+nzMGa7qut/iZuyC6xY9qmZW+7JuEkiVAWp1Ky4S8L6YstrhLNF bY88idVv69oe67jFbR6iL+IgV2UmAzJ21iUhe6Dqw9vD+YRcc+uh8cN8RF9VqmTCf7mP 7BORRhyDM0GT+5U0WsRm52w83mLaiUkOPi06yEwYT389Igf/FqLy8J08cz/dM2myJ2Kj ghHIA1UYAP0TX2yfbPc76QeYoaPOEUdJ+NUmiMXCanm32KZVScnEOAj0JaO84G+LdY7k ehPg== X-Gm-Message-State: AOAM531vzOjai7HlODsWbyUcQDq/G/zO94OAEOzTERopklLfeqtqv1+v oy3b/O7w1c23KCcRZMgo/YEj3zpQZyic8cyH0G0= X-Received: by 2002:ac8:57c6:: with SMTP id w6mr1211125qta.309.1618925289077; Tue, 20 Apr 2021 06:28:09 -0700 (PDT) Received: from saya.kepstin.ca (dhcp-108-168-125-232.cable.user.start.ca. [108.168.125.232]) by smtp.gmail.com with ESMTPSA id m124sm11028208qkc.70.2021.04.20.06.28.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 06:28:08 -0700 (PDT) Message-ID: <4cbb1eff77de1e843912267ade4686cfa1acd610.camel@kepstin.ca> Subject: Re: [PATCH v2] tools/power turbostat: Fix RAPL summary collection on AMD processors From: Calvin Walton To: Chen Yu , Borislav Petkov Cc: Terry Bowman , lenb@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, wei.huang2@amd.com, aros@gmx.com Date: Tue, 20 Apr 2021 09:28:06 -0400 In-Reply-To: <20210420131541.GA388877@chenyu-desktop> References: <20210419195812.147710-1-terry.bowman@amd.com> <20210420020336.GA386151@chenyu-desktop> <20210420080701.GA2326@zn.tnic> <20210420131541.GA388877@chenyu-desktop> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2021-04-20 at 21:15 +0800, Chen Yu wrote: > > Okay. I would vote for the the patch from Bas as it was a combined > work from two > authors and tested by several AMD users. But let me paste it here too > for Artem to > see if this also works for him: > > > From 00e0622b1b693a5c7dc343aeb3aa51614a9e125e Mon Sep 17 00:00:00 > 2001 > From: Bas Nieuwenhuizen > Date: Fri, 12 Mar 2021 21:27:40 +0800 > Subject: [PATCH] tools/power/turbostat: Fix turbostat for AMD Zen > CPUs > > > @@ -297,7 +297,10 @@ int idx_to_offset(int idx) >   >         switch (idx) { >         case IDX_PKG_ENERGY: > -               offset = MSR_PKG_ENERGY_STATUS; > +               if (do_rapl & RAPL_AMD_F17H) > +                       offset = MSR_PKG_ENERGY_STAT; > +               else > +                       offset = MSR_PKG_ENERGY_STATUS; >                 break; >         case IDX_DRAM_ENERGY: >                 offset = MSR_DRAM_ENERGY_STATUS; This patch has the same issue I noticed with the initial revision of Terry's patch - the idx_to_offset function returns type int (32-bit signed), but MSR_PKG_ENERGY_STAT is greater than INT_MAX (or rather, would be interpreted as a negative number) The end result is, as far as I can tell, that it hits the if (offset < 0) check in update_msr_sum() resulting in the timer callback for updating the stat in the background when long durations are used to not happen. For short durations it still works fine since the background update isn't used. -- Calvin Walton