Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp178239pxb; Wed, 14 Apr 2021 12:21:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3lSfK6CzgAqN+voXo47URmIPRiOVtIbCq87dEqqOG91/Nv/8nZ7Ekq+UhAhcijg0yoogE X-Received: by 2002:a17:906:704a:: with SMTP id r10mr433571ejj.312.1618428115517; Wed, 14 Apr 2021 12:21:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618428115; cv=none; d=google.com; s=arc-20160816; b=ib98oGeCd68AGkvIBorKI+0r8dwrTNfxwsjvPZhgAUDjCOQ4UX7P9J9g3vIp5feKQc qiKEkN2jc0/5ejjd06xsThLl0oB5HnEKwSUtjliwpSKRQqJNlqlJnvRHIuo5H0OaTa7D /Bn2lW+WMJ71Pwa0nRTnXXSFlqGJrwX2IXHNE4WmPBkVKak22KnZ8Fj1oZ9fhoGNfNmy h612fFK+P0DqrvqmCvfRuAlrThtVWENsEWofqbJVXzU0kRMjOP61z3XLlWpFhPxU30DT xtbfw6I16piORVWp3OqI5P/EdKizuX+YuFll1MpvRfMygOiOaBZQKnqngmvn8ZMLogsS uaMw== 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:ironport-sdr:ironport-sdr; bh=CIM4+9C+spX+7wXx7zGjPHroTJdB2MeL6CqzycjzEVs=; b=CjR4CL+kgvfr68HXwrsBwzpkNWejM7CTPW0FWJGNgZenKCxUQDWBGtMerrFE7kS361 nwzC+uyl4HbHX1K9svZayr7306QHzHOKQbovsBSLYFQvB1f0njoIiMD6FAscn8id9su4 37GIuyaOzRm0dvzRWGUhie3Hp9wGIf7V4chOubJkUgy9eJdUpPRCFD90/aPkzfMk9sUx 3GBWGsJ5LwSqGsyfYXl0iAkuQYg3WY0jbVXez9xUDlpz/bJIIj2z7HdrdNf60AvGfAE/ mNmHRFvzu+b/ujTPJ4/vC/10VI+/OyaTAKILOa6hb0JXs3EQY2YmjynQyvJOaPSsLWLS Zd+A== 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 ds10si230415ejc.559.2021.04.14.12.21.30; Wed, 14 Apr 2021 12:21:55 -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 S229837AbhDNGBP (ORCPT + 99 others); Wed, 14 Apr 2021 02:01:15 -0400 Received: from mga17.intel.com ([192.55.52.151]:10337 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231629AbhDNGBN (ORCPT ); Wed, 14 Apr 2021 02:01:13 -0400 IronPort-SDR: mR04dnqzzjFzPyZreN2FhTTafTTB+IZhNjMBS8yDd0xxeAVCFLNGlQtPDTrqaRFdqNnxIfxGGk +r6W6W9TO5zw== X-IronPort-AV: E=McAfee;i="6200,9189,9953"; a="174679395" X-IronPort-AV: E=Sophos;i="5.82,221,1613462400"; d="scan'208";a="174679395" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2021 23:00:50 -0700 IronPort-SDR: iAAaup/KkwHp+utw+AfOGHomK6q2f7xNUUET0OhPGe8sqRiCmIErCfAJ5Zv03BOy6mxEKMWMWQ NhsjrcscwEdA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,221,1613462400"; d="scan'208";a="452304710" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.174]) ([10.237.72.174]) by fmsmga002.fm.intel.com with ESMTP; 13 Apr 2021 23:00:43 -0700 Subject: Re: [PATCH 2/2] perf intel-pt: Use aux_watermark To: Alexander Shishkin , Peter Zijlstra , Arnaldo Carvalho de Melo Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Jiri Olsa , Mathieu Poirier References: <20210408153159.81880-1-alexander.shishkin@linux.intel.com> <20210408153159.81880-3-alexander.shishkin@linux.intel.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: Date: Wed, 14 Apr 2021 09:00:59 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210408153159.81880-3-alexander.shishkin@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/04/21 6:31 pm, Alexander Shishkin wrote: > Turns out, the default setting of attr.aux_watermark to half of the total > buffer size is not very useful, especially with smaller buffers. The > problem is that, after half of the buffer is filled up, the kernel updates > ->aux_head and sets up the next "transaction", while observing that > ->aux_tail is still zero (as userspace haven't had the chance to update > it), meaning that the trace will have to stop at the end of this second > "transaction". This means, for example, that the second PERF_RECORD_AUX in > every trace comes with TRUNCATED flag set. > > Setting attr.aux_watermark to quarter of the buffer gives enough space for > the ->aux_tail update to be observed and prevents the data loss. > > The obligatory before/after showcase: > >> # perf_before record -e intel_pt//u -m,8 uname >> Linux >> [ perf record: Woken up 6 times to write data ] >> Warning: >> AUX data lost 4 times out of 10! >> >> [ perf record: Captured and wrote 0.099 MB perf.data ] >> # perf record -e intel_pt//u -m,8 uname >> Linux >> [ perf record: Woken up 4 times to write data ] >> [ perf record: Captured and wrote 0.039 MB perf.data ] > > The effect is still visible with large workloads and large buffers, > although less pronounced. > > Signed-off-by: Alexander Shishkin > --- > tools/perf/arch/x86/util/intel-pt.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c > index a6420c647959..d00707faf547 100644 > --- a/tools/perf/arch/x86/util/intel-pt.c > +++ b/tools/perf/arch/x86/util/intel-pt.c > @@ -776,6 +776,10 @@ static int intel_pt_recording_options(struct auxtrace_record *itr, > } > } > > + if (opts->full_auxtrace) > + intel_pt_evsel->core.attr.aux_watermark = > + opts->auxtrace_mmap_pages / 4 * page_size; > + I would be explicit about the mode and put "/ 4" at the end for the case auxtrace_mmap_pages is not a multiple of 4 (e.g. 2). i.e. if (!opts->auxtrace_snapshot_mode && !opts->auxtrace_sample_mode) { u32 aux_watermark = opts->auxtrace_mmap_pages * page_size / 4; intel_pt_evsel->core.attr.aux_watermark = aux_watermark; } > intel_pt_parse_terms(intel_pt_pmu->name, &intel_pt_pmu->format, > "tsc", &tsc_bit); > >