Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1556299pxb; Fri, 13 Nov 2020 16:27:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxECL+qUGmHs/Pd5vLPsWPLaYdTwrpQ8/pFYO7o7VPVNCbaZIgE/jYiiI0d5VgoiUNmgyPx X-Received: by 2002:a17:906:86cf:: with SMTP id j15mr4640881ejy.260.1605313652492; Fri, 13 Nov 2020 16:27:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605313652; cv=none; d=google.com; s=arc-20160816; b=IqPR6bT6GmZzyA5hHMcxiXLQkDpDytJrt5YiLYMbfO/RG69ceTeua20Z7dEVF4K3Tu a/jumUXJTo45l+SsF6Bq7lwFTyF90o/njot+icZWfR/2QEYnh4iOVaEV3A9hRx9A8VS+ Ryk2PfmF8+gnrN5UTy2kZZSJLhj1ZyjCj74vozzKdXfPajTSYxLevHsXq1320oWt6RiI h991e3nxsbYwh9cbvirIhKSz9yuTqwC+sRAKilYWFnwRsx5s5moXSqV019QLklHt+7C8 I/H/w1gXOxwhi2bxJRV/QDANGCACzIs9HQ5GCyKEgkshw4joCugyoIpcdFc/qbex359R At/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=AJHk4qfWuVzx38s7nu/Sl1qnsKktld+vhnX7xT/2xW0=; b=aJFIJ3iAR9EimK0ZZkGG4rduvDt8DmjOoyX4YAwipJsOCFERErPQ6sDDM1wKu1hKKU lZRq5J16OG70jw0SX46+jooC/r3Z7ArNsQA9/SURybcgRnkbLwygFvXDu6tcg+taKHR1 yP16p5cAJp9YZFchXbRL3oHFR2R3LKxih7UqI76EixhHbe/YzTRdfuQ32BrfncReofjw AuqCZ2ENJGL2DErTs6Z06fo8m2ClsttXC07lorjBuP/+CAweJp8HT1xLuBn2QAdHVzUC g6zH6KZxy6rPOvvMIIiwfoX6uc2MWahhXKAGF3voILjWMzaOjEJ8Ht9bvlWMKzaLZDtg r9mg== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h9si6444433ejx.477.2020.11.13.16.27.09; Fri, 13 Nov 2020 16:27:32 -0800 (PST) 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; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726204AbgKNAXy (ORCPT + 99 others); Fri, 13 Nov 2020 19:23:54 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:41558 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726172AbgKNAXw (ORCPT ); Fri, 13 Nov 2020 19:23:52 -0500 Received: by mail-lf1-f66.google.com with SMTP id w142so16670736lff.8 for ; Fri, 13 Nov 2020 16:23:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=AJHk4qfWuVzx38s7nu/Sl1qnsKktld+vhnX7xT/2xW0=; b=PV99L0ogiDY1JXSvMhJ0BNquFPW6vsn4gQgwDpps95N/oREFzgdPxrbGqqt8YgF7o6 EasxCDtx0ZmAXKdCW1ywbzvhYcOFJr3Y5ov2Fl4CM4JuwolctAO41VhhIf55sRn8k9xb izIwEbHC7vXEIZyAium/HQR7WY1bZFcpLeWjbmYVtglw+vyMOEqQci8l9xSKsjP7uGpQ T+UXycwG1E+RcJpeD2YBISj0ltc0wuqwQfSchepUNQqJ1pAosjhLbiLlCzuabmEK3+Ay Gah6NU78MgTnPsE1D11mhIlcj9Q2gRuKqWbGmRVC8QXDI94ZgDKn5b3prP7IloVHgo4O bDDg== X-Gm-Message-State: AOAM533K+lcqZxCdDtmMM4dYLc9H/2hPoh1sezH73ro4G+fVGiGSNIaX ueSw7E7TJsO2FR8QoCDfg2tRqs8vjb3EkMmt6Hs= X-Received: by 2002:a19:838c:: with SMTP id f134mr1758007lfd.540.1605313429798; Fri, 13 Nov 2020 16:23:49 -0800 (PST) MIME-Version: 1.0 References: <20201113050236.175141-1-namhyung@kernel.org> <20201113221601.GE842058@krava> In-Reply-To: <20201113221601.GE842058@krava> From: Namhyung Kim Date: Sat, 14 Nov 2020 09:23:39 +0900 Message-ID: Subject: Re: [PATCH] perf stat: Use proper cpu for shadow stats To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra , Mark Rutland , Alexander Shishkin , LKML , Stephane Eranian , Ian Rogers , Andi Kleen , Sam Xi Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Nov 14, 2020 at 7:16 AM Jiri Olsa wrote: > > On Fri, Nov 13, 2020 at 02:02:36PM +0900, Namhyung Kim wrote: > > Currently perf stat shows some metrics (like IPC) for defined events. > > But when no aggregation mode is used (-A option), it shows incorrect > > values since it used a value from a different cpu. > > > > Before: > > > > $ perf stat -aA -e cycles,instructions sleep 1 > > > > Performance counter stats for 'system wide': > > > > CPU0 116,057,380 cycles > > CPU1 86,084,722 cycles > > CPU2 99,423,125 cycles > > CPU3 98,272,994 cycles > > CPU0 53,369,217 instructions # 0.46 insn per cycle > > CPU1 33,378,058 instructions # 0.29 insn per cycle > > CPU2 58,150,086 instructions # 0.50 insn per cycle > > CPU3 40,029,703 instructions # 0.34 insn per cycle > > > > 1.001816971 seconds time elapsed > > > > So the IPC for CPU1 should be 0.38 (= 33,378,058 / 86,084,722) > > but it was 0.29 (= 33,378,058 / 116,057,380) and so on. > > > > After: > > > > $ perf stat -aA -e cycles,instructions sleep 1 > > > > Performance counter stats for 'system wide': > > > > CPU0 109,621,384 cycles > > CPU1 159,026,454 cycles > > CPU2 99,460,366 cycles > > CPU3 124,144,142 cycles > > CPU0 44,396,706 instructions # 0.41 insn per cycle > > CPU1 120,195,425 instructions # 0.76 insn per cycle > > CPU2 44,763,978 instructions # 0.45 insn per cycle > > CPU3 69,049,079 instructions # 0.56 insn per cycle > > > > 1.001910444 seconds time elapsed > > > > Reported-by: Sam Xi > > Fixes: 44d49a600259 ("perf stat: Support metrics in --per-core/socket mode") > > Signed-off-by: Namhyung Kim > > nice catch! would be great to have test for this > > Acked-by: Jiri Olsa Thanks! Will add a test later. Thanks, Namhyung