Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3373667pxb; Mon, 17 Jan 2022 18:57:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJwY8FSDn2a8WmmQQ5JKsK/uUblEChQvIwT5kuFlZtJAsWUbfj2H/0FlzuM7/cW3Jq2Fds6g X-Received: by 2002:a17:90b:4c42:: with SMTP id np2mr28521790pjb.201.1642474639719; Mon, 17 Jan 2022 18:57:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642474639; cv=none; d=google.com; s=arc-20160816; b=IfZGdv82k6cx/9tg1YfCHnoPwxOxxy0Q/SJRvApMA0+o6YWrbMR3cMFzTGMDmtJNOU g6q3XYGnpnY1epuTHK+x2YWYxal76OtAuUVKmSpXEeSlWFpQgdvUggkV0+Za6eM0maig /mX3SAybJz5xSShVRLlPd80EaCuks+xMhN7mMB8NC4J+YbmClmW4XJ/bWTWr4zFhv+qH 9xPFNi1gYodtv2z2022g2/Sxvt8+m5v4tbQnBR6cQuhQiRx5ChbiMoyYxsMfow0/f5cQ jTyJDoaxtl2nqQTmnTQFvt8rO/tzu71GZ/yms1BsD/ctOzhl1QByX7c/ZeJ5wx01BzW3 VzEA== 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=gYkr2PhTigWhgCBQUT1GRfCHAS13HlDSNzJrwW9yxP0=; b=kmS1Wq3aHH2ekfh2BlUledUygMkJV68jAgeC4Y5UC9hNh6keeaDWbQvSbxKj+DHW+x NksKC/gwow7++dUE4Fmhk09G9/xD/lK3Kn0AL3ltbfwIVXapColTXEE6/fiYDEW2hdS/ RJjLbdX4B+YEZUmi2jXutSY73N6g+vt9VZ8ALFSR5F9JIJwgYVF6D20gncZ1D0Wlb1O/ rAGlZOxI1FPoXILYZf9VXgMB0E5Jb0Vy/ixr2xSQ3rMsyRsGAoTDCyZDnezpBOhjagDf tH8dIlW54Yb/SQ87jpV//AWZczFtvRgbdxh5ohmHezuss2idOJcZhDRIEtuWv5bNt9QY cs+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iSPywyDb; 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 w185si16296083pgd.607.2022.01.17.18.57.08; Mon, 17 Jan 2022 18:57:19 -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=iSPywyDb; 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 S242780AbiAQSfa (ORCPT + 99 others); Mon, 17 Jan 2022 13:35:30 -0500 Received: from mga12.intel.com ([192.55.52.136]:48629 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242770AbiAQSfL (ORCPT ); Mon, 17 Jan 2022 13:35:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642444511; x=1673980511; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jXewn2D3TS6sPyNfV5Vn+j8dLBIuSljGeQz6Yl1GSqM=; b=iSPywyDb9MpC6zfuyRf3V9Ni0wjYcKOR23ejKrcS4PifocV4YAt5Z0vM q1Q/BcIuAPDNnIzNAgVACcj9Gatnal6HS9DjPsi3W9TLEzOwjQ2/q89Ji BwpwQrtqv4ZciWXV9cVbxAVGx7RvSFRaE4cLVNS3/NGJO7fU7lhVj1XpP zvtNRRR89mHXvrFXq873kbBx5T3pNl8rCmSEx/hFDsYK+GJFhn3mxYuzy CZgznMFoC71iK2+mSqANyIRMuQ5BbJy789yWb5pcPvLmprFQRhmDNlJfn 8IRpLjcupUtwkyQoIv4gifC7pfZNGXFkNiV7K6oBdSYl4wIQabbWHUKBf g==; X-IronPort-AV: E=McAfee;i="6200,9189,10229"; a="224656021" X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="224656021" 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:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="492434276" Received: from nntpat99-84.inn.intel.com ([10.125.99.84]) by orsmga002.jf.intel.com with ESMTP; 17 Jan 2022 10:35:07 -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 09/16] perf record: Introduce bytes written stats Date: Mon, 17 Jan 2022 21:34:29 +0300 Message-Id: <3e2c69186641446f8ab003ec209bccc762b3394d.1642440724.git.alexey.v.bayduraev@linux.intel.com> 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 a function to calculate the total amount of data written and use it to support the --max-size option. Acked-by: Namhyung Kim Reviewed-by: Riccardo Mancini Tested-by: Riccardo Mancini Signed-off-by: Alexey Bayduraev --- tools/perf/builtin-record.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 8766a3dc9440..50981bbc98bb 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -110,6 +110,7 @@ struct record_thread { struct record *rec; unsigned long long samples; unsigned long waking; + u64 bytes_written; }; static __thread struct record_thread *thread; @@ -194,10 +195,22 @@ static bool switch_output_time(struct record *rec) trigger_is_ready(&switch_output_trigger); } +static u64 record__bytes_written(struct record *rec) +{ + int t; + u64 bytes_written = rec->bytes_written; + struct record_thread *thread_data = rec->thread_data; + + for (t = 0; t < rec->nr_threads; t++) + bytes_written += thread_data[t].bytes_written; + + return bytes_written; +} + static bool record__output_max_size_exceeded(struct record *rec) { return rec->output_max_size && - (rec->bytes_written >= rec->output_max_size); + (record__bytes_written(rec) >= rec->output_max_size); } static int record__write(struct record *rec, struct mmap *map __maybe_unused, @@ -213,13 +226,15 @@ static int record__write(struct record *rec, struct mmap *map __maybe_unused, return -1; } - if (!(map && map->file)) + if (map && map->file) + thread->bytes_written += size; + else rec->bytes_written += size; if (record__output_max_size_exceeded(rec) && !done) { fprintf(stderr, "[ perf record: perf size limit reached (%" PRIu64 " KB)," " stopping session ]\n", - rec->bytes_written >> 10); + record__bytes_written(rec) >> 10); done = 1; } -- 2.19.0