Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2208497pxb; Mon, 20 Sep 2021 15:20:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynMsiq8FAd+q23QaqCUnaHdzMz4U6hODr++vQCHN3GBdC3HEtOlq1dQfX/DIbfccm7j2BV X-Received: by 2002:a92:d2ca:: with SMTP id w10mr18750337ilg.222.1632176419788; Mon, 20 Sep 2021 15:20:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632176419; cv=none; d=google.com; s=arc-20160816; b=pX/mwJAsyYAYxHQS9nMowpJkNFJOEAJYpyGJrGtL9BSH+JDU1EWmSepTy64VLNkNv1 puTRDMadabfxu3Tana6WHCh9VCsrE4pTdkDu3Qnt4XPGJ+V6C23U5rRsYnMGvYL20tA+ 5pGfVe6AjvhKKPlEcDxgnY/Ees16nZfIAmFAsVVakc/kcSGsITy/7vhmeHK2aEOh19/e 2CTMA64nzlWox0+WyH1RFuK5O9dS8tu993edLTvXMNBSienFXP5IR/YXE9EDNqXqgMkT qP1SGeEHNyDcJmpP75QaFAs+tdDGZ6+iIgb4BiHGos/+zG09+zmKTWpeOEIUCli4Izpm UqiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject; bh=AIW9ZmKPuGlnoUbr192Q8vf6itSF3cf/e6n26pDZIbA=; b=bo6FGmpa+0E4gTVLTfZ6Uvy7ULgLYHIPx6UaASV9uD69K46iygogTJ1BEPO179Usxu pSLEQt3y+5e5FwNWIImdI+bX9lZhfPe3UkKOF1bxiHHP4n48PRqyNQYPWrXU0Iicap4D cVjVSDqho0X6p+UNcQghq2Hty0In4TX69MgyNDKp2fWlkugvNaRFZ2yqUaNy7KOFuQnY QfplJJmW3FTN7ZiIzFDfvypvHn9XPSzH3aw3U0Jf9Feo/QzXQrBMJ1sn+cFqKQNh44Zd dDNj6D8A9AJCTwBG0p0XLNbZgX4p84vYJD40tYIMDX+HhWouxXSewc/BGBhU6z8r0+Bo lvQg== 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 x17si14243396ilc.170.2021.09.20.15.20.08; Mon, 20 Sep 2021 15:20:19 -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 S238998AbhITM4P (ORCPT + 99 others); Mon, 20 Sep 2021 08:56:15 -0400 Received: from mga06.intel.com ([134.134.136.31]:9505 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238815AbhITM4J (ORCPT ); Mon, 20 Sep 2021 08:56:09 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10112"; a="284136030" X-IronPort-AV: E=Sophos;i="5.85,308,1624345200"; d="scan'208";a="284136030" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2021 05:54:39 -0700 X-IronPort-AV: E=Sophos;i="5.85,308,1624345200"; d="scan'208";a="548698090" Received: from abaydur-mobl1.ccr.corp.intel.com (HELO [10.249.227.77]) ([10.249.227.77]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2021 05:54:36 -0700 Subject: Re: [PATCH v11 09/24] perf record: Introduce bytes written stats to support --max-size option To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , linux-kernel , Andi Kleen , Adrian Hunter , Alexander Antonov , Alexei Budankov , Riccardo Mancini References: From: "Bayduraev, Alexey V" Organization: Intel Corporation Message-ID: <88975265-4e15-3a49-547b-c2f7dd067ac2@linux.intel.com> Date: Mon, 20 Sep 2021 15:54:33 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12.09.2021 23:46, Jiri Olsa wrote: > On Tue, Aug 17, 2021 at 11:23:12AM +0300, Alexey Bayduraev wrote: >> 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; > > could we instead have bytes_written in thread data? so we don't > need to iterate all the maps? Hi, As I remember the main issue is that bytes_written should be atomic64_t. Unfortunately we don't have atomic64 framework in tools/lib (even atomic32_add is missing). Thus I decided to calculate total size on each iteration. But I think your suggestion to move record__output_max_size_exceeded to trigger framework is better. > >> + 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); > > you're calling record__bytes_written twice.. could we just save the > bytes_written from the first call and use it in the printf? > >> done = 1; >> } >> >> + if (map && map->file) >> + return 0; > > please make comment why quit in here, we don't support switch-output for > threads? Yes, parallel streaming mode doesn't support switch-output and there is a special warning in [PATCH v11 14/24] Thanks, Alexey > > jirka > >> + >> 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 >> >