From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31DA9C43381 for ; Thu, 7 Mar 2019 08:28:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 08A8D20851 for ; Thu, 7 Mar 2019 08:28:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726248AbfCGI2h (ORCPT ); Thu, 7 Mar 2019 03:28:37 -0500 Received: from mga05.intel.com ([192.55.52.43]:19139 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbfCGI2g (ORCPT ); Thu, 7 Mar 2019 03:28:36 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Mar 2019 00:28:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,451,1544515200"; d="scan'208";a="152828103" Received: from linux.intel.com ([10.54.29.200]) by fmsmga001.fm.intel.com with ESMTP; 07 Mar 2019 00:28:35 -0800 Received: from [10.125.252.109] (abudanko-mobl.ccr.corp.intel.com [10.125.252.109]) by linux.intel.com (Postfix) with ESMTP id 6884C5805B4; Thu, 7 Mar 2019 00:28:33 -0800 (PST) From: Alexey Budankov Subject: Re: [PATCH v5 02/10] perf record: implement -f,--mmap-flush= option To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel References: <4d1b11a4-77ed-d9af-ed22-875fc17b6050@linux.intel.com> <3600e56e-0431-080e-9df8-e376cdea1aad@linux.intel.com> <20190305122557.GF16615@krava> Organization: Intel Corp. Message-ID: <2df92343-57d0-8e07-f637-d2415da0e52d@linux.intel.com> Date: Thu, 7 Mar 2019 11:28:32 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <20190305122557.GF16615@krava> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05.03.2019 15:25, Jiri Olsa wrote: > On Fri, Mar 01, 2019 at 06:41:44PM +0300, Alexey Budankov wrote: > > SNIP > >> static int process_synthesized_event(struct perf_tool *tool, >> union perf_event *event, >> struct perf_sample *sample __maybe_unused, >> @@ -543,7 +566,8 @@ static int record__mmap_evlist(struct record *rec, >> if (perf_evlist__mmap_ex(evlist, opts->mmap_pages, >> opts->auxtrace_mmap_pages, >> opts->auxtrace_snapshot_mode, >> - opts->nr_cblocks, opts->affinity) < 0) { >> + opts->nr_cblocks, opts->affinity, >> + opts->mmap_flush) < 0) { >> if (errno == EPERM) { >> pr_err("Permission error mapping pages.\n" >> "Consider increasing " >> @@ -733,7 +757,7 @@ static void record__adjust_affinity(struct record *rec, struct perf_mmap *map) >> } >> >> static int record__mmap_read_evlist(struct record *rec, struct perf_evlist *evlist, >> - bool overwrite) >> + bool overwrite, bool sync) >> { >> u64 bytes_written = rec->bytes_written; >> int i; >> @@ -756,12 +780,19 @@ static int record__mmap_read_evlist(struct record *rec, struct perf_evlist *evli >> off = record__aio_get_pos(trace_fd); >> >> for (i = 0; i < evlist->nr_mmaps; i++) { >> + u64 flush = MMAP_FLUSH_DEFAULT; > > hum, why does this need the initial value? Compiler reported some warning or even error so staying on the safe side. > >> struct perf_mmap *map = &maps[i]; >> >> if (map->base) { >> record__adjust_affinity(rec, map); >> + if (sync) { >> + flush = map->flush; >> + map->flush = MMAP_FLUSH_DEFAULT; >> + } >> if (!record__aio_enabled(rec)) { >> if (perf_mmap__push(map, rec, record__pushfn) != 0) { >> + if (sync) >> + map->flush = flush; >> rc = -1; >> goto out; >> } >> @@ -774,10 +805,14 @@ static int record__mmap_read_evlist(struct record *rec, struct perf_evlist *evli >> idx = record__aio_sync(map, false); >> if (perf_mmap__aio_push(map, rec, idx, record__aio_pushfn, &off) != 0) { >> record__aio_set_pos(trace_fd, off); >> + if (sync) >> + map->flush = flush; >> rc = -1; >> goto out; >> } >> } >> + if (sync) >> + map->flush = flush; > > is there a point to set this back in case of sync == true? > we are going out at this point, right? Right, but function should work independently of any external assumption. ~Alexey > > jirka >