Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp330931pxv; Thu, 8 Jul 2021 22:40:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCYo1qPWuXRXeinKr+G95lsJJyE7pOQVpdNd1fXLfBppCd4ycUo6/XNIxPlW44pNGiX6Ru X-Received: by 2002:a02:620a:: with SMTP id d10mr31237331jac.22.1625809206678; Thu, 08 Jul 2021 22:40:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625809206; cv=none; d=google.com; s=arc-20160816; b=DJ3TFfRnLDrcvECu5gXgjAwUF4l6m9vc/Zd/9ij6Gg2O0N2tX80mAhKXKD9mRf0TiT /60p776tNOwMYV6OA0zc2aJvI40Fu1bvgKZpyXNv3/dwln0O9SBpTXmdxb3CUOP9xoxN uj8m2hSq9dFRnOk8JscpGtyzTY9mofG7/X29LMT7ffleL75/fEVJFSnfMJOOQW+rV+e4 mWgChSgOMvdsnDdhjByF7muEt0xohnBVa8RuSpoe2TpYpWa6evWo67AZSsEirpOTJWNW hkTc6iHI5SfqaNj9K1CUVWEqrXfabAzL0pzj78uCVcq5N0nfGCQI1RSJ0E850OfYD84z uGjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=tCSMbHmqdsIO0bSM7bjrOKO1HQ1oVbqYGlUHkRMGhls=; b=q8Lyq7JhjMI/FL2rneERsXotulzLqWJgvCXqT4o/zuZWh+bl5hQ8g7G3jlk4jJEnVH 06YnzJV0eoBFzHfB1w0nHrNBEdd9eS40LAta3MIwDj7Qyu/m3yrikHyzkXVfMXdDtRqR hdQH2lbLFSy38gVXKxp5HX/R8/0aKvz2v3lHjncHspA/HuYKo4ILRaKwYvP9MKJoniPU W99Pt8v4AxLF4/VtUGnNgyW9I2haSjt9gUmqDWYCr7Wd46QBW1OOPhhFsCLug8e52IGU Hme9yYCWc7HmmR3v2+OrP+oi4jyg/DAVCWuOmKf4Mbag5HojExVmU/kt0gFDjP2DTLOi U/Ig== 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=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 z6si4918074ils.150.2021.07.08.22.39.49; Thu, 08 Jul 2021 22:40:06 -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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229821AbhGIFlN (ORCPT + 99 others); Fri, 9 Jul 2021 01:41:13 -0400 Received: from mail-lf1-f46.google.com ([209.85.167.46]:40843 "EHLO mail-lf1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229707AbhGIFlN (ORCPT ); Fri, 9 Jul 2021 01:41:13 -0400 Received: by mail-lf1-f46.google.com with SMTP id q18so20950862lfc.7 for ; Thu, 08 Jul 2021 22:38:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tCSMbHmqdsIO0bSM7bjrOKO1HQ1oVbqYGlUHkRMGhls=; b=Ig43qfGjviDSz7t+sKumpTsg6ST+Tu3H/lhAydhX1rPS2BFiPKXLPFYzxF7yEK7g7b GWxzYvxCcv0SEVa/ivhbH0HeCMVr99ucz9L0pwzUJ7mJQF+Zr9Jwt2DSRyeEu83oPPjS C0QsE1eMynomQfuEA5haEnttfoMlAZHLBawotbX1Y68grRTSXS2ZT9hJh04GLwOny2qh VKDYitnMQFMDtuiulZ/g0w4jfOeueVSchBBCnyuQpMtTnbuHYPJEUHXO1jZQVeNzXaW+ gdU0Tb5yOrLDgRFQMjmTgPCzSvB6y79DWG9UmOcfR8k8T1sADx9xo/L8uFq7tDrslnw1 N1YQ== X-Gm-Message-State: AOAM531MYAiSMig8Qg4A9P291WbNCd+TeS02DlShVWX0IlG+uaGDll04 dDZmiPScJ6alD5sVUfQoR+GbMMbuYZlchVKGHMU= X-Received: by 2002:a05:6512:3744:: with SMTP id a4mr26681125lfs.112.1625809108602; Thu, 08 Jul 2021 22:38:28 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Namhyung Kim Date: Thu, 8 Jul 2021 22:38:17 -0700 Message-ID: Subject: Re: [PATCH v9 09/24] perf record: Introduce bytes written stats to support --max-size option To: Alexey Bayduraev Cc: Arnaldo Carvalho de Melo , Jiri Olsa , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , linux-kernel , Andi Kleen , Adrian Hunter , Alexander Antonov , Alexei Budankov , Riccardo Mancini Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Fri, Jul 2, 2021 at 5:33 AM Alexey Bayduraev wrote: > > Adding a function to calculate the total amount of data written > and using it to support the --max-size option. > > Signed-off-by: Alexey Bayduraev Acked-by: Namhyung Kim Thanks, Namhyung > --- > tools/perf/builtin-record.c | 30 +++++++++++++++++++++++++++--- > tools/perf/util/mmap.h | 1 + > 2 files changed, 28 insertions(+), 3 deletions(-) > > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c > index ac9bc1bbdff4..6419b7974435 100644 > --- a/tools/perf/builtin-record.c > +++ b/tools/perf/builtin-record.c > @@ -186,10 +186,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 record_thread *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, > @@ -205,15 +223,21 @@ static int record__write(struct record *rec, struct mmap *map __maybe_unused, > return -1; > } > > - rec->bytes_written += size; > + if (map && map->file) > + map->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); > > diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h > index c4aed6e89549..67d41003d82e 100644 > --- a/tools/perf/util/mmap.h > +++ b/tools/perf/util/mmap.h > @@ -46,6 +46,7 @@ struct mmap { > int comp_level; > struct perf_data_file *file; > struct zstd_data zstd_data; > + u64 bytes_written; > }; > > struct mmap_params { > -- > 2.19.0 >