Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp440860pxv; Wed, 30 Jun 2021 09:02:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrOTXV6qWOLYBLZVGOCCcWXaiqJMkwznr7Ja6tjfJjWDHYgZueKq9q+FwvkZc39rYLo7qW X-Received: by 2002:a17:907:e8d:: with SMTP id ho13mr1550355ejc.545.1625068970221; Wed, 30 Jun 2021 09:02:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625068970; cv=none; d=google.com; s=arc-20160816; b=vnSkt3LM2auEPUUJplkuIILRT1heSGTT/4s1SJdKaPbS1zV4rNyLMOoxFfAlfKmxiU Y1ouzi2HBczpCmt+knAFIbBsqvpb+JQDvviRunWcjk+pKGfv/uPU/l0XAzETzvgwHQZh I9yM7D+i9aVmU4HgzuNUv8Po6j78rFPPyi44GsOnWvIWYMPmmt/9jZ9Y63VUfSNUgcfI jaNMn8atREuWGAhZND6JIRUBn16ZC9PesmnRudF0c6n0IBgnzKsgXRMaFod85boOZFqx Wyy8knLb1TuD7NfNtmW1Rwygf88+AND1gVnmgL2iHGKQA8A/PMJrDb3RnKx8/KDUav2K aE4Q== 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; bh=LdcPcuhAkEKd1eSwqEDEfuhoKLBVdv4yEtlrFFac5hA=; b=BZGPQbNGg7Rw+MDKGyA+FE92l+GLbz1pUftepgSIwVs4zlSN5qYTQwKOyeG4E0JrdG 9uw7AG/qRd74VLdWt7Qqb9p231seefOmHZMxYtjVk13Nfc3tLexzCmE/a0/vlIsehCkC GrMPk9k5SrkTSUnALCGMknEx9T7oq4PJOCzBF80Nz6nkrpEoUlJiU75H7ECzpr9U+brs 3KtnNtVMB0UdR9SXeHp1Vg6ZoGlMMvmad8EhwjVl4NZO55xr/ha7c0cxRHzYB3EMgE2u jSWPli3HtdVk7jkW48kaImNUzZ/4xiXkq/PuwWxJNvz24jpc7Pg9Se35A5J9lPrjZ6zj bPbA== 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=fail (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 b13si21396992edv.57.2021.06.30.09.02.22; Wed, 30 Jun 2021 09:02:50 -0700 (PDT) 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236156AbhF3QCN (ORCPT + 99 others); Wed, 30 Jun 2021 12:02:13 -0400 Received: from mga01.intel.com ([192.55.52.88]:4080 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236159AbhF3QBy (ORCPT ); Wed, 30 Jun 2021 12:01:54 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10031"; a="230016105" X-IronPort-AV: E=Sophos;i="5.83,312,1616482800"; d="scan'208";a="230016105" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2021 08:56:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,312,1616482800"; d="scan'208";a="559099907" Received: from nntpat99-84.inn.intel.com ([10.125.99.84]) by fmsmga001.fm.intel.com with ESMTP; 30 Jun 2021 08:56:14 -0700 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 v8 22/22] perf record: Introduce record__bytes_written and fix --max-size option Date: Wed, 30 Jun 2021 18:55:01 +0300 Message-Id: <7fb2b3abe92f1ab91e790ce1885eb5a3de4bab87.1625065643.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 Adding a function to calculate the total amount of data transferred and using it to fix the --max-size option. Signed-off-by: Alexey Bayduraev --- tools/perf/builtin-record.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index c5954cb3e787..16a81d8a840a 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -199,10 +199,28 @@ static bool switch_output_time(struct record *rec) trigger_is_ready(&switch_output_trigger); } +static u64 record__bytes_written(struct record *rec) +{ + int t, tm; + struct thread_data *thread_data = rec->thread_data; + u64 bytes_written = rec->bytes_written; + + for (t = 0; t < rec->nr_threads; t++) { + for (tm = 0; tm < thread_data[t].nr_mmaps; tm++) { + if (thread_data[t].maps) + bytes_written += thread_data[t].maps[tm]->bytes_written; + if (thread_data[t].overwrite_maps) + bytes_written += thread_data[t].overwrite_maps[tm]->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, @@ -218,20 +236,21 @@ static int record__write(struct record *rec, struct mmap *map __maybe_unused, return -1; } - if (map && map->file) { + if (map && map->file) map->bytes_written += size; - return 0; - } - - rec->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; } + if (map && map->file) + return 0; + if (switch_output_size(rec)) trigger_hit(&switch_output_trigger); -- 2.19.0