Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2483996rwb; Fri, 2 Dec 2022 10:21:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf7/z5mC8gdfb12skiQrBwZACyPtWY4MlSI93/zzKZxY7PQK+JSvTGOfncWHPKGPJBY0rez5 X-Received: by 2002:a17:906:69b:b0:78e:ebb:cbb7 with SMTP id u27-20020a170906069b00b0078e0ebbcbb7mr47156320ejb.38.1670005274169; Fri, 02 Dec 2022 10:21:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670005274; cv=none; d=google.com; s=arc-20160816; b=OKTU8poZUWexBCiJmL4EJwgJBhhtVl9E8Bm9cAhd7y3TBsWlnnrW7x0mPLPKgFySra PTlJv5baYvxT9lPmQA+6kYkGk7mW78hbOA26pUWzgS7KkEXvIm4Xf0nEBU+PP6hcSoB/ kZP5vOaShtOEwb7P/KOaAmEBCK1dZ7ahLpt8XE1tey36/dYsmY2H8lo+TAK1nV8EtlAE flSeP7vUlkq5mHcQ8u5nqECT+yTQyctrWLp2Z9KUG0/EGZSYe4GYOS+eddyPPek5Ec+z ATIVIvTx/rfT8Nf9XW/BrY47UdPxqRLl/AyOk93F/VxqUbHizDZyjCRilShmN8LO1wPX T/YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=st8XfY9/VozJGgnPkGa3sykG9tnb1K6837OxC8tTfRU=; b=VXbrs1qNgXhAWmRaj6TKmYYaD8Kr5BDYWZUYHxkvBr4rOl6CIR0HXvVK9waZsreOWT U7S16cJ5SwGOu1F80gtY20c920YkUHV0HW2HZp4AHE75LuWQKkMrXSNquIKeeCztrS9F 4FD8HBQz/TX2Vzlg7RRTZl0/nppkgo2ZRYv8SzPD3eJdMbI5j9byYikYR4kYfWID2sys hzCEATCWL2IOnczWGwllHbH0d17gd8h13vp96bdcsuG0NlWCkJWI9HAOq2rjX6DhJF88 9cI7N7k2BIkat0KK2EJ26Z+Euktwqxe8NjOB9PJSWBE8+Lbs3g100RaeHHnPywovRD46 C6sA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw25-20020a1709066a1900b0078c4a772ea7si6615523ejc.11.2022.12.02.10.20.52; Fri, 02 Dec 2022 10:21:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S233744AbiLBSDe convert rfc822-to-8bit (ORCPT + 82 others); Fri, 2 Dec 2022 13:03:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234216AbiLBSDb (ORCPT ); Fri, 2 Dec 2022 13:03:31 -0500 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0397260B4C; Fri, 2 Dec 2022 10:03:30 -0800 (PST) Received: by mail-wr1-f48.google.com with SMTP id y16so8995363wrm.2; Fri, 02 Dec 2022 10:03:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v5S9AInjAkBzgT4Ue2Z9+cewf5MRHGtio+KBn1axLoU=; b=ljRwqPwIY3zJkK+ZKd+fmuYoxTbwwtPcuyB7Qx/2C590v+s04ukAE2dDkG0z8T2Jok w2c6O5CXEBQUmwY+p0qNcEWIpH3Moxm8HdG1WKATf10zWtc/r9SE4Znk9op8/zevnb8g 1PgwqXXdRXxkZJ8/kQasd0nwfz0gM2bx0kdkR3Fl5CC0vlH49vznkj4vNudELOWmIlpT kZxDdok39xvVQnMa7yIUcPTgH2Bo4yewZtayojEJ5hFiZCZCrnPzgvfPNpaYke5ibvL1 oZIuW2kWk0yyV9gOPUFcjl7NR8FF8V4f0JN+3rVpE8axEKWaJGSFwDYMAlRTrnT6/cWH 0M1g== X-Gm-Message-State: ANoB5plKNR1UDOj1PHwSSXKoWkpS30HUuDvqYvVCryebVqfTj524XZlh wtn/85Y30JpE1lhgq+orDUn0WBy0695UcV2PRo8= X-Received: by 2002:a5d:5b08:0:b0:241:d7b1:b3db with SMTP id bx8-20020a5d5b08000000b00241d7b1b3dbmr1829830wrb.293.1670004208244; Fri, 02 Dec 2022 10:03:28 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Namhyung Kim Date: Fri, 2 Dec 2022 10:03:16 -0800 Message-ID: Subject: Re: [PATCH 13/15] perf stat: Fix JSON output in metric-only mode To: "Wang, Weilin" Cc: "acme@kernel.org" , "Hunter, Adrian" , "atrajeev@linux.vnet.ibm.com" , "irogers@google.com" , "james.clark@arm.com" , "jolsa@kernel.org" , "kan.liang@linux.intel.com" , "linux-kernel@vger.kernel.org" , "linux-perf-users@vger.kernel.org" , "mingo@kernel.org" , "peterz@infradead.org" , "zhengjun.xing@linux.intel.com" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Thu, Dec 1, 2022 at 4:56 PM Wang, Weilin wrote: > > Hi Namhyung, > > > > I encountered an issue with the metric json output, which I think might be related to this commit. > > > > This is one of the commands I tried: > > > > ./perf stat -M memory_bandwidth_total,memory_bandwidth_read,memory_bandwidth_write -a -j -- sleep 1 > > > > Output before this commit: > > ==================================================== > > {"counter-value" : "1117309.000000", "unit" : "", "event" : "UNC_M_CAS_COUNT.RD", "event-runtime" : 8017286783, "pcnt-running" : 100.00, "metric-value" : 124.961911, "metric-unit" : "MB/s memory_bandwidth_read"} {"metric-value" : 237.237504, "metric-unit" : "MB/s memory_bandwidth_total"} {"counter-value" : "1004052.000000", "unit" : "", "event" : "UNC_M_CAS_COUNT.WR", "event-runtime" : 8017286783, "pcnt-running" : 100.00, "metric-value" : 112.275593, "metric-unit" : "MB/s memory_bandwidth_write"} {"counter-value" : "1002140370.000000", "unit" : "ns", "event" : "duration_time", "event-runtime" : 1002140370, "pcnt-running" : 100.00, "metric-value" : 0.000000, "metric-unit" : "(null)"} > > ==================================================== > > > > Output after this commit: > > ==================================================== > > {"counter-value" : "1374098.000000", "unit" : "", "event" : "UNC_M_CAS_COUNT.RD", "event-runtime" : 8016491003, "pcnt-running" : 100.00, "metric-value" : 153.660738, "metric-unit" : "MB/s memory_bandwidth_read"} "metric-value" : 300.338968, "metric-unit" : "MB/s memory_bandwidth_total"} {"counter-value" : "1311710.000000", "unit" : "", "event" : "UNC_M_CAS_COUNT.WR", "event-runtime" : 8016491003, "pcnt-running" : 100.00, "metric-value" : 146.678229, "metric-unit" : "MB/s memory_bandwidth_write"} {"counter-value" : "1002037512.000000", "unit" : "ns", "event" : "duration_time", "event-runtime" : 1002037512, "pcnt-running" : 100.00, "metric-value" : 0.000000, "metric-unit" : "(null)"} > > ==================================================== > > > > The second set of output is missing a "{" on the second line. Looks like it happens when I collect two related metrics together. Another example is: > > > > ./perf stat -M memory_bandwidth_total,memory_bandwidth_read,memory_bandwidth_write,L3_Cache_Fill_BW_1T,L3_Cache_Fill_BW -a -j -- sleep 1 > > > > {"counter-value" : "944204.000000", "unit" : "", "event" : "UNC_M_CAS_COUNT.RD", "event-runtime" : 8033937053, "pcnt-running" : 100.00, "metric-value" : 105.369994, "metric-unit" : "MB/s memory_bandwidth_read"} "metric-value" : 210.592807, "metric-unit" : "MB/s memory_bandwidth_total"} {"counter-value" : "942679.000000", "unit" : "", "event" : "UNC_M_CAS_COUNT.WR", "event-runtime" : 8033937053, "pcnt-running" : 100.00, "metric-value" : 105.222813, "metric-unit" : "MB/s memory_bandwidth_write"} {"counter-value" : "1004471458.000000", "unit" : "ns", "event" : "duration_time", "event-runtime" : 1004471458, "pcnt-running" : 100.00, "metric-value" : 0.000000, "metric-unit" : "(null)"} {"counter-value" : "184675.000000", "unit" : "", "event" : "LONGEST_LAT_CACHE.MISS", "event-runtime" : 88387319917, "pcnt-running" : 100.00, "metric-value" : 0.011767, "metric-unit" : "L3_Cache_Fill_BW_1T"} "metric-value" : 0.011767, "metric-unit" : "L3_Cache_Fill_BW"} {"counter-value" : "1004471458.000000", "unit" : "ns", "event" : "duration_time", "event-runtime" : 1004471458, "pcnt-running" : 100.00, "metric-value" : 0.000000, "metric-unit" : "(null)"} Thanks for your report. It seems it misses the open bracket when the metric produces more than one values. I think new_line_json() should have it. Will send the fix soon. Thanks, Namhyung