Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3527981pxb; Mon, 24 Jan 2022 11:27:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUv3EHmWCn6Mnp89ykX8kLqRioV7od8C2gKF6hvjiTG2QzAgo/4DPrtMc95h63Xz+pjyGE X-Received: by 2002:a05:6a00:b55:b0:4c9:25c7:b522 with SMTP id p21-20020a056a000b5500b004c925c7b522mr5598987pfo.55.1643052462173; Mon, 24 Jan 2022 11:27:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643052462; cv=none; d=google.com; s=arc-20160816; b=dYmecRgVvdQlPBq1aeWofY2IiWfNGs5adceRsWG3yixHZEykUlWYtdfDp57yQ4JXZ2 7ChJ/ifZk7o6BGhqZSFuqjPv8sP1wA/hHMNVZW2BAgBoViSS+xNkBmGQTnGY8e456f4H rTEAsbMGKnBkwFCpKD21SC0J6i+pDIdZscZdjE76D1NXqH9rs7/cSCFJge7GQujXXy+J bfoCDKmYf2oVbr4Aj4bn+iJXYj3iP7/IH+7WTCv2CyEe/VClldMBS8+wc7/2PHrUWNjt SM8fERsY4MUwgz4CPSLuoSSvpzb0fprybE/q39WME3wDBsQmUVpt2G/Eidz8/Sdydc2W PVqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=RfMZBy/XY1O8+NE+qLoORXEw37YZ2gfc4Yt/FfvkjCg=; b=v2pfdGqpZVMmOafU0fsQm0foyecueGNym7XUapGHaLlB2QTEXKx+gnkFLAhDZgKcGi AlmnAhEgUeI9pTTTrCl1CyUBLNXtGA2rVbrdAu/I/b8CFL9Y1+2BWwJfuIb6SXafPFxs CTGQ+vh3BdrQ69gRVKb0QDICPsYWqtVtCS/mZM2Y/tJNkA8H+Aq0rFeUlaHiDwVuGlv6 5ajlJdXyNg4EX4NVQzwKDdqRIg+riJ/u4tGpmK3oK+3tfam3oLTWHbBKA0G0BdyQOieN y8/BK96ME8+GxMR3jZOfi3mLknUjyrpsel9fuOz7feiWQHL85LG0KU32LWHfrLxT1zr0 pXxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SsyMrwPY; 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 p1si14639674pfo.150.2022.01.24.11.27.27; Mon, 24 Jan 2022 11:27:42 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SsyMrwPY; 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 S243199AbiAXPaX (ORCPT + 99 others); Mon, 24 Jan 2022 10:30:23 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:57190 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243145AbiAXPaW (ORCPT ); Mon, 24 Jan 2022 10:30:22 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 397C16148F for ; Mon, 24 Jan 2022 15:30:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42797C340E5; Mon, 24 Jan 2022 15:30:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643038221; bh=imIbdS9bZRqwq9tKxxFNiH/5EeT1Jb7ncT1Gvs01f+Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SsyMrwPYNdLkHkGLRNMnOV+H1I/ga9IHmIv25OSKDYYd+qhlq7Mq2gZ4hrbvwMFJD KNgJ6xY1Rkzs7UEym/C0f3SroHl+9xrFPt761pxJDj4REId3D+oDe5/Nt/W94tKjDA 26zssgpMb+NfkB0GcF1ZvCvGmC7nAqey2gQ7DEG/hH8+XkVptzu2kPzb0OgKYzxxgN MRUz8OAlRTsGs23h1NZKj73oikpdWuPMfp9uogOM3JDolVeOHKndSM/iUQ9zbbiMFO egnjS7rFG0VTEdKwD3/lPSaFIg8ei5xo3stPylunFVTEOaf0qZpdMFTTUi/Tqi6oqK 7v6XYeXgZFw1Q== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 2637040C99; Mon, 24 Jan 2022 12:28:18 -0300 (-03) Date: Mon, 24 Jan 2022 12:28:18 -0300 From: Arnaldo Carvalho de Melo To: Alexey Bayduraev Cc: Jiri Olsa , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , linux-kernel , Andi Kleen , Adrian Hunter , Alexander Antonov , Alexei Budankov , Riccardo Mancini Subject: Re: [PATCH v13 11/16] perf record: Introduce data transferred and compressed stats Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Mon, Jan 17, 2022 at 09:34:31PM +0300, Alexey Bayduraev escreveu: > Introduce bytes_transferred and bytes_compressed stats so they > would capture statistics for the related data buffer transfers. > > Acked-by: Andi Kleen > Acked-by: Namhyung Kim > Reviewed-by: Riccardo Mancini > Tested-by: Riccardo Mancini > Signed-off-by: Alexey Bayduraev > --- > tools/perf/builtin-record.c | 25 ++++++++++++++++++++++--- > 1 file changed, 22 insertions(+), 3 deletions(-) > > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c > index 7d0338b5a0e3..0f8488d12f44 100644 > --- a/tools/perf/builtin-record.c > +++ b/tools/perf/builtin-record.c > @@ -111,6 +111,8 @@ struct record_thread { > unsigned long long samples; > unsigned long waking; > u64 bytes_written; > + u64 bytes_transferred; > + u64 bytes_compressed; > }; > > static __thread struct record_thread *thread; > @@ -1407,8 +1409,13 @@ static size_t zstd_compress(struct perf_session *session, struct mmap *map, > compressed = zstd_compress_stream_to_records(zstd_data, dst, dst_size, src, src_size, > max_record_size, process_comp_header); > > - session->bytes_transferred += src_size; > - session->bytes_compressed += compressed; > + if (map && map->file) { > + thread->bytes_transferred += src_size; > + thread->bytes_compressed += compressed; > + } else { > + session->bytes_transferred += src_size; > + session->bytes_compressed += compressed; > + } > > return compressed; > } > @@ -2098,8 +2105,20 @@ static int record__stop_threads(struct record *rec) > for (t = 1; t < rec->nr_threads; t++) > record__terminate_thread(&thread_data[t]); > > - for (t = 0; t < rec->nr_threads; t++) > + for (t = 0; t < rec->nr_threads; t++) { > rec->samples += thread_data[t].samples; > + if (!record__threads_enabled(rec)) > + continue; > + rec->session->bytes_transferred += thread_data[t].bytes_transferred; > + rec->session->bytes_compressed += thread_data[t].bytes_compressed; > + pr_debug("threads[%d]: samples=%lld, wakes=%ld, ", thread_data[t].tid, > + thread_data[t].samples, thread_data[t].waking); > + if (thread_data[t].bytes_transferred && thread_data[t].bytes_compressed) > + pr_debug("trasferred=%ld, compressed=%ld\n", > + thread_data[t].bytes_transferred, thread_data[t].bytes_compressed); > + else > + pr_debug("written=%ld\n", thread_data[t].bytes_written); In file included from builtin-record.c:22: builtin-record.c: In function 'record__stop_threads': builtin-record.c:2138:13: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'u64' {aka 'long long unsigned int'} [-Werror=format=] 2138 | pr_debug("trasferred=%ld, compressed=%ld\n", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ util/debug.h:18:21: note: in definition of macro 'pr_fmt' 18 | #define pr_fmt(fmt) fmt | ^~~ builtin-record.c:2138:4: note: in expansion of macro 'pr_debug' 2138 | pr_debug("trasferred=%ld, compressed=%ld\n", | ^~~~~~~~ builtin-record.c:2138:27: note: format string is defined here 2138 | pr_debug("trasferred=%ld, compressed=%ld\n", | ~~^ | | | long int | %lld In file included from builtin-record.c:22: builtin-record.c:2138:13: error: format '%ld' expects argument of type 'long int', but argument 5 has type 'u64' {aka 'long long unsigned int'} [-Werror=format=] 2138 | pr_debug("trasferred=%ld, compressed=%ld\n", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ util/debug.h:18:21: note: in definition of macro 'pr_fmt' 18 | #define pr_fmt(fmt) fmt | ^~~ builtin-record.c:2138:4: note: in expansion of macro 'pr_debug' 2138 | pr_debug("trasferred=%ld, compressed=%ld\n", | ^~~~~~~~ LINK /tmp/build/perf/libtraceevent.a builtin-record.c:2138:43: note: format string is defined here 2138 | pr_debug("trasferred=%ld, compressed=%ld\n", | ~~^ | | | long int | %lld In file included from builtin-record.c:22: builtin-record.c:2141:13: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'u64' {aka 'long long unsigned int'} [-Werror=format=] 2141 | pr_debug("written=%ld\n", thread_data[t].bytes_written); | ^~~~~~~~~~~~~~~ util/debug.h:18:21: note: in definition of macro 'pr_fmt' 18 | #define pr_fmt(fmt) fmt | ^~~ builtin-record.c:2141:4: note: in expansion of macro 'pr_debug' 2141 | pr_debug("written=%ld\n", thread_data[t].bytes_written); | ^~~~~~~~ builtin-record.c:2141:24: note: format string is defined here 2141 | pr_debug("written=%ld\n", thread_data[t].bytes_written); | ~~^ | | | long int | %lld Fixed with the following patch, no need to resend, I'll fix several other similar issues and put the result in a tmp.perf/thread branch while I review/test it. - Arnaldo diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 0f8488d12f446b84..d19d0639c3f1abc0 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -2114,10 +2114,10 @@ static int record__stop_threads(struct record *rec) pr_debug("threads[%d]: samples=%lld, wakes=%ld, ", thread_data[t].tid, thread_data[t].samples, thread_data[t].waking); if (thread_data[t].bytes_transferred && thread_data[t].bytes_compressed) - pr_debug("trasferred=%ld, compressed=%ld\n", + pr_debug("transferred=%" PRIu64 ", compressed=%" PRIu64 "\n", thread_data[t].bytes_transferred, thread_data[t].bytes_compressed); else - pr_debug("written=%ld\n", thread_data[t].bytes_written); + pr_debug("written=%" PRIu64 "\n", thread_data[t].bytes_written); } return 0;