Received: by 10.223.176.5 with SMTP id f5csp161541wra; Tue, 30 Jan 2018 09:31:36 -0800 (PST) X-Google-Smtp-Source: AH8x224XG0vUX12Dg4G9tl0HBqMDR3dR6f2MI9vdr29EQxaXb0bzM3CqaVavE7HTz9YyJreg7tIF X-Received: by 2002:a17:902:be09:: with SMTP id r9-v6mr26148054pls.234.1517333496169; Tue, 30 Jan 2018 09:31:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517333496; cv=none; d=google.com; s=arc-20160816; b=pkKMSWfY5zPOIQ6r9HVP9qng5g4mknRGjnTovgCZyxgfNxUul+RmXMESsuS0PByq/7 6QvZ6co3X+eksc8xwpxmlbkkwXa9/gSVDjhQzRsgucjRH8dm8lKm5x+VUUK1gWVlPRRW m5tQ5DWlu/dkW83ldMKEz8UM7UlWf9vxQvrViTHatnY0ktwgcmNRZC3NuPN4SRSoFnVe 5j+fc08TpXr9erLqxYh9Fd+1vTJJ/dI2GwJgTfQL6hqeltwvEReQeQ2kbvbdJ3vph+CP wCaVS6wSLPGTOJmYKPuBH3KLcm3e4S6dSp5HN5XQ2IVIWIaLvoeteoBcx05BrTpSkaQz FwWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=JFhonXUwrzUflxkLPGzhGYbjzghneencEiBLZwrcVgQ=; b=CstfOXhpNzLRlEMo03aV7smn/pdsPOh+pSqdRrY6yrSw1N1TyOTaJ5pECZOBTITPHE CumlrPWbHPvsCGFvwRF0HQlzhvZVnb50cYVZiBWvZnNwFiOJtSylqMABUz2LZKY4nX90 xRGblHDy0UTuEZ4m1Ptgwggr3toqJXcFv6rXutftxohmfhEGwFxA3t/nrtRoWmAJ20SH OVpaqVnx2XhgaX6iI0oISIbsPhBz+X95RkzThhl/qoIqGAFvyxnvpL4XeVf6idh6fE9E oO1NwjKzsGHEfg0a/9Vexkpf7UPW3ZtSfA8b0K7hwQqo+RxDC6+NDBE/eUcJulndNHlX n+fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RHQSyTnV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m21si1978764pgc.351.2018.01.30.09.31.21; Tue, 30 Jan 2018 09:31:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RHQSyTnV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752915AbeA3Qgs (ORCPT + 99 others); Tue, 30 Jan 2018 11:36:48 -0500 Received: from mail-io0-f196.google.com ([209.85.223.196]:34863 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751829AbeA3Qgr (ORCPT ); Tue, 30 Jan 2018 11:36:47 -0500 Received: by mail-io0-f196.google.com with SMTP id m11so12120204iob.2 for ; Tue, 30 Jan 2018 08:36:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=JFhonXUwrzUflxkLPGzhGYbjzghneencEiBLZwrcVgQ=; b=RHQSyTnVx0NBe9/IOGQbZmgYtmjaOW4eOGpkOVozeRq1BcWPbtcqwHeen758X//YcV YmtNZRRDPIA9i3ry0E4VrzDPKHhWkNHiyRkAg6XMyJRTO5CgXsZ7myfF22jlJUkSnBGN 5mDpG0I7Q8w/64lNUKBB2c1fg+yHm51szaBTSDk5QeLyiDuD6KrjL17p11+/2HLFXq6k 5GBjSEm4TVQRvSP8YEDrNV4myEUrR1oAOppOg9jWNxez0Xg3cjg5QdRQC2NIGVHt3+HE pqXyhj4DmfwM6Qu1UIIF7fyaUJqu96onhdS+nVQWzsmAAuqSutRYbM1ofi6+4SYcDV15 MHag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=JFhonXUwrzUflxkLPGzhGYbjzghneencEiBLZwrcVgQ=; b=MELS3lEL7kKc5LipCt/hyhvWDSDQ63nHPXZJR8Jd4CvTc1ZL5a7N3BUdfy7xe/xV3j yA/bOYYB9QIeG1rStbX82FmnPvQf+tsS57hmEPBJlchPtx5CeOBBqIHFgwglYcTS48eh F3e3KGSOEHTUK+VAuEPzBxa/282vi6YFiduLwx9gnU+6U7KRtkb5AQl3qrCJmcgaYweN q/dOiDIwC2rcKzZz75QaOlc5rA9fnGZfQTL9KlAqIoOlG6UlghJC5PVpi2SsNrlSYo4A qlYlXbsXo+iCFGH2L+FR828fJK1HgMGcqpgOCVsNVORZZ1slozeahiLtZvix5cJFzLJe 4aew== X-Gm-Message-State: AKwxytd6fKN3nva711JKNJlFC6IDmK3Qn7dijVuVQ+geTJc93GWE4S3+ n0GPYN1dQlfFQtuBVk8CXc+PqTDyb8hjflGsh6Er1Q== X-Received: by 10.107.19.213 with SMTP id 82mr29991386iot.276.1517330206262; Tue, 30 Jan 2018 08:36:46 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.170.39 with HTTP; Tue, 30 Jan 2018 08:36:45 -0800 (PST) In-Reply-To: <35090c62-466a-aec8-b1a3-69def959c1c6@linux.intel.com> References: <1517243373-355481-1-git-send-email-kan.liang@linux.intel.com> <20180130133917.GC29098@krava> <6d708c09-52a7-a906-b651-b133a7b4f189@linux.intel.com> <20180130150454.GE29098@krava> <35090c62-466a-aec8-b1a3-69def959c1c6@linux.intel.com> From: Stephane Eranian Date: Tue, 30 Jan 2018 08:36:45 -0800 Message-ID: Subject: Re: [PATCH V3 0/5] bugs fix for large PEBS mmap read and rdpmc read To: "Liang, Kan" Cc: Jiri Olsa , Peter Zijlstra , Ingo Molnar , LKML , Arnaldo Carvalho de Melo , Thomas Gleixner , Andi Kleen Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 30, 2018 at 7:25 AM, Liang, Kan wrote: > > > On 1/30/2018 10:04 AM, Jiri Olsa wrote: >> >> On Tue, Jan 30, 2018 at 09:59:15AM -0500, Liang, Kan wrote: >>> >>> >>> >>> On 1/30/2018 8:39 AM, Jiri Olsa wrote: >>>> >>>> On Tue, Jan 30, 2018 at 01:16:39AM -0800, Stephane Eranian wrote: >>>>> >>>>> Hi, >>>>> >>>>> On Mon, Jan 29, 2018 at 8:29 AM, wrote: >>>>>> >>>>>> >>>>>> From: Kan Liang >>>>>> >>>>>> ------ >>>>>> >>>>>> Changes since V2: >>>>>> - Refined the changelog >>>>>> - Introduced specific read function for large PEBS. >>>>>> The previous generic PEBS read function is confusing. >>>>>> Disabled PMU in pmu::read() path for large PEBS. >>>>>> Handled the corner case when reload_times == 0. >>>>>> - Modified the parameter of intel_pmu_save_and_restart_reload() >>>>>> Discarded local64_cmpxchg >>>>>> - Added fixes tag >>>>>> - Added WARN to handle reload_times == 0 || reload_val == 0 >>>>>> >>>>>> Changes since V1: >>>>>> - Check PERF_X86_EVENT_AUTO_RELOAD before call >>>>>> intel_pmu_save_and_restore() >>>>> >>>>> >>>>> It is not yet clear to me why PERF_SAMPLE_PERIOD is not allowed >>>>> with large PEBS. Large PEBS requires fixed period. So the kernel could >>>>> make up the period from the event and store it in the sampling buffer. >>>>> >>>>> I tried using large PEBS recently, and despite trying different option >>>>> combination of perf record, I was not able to get it to work. >>>>> >>>>> $ perf record -c 1 -e cpu/event=0xd1,umask=0x10,period=19936/pp >>>>> --no-timestamp --no-period -a -C 0 >>>>> >>>>> But I was able to make this work with a much older kernel. >>>>> >>>>> Another annoyance I ran into is with perf record requiring -c period >>>>> in order not to set >>>>> PERF_SAMPLE_PERIOD in the event. >>>>> >>>>> If I do: >>>>> perf record -c 1 -e cpu/event=0xd1,umask=0x10,period=19936/pp >>>>> --no-timestamp --no-period -a -C 0 >>>>> >>>>> I get >>>>> >>>>> perf_event_attr: >>>>> type 4 >>>>> size 112 >>>>> config 0x10d1 >>>>> { sample_period, sample_freq } 199936 >>>>> sample_type IP|TID|CPU >>>>> >>>>> But if I do: >>>>> perf record -e cpu/event=0xd1,umask=0x10,period=19936/pp >>>>> --no-timestamp --no-period -a -C 0 >>>>> >>>>> I get >>>>> >>>>> perf_event_attr: >>>>> type 4 >>>>> size 112 >>>>> config 0x10d1 >>>>> { sample_period, sample_freq } 199936 >>>>> sample_type IP|TID|CPU|PERIOD >>>>> >>>>> Perf should check if all events have a period=, then it should not >>>>> pass PERF_SAMPLE_PERIOD, even >>>>> more so when only one event is defined. >>>>> >>>>> Also it does not seem to honor --no-period. >>>> >>>> >>>> yep, there's a bug in period=x term handling >>>> we did not re/set the sample_type based on that >>>> >>>> attached patch fixes that for me, also takes into account >>>> the --no/-period options >>>> >>>> jirka >>>> >>>> >>>> --- >>>> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c >>>> index f251e824edac..907267206973 100644 >>>> --- a/tools/perf/builtin-record.c >>>> +++ b/tools/perf/builtin-record.c >>>> @@ -1566,7 +1566,8 @@ static struct option __record_options[] = { >>>> OPT_BOOLEAN_SET('T', "timestamp", &record.opts.sample_time, >>>> &record.opts.sample_time_set, >>>> "Record the sample timestamps"), >>>> - OPT_BOOLEAN('P', "period", &record.opts.period, "Record the >>>> sample period"), >>>> + OPT_BOOLEAN_SET('P', "period", &record.opts.period, >>>> &record.opts.period_set, >>>> + "Record the sample period"), >>>> OPT_BOOLEAN('n', "no-samples", &record.opts.no_samples, >>>> "don't sample"), >>>> OPT_BOOLEAN_SET('N', "no-buildid-cache", >>>> &record.no_buildid_cache, >>>> diff --git a/tools/perf/perf.h b/tools/perf/perf.h >>>> index 2357f4ccc9c7..cfe46236a5e5 100644 >>>> --- a/tools/perf/perf.h >>>> +++ b/tools/perf/perf.h >>>> @@ -50,6 +50,7 @@ struct record_opts { >>>> bool sample_time_set; >>>> bool sample_cpu; >>>> bool period; >>>> + bool period_set; >>>> bool running_time; >>>> bool full_auxtrace; >>>> bool auxtrace_snapshot_mode; >>>> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c >>>> index 66fa45198a11..ff359c9ece2e 100644 >>>> --- a/tools/perf/util/evsel.c >>>> +++ b/tools/perf/util/evsel.c >>>> @@ -745,12 +745,14 @@ static void apply_config_terms(struct perf_evsel >>>> *evsel, >>>> if (!(term->weak && opts->user_interval != >>>> ULLONG_MAX)) { >>>> attr->sample_period = term->val.period; >>>> attr->freq = 0; >>>> + perf_evsel__reset_sample_bit(evsel, >>>> PERIOD); >>>> } >>>> break; >>>> case PERF_EVSEL__CONFIG_TERM_FREQ: >>>> if (!(term->weak && opts->user_freq != >>>> UINT_MAX)) { >>>> attr->sample_freq = term->val.freq; >>>> attr->freq = 1; >>>> + perf_evsel__set_sample_bit(evsel, >>>> PERIOD); >>>> } >>> >>> >>> If we do so, some events could be in fixed mode without PERIOD set. Other >>> events could be in freq mode with PERIOD set. >> >> >> it also sets the attr->freq, so it's not in fixed mode >> > > I mean the TERM_PERIOD. It probably enable the large PEBS. >>>> attr->freq = 0; >>>> + perf_evsel__reset_sample_bit(evsel, PERIOD); > > The events in fixed mode could enable large PEBS. Events in freq mode should > not enable large PEBS. > I think that could be a problem if some events try to enable large PEBS, > while others not. > You only enable large PEBS if 100% of the events use fixed periods, either via -c period or because they all use individual period=p. The --no-period could also be used to remove the period for measurements where the period is not needed. > Thanks, > Kan > >