Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3373820pxb; Mon, 17 Jan 2022 18:57:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhRhvN4zoF1/LmZ2eLOf64mDIoOH0vuKZ4gnAXhV54loLViCgEY4qnuSFArK5+MJOPKFit X-Received: by 2002:a05:6a00:24cc:b0:4bb:ffe2:17c2 with SMTP id d12-20020a056a0024cc00b004bbffe217c2mr24170414pfv.31.1642474654891; Mon, 17 Jan 2022 18:57:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642474654; cv=none; d=google.com; s=arc-20160816; b=Vxv66wHiznnE2NZkY6jUWkdU7ON/PuCcQGCDZm4MbBsjn6JQsycdnNqW+63bdn/8jG un564ZqEmIeeqJ1WHNgar6X4em8GaFZ1SnJZA9pAJ8zAwhMtjwYZ73PAwZKLtrrLHWIn jJF7YqUQ+LVGc31GHEzAYsiwrryG46kej+T2MQgvH+BTaiBvL+hcABn/WSZop+WJVefW vgkSOYakuOaWTpR7Cc5tQRPMo900X4+EUdDevIRSoDEgEZarNiWXNpvX+kDODEGxznX6 R48EBqn8rrOOyHsqYGxDaLY+nasYHQjbsovbF+q4KKiGiC+YQDT9sQTD7dGsQ07H9J46 u/aQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Iglsy9mh4gcWCEJQUwA3xMJhp0v17OaWSN3A2Ls8pHo=; b=QTTElq7cayX74D3r8ETNEiuTH1CczQS8o+G85BbW+E2HLycaKjZ7BiZPFppVF68LWN 36Z78ZWw7IVEXQ7HPR0cZAFMEccgVOExN264Z/F1lUMt6Qcx7rCohWkBKSWMDfDL29dw XmxL6xVLuzMNq2+j58CiAdnDBa1L0uq6BanW7o28FWcGlsJPD/6VltFclfrQ+6wpa/pO 2sZVeumNKv430k393a9iYOpp2BDA3+qD013+onJ2OdtusNh2X/OfAIpJNMujHNYGki8Z L4OVyabvYhX+J8Gpq1Fdp3zhYhCt0aloorb6+icUkNxboy9XE8S4Ro+W4e8eQXioJUtG Yu6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PcMiqLVo; 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t12si14356711plo.124.2022.01.17.18.57.23; Mon, 17 Jan 2022 18:57:34 -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=@intel.com header.s=Intel header.b=PcMiqLVo; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242847AbiAQSft (ORCPT + 99 others); Mon, 17 Jan 2022 13:35:49 -0500 Received: from mga12.intel.com ([192.55.52.136]:48634 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242843AbiAQSfR (ORCPT ); Mon, 17 Jan 2022 13:35:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642444517; x=1673980517; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IgZjj9XbMC7hMTZDfcpEgux3Es+6Lrg4o7zKivFg6PY=; b=PcMiqLVoSu9VN8i4/914pwfQLxc4vLjAbErNIXxOeES0uVXFlXflLI4o CKmVqINWUGP+m5beHJ2g1tjhPrAwOYYeBJrCiX/v3mfayqLAQpcB2fGPi UNB74SvgiiPFCu+CYkN6uRd+08C3pLAgwFzleVug00BixaYkqtJgcpJzV CNACnkTyK27ur/2tQlq+nr+1tb07/Y5ZU5NAhQt4Oqd++xU3JWpMfI9CD pcMeU+yBgU2693xz5z2NnlolDXH8weL1BnKQgyLI5kWrpRJoQzBlZO/XR 097wJRitotblLkiedWdBJJzBUHeTAiozfVtjyGomzam1XtaNI+ZPm5hF+ A==; X-IronPort-AV: E=McAfee;i="6200,9189,10229"; a="224656030" X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="224656030" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2022 10:35:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="492434292" Received: from nntpat99-84.inn.intel.com ([10.125.99.84]) by orsmga002.jf.intel.com with ESMTP; 17 Jan 2022 10:35:13 -0800 From: Alexey Bayduraev To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , linux-kernel , Andi Kleen , Adrian Hunter , Alexander Antonov , Alexei Budankov , Riccardo Mancini Subject: [PATCH v13 11/16] perf record: Introduce data transferred and compressed stats Date: Mon, 17 Jan 2022 21:34:31 +0300 Message-Id: X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); + } return 0; } -- 2.19.0