mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Wangnan (F)" <wangnan0@huawei.com>
To: "Liang, Kan" <kan.liang@intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"acme@kernel.org" <acme@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
	"Hunter, Adrian" <adrian.hunter@intel.com>,
	Andi Kleen <ak@linux.intel.com>, Li Zefan <lizefan@huawei.com>
Subject: Re: [PATCH] perf tools: fix: Force backward ring buffer mapped readonly
Date: Thu, 12 Oct 2017 22:46:08 +0800	[thread overview]
Message-ID: <1a46c859-13a1-ec6e-b27a-e54570ee8e11@huawei.com> (raw)
In-Reply-To: <37D7C6CF3E00A74B8858931C1DB2F077537D2925@SHSMSX103.ccr.corp.intel.com>



On 2017/10/12 22:45, Liang, Kan wrote:
>> On 2017/10/12 20:56, Liang, Kan wrote:
>>>> On 2017/10/11 21:16, Liang, Kan wrote:
>>>>>> perf record's --overwrite option doesn't work as we expect.
>>>>>> For example:
>>>> [SNIP]
>>>>
>>>>>> In the above example we get same records from the backward ring
>>>>>> buffer all the time. Overwriting is not triggered.
>>>>>>
>>>>>> This commit maps backward ring buffers readonly, make it overwritable.
>>>>>> It is safe because we assume backward ring buffer always overwritable
>>>>>> in other part of code.
>>>>>>
>>>>>> After applying this patch:
>>>>>>
>>>>>>        $ ~/linux/tools/perf$ sudo ./perf record -m 4 -e raw_syscalls:*
>>>>>> -g -- overwrite \
>>>>>> 	    			   --switch-output=1s --tail-synthesize   dd
>>>>>> if=/dev/zero of=/dev/null
>>>> [SNIP]
>>>>
>>>>>> Signed-off-by: Wang Nan <wangnan0@huawei.com>
>>>>>> Cc: Liang Kan <kan.liang@intel.com>
>>>>>> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
>>>>>> Cc: Peter Zijlstra <peterz@infradead.org>
>>>>>> Cc: Ingo Molnar <mingo@kernel.org>
>>>>>> Cc: Jiri Olsa <jolsa@kernel.org>
>>>>>> Cc: Namhyung Kim <namhyung@kernel.org>
>>>>>> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
>>>>>> Cc: Adrian Hunter <adrian.hunter@intel.com>
>>>>>> Cc: Andi Kleen <ak@linux.intel.com>
>>>>>> Cc: Li Zefan <lizefan@huawei.com>
>>>>>> ---
>>>>>>     tools/perf/util/evlist.c | 7 ++++++-
>>>>>>     1 file changed, 6 insertions(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
>>>>>> index c6c891e..a86b0d2 100644
>>>>>> --- a/tools/perf/util/evlist.c
>>>>>> +++ b/tools/perf/util/evlist.c
>>>>>> @@ -799,12 +799,14 @@ perf_evlist__should_poll(struct perf_evlist
>>>>>> *evlist __maybe_unused,
>>>>>>     }
>>>>>>
>>>>>>     static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int
>> idx,
>>>>>> -				       struct mmap_params *mp, int cpu_idx,
>>>>>> +				       struct mmap_params *_mp, int cpu_idx,
>>>>>>     				       int thread, int *_output, int
>>>>>> *_output_backward)
>>>>>>     {
>>>>>>     	struct perf_evsel *evsel;
>>>>>>     	int revent;
>>>>>>     	int evlist_cpu = cpu_map__cpu(evlist->cpus, cpu_idx);
>>>>>> +	struct mmap_params *mp = _mp;
>>>>>> +	struct mmap_params backward_mp;
>>>>>>
>>>>>>     	evlist__for_each_entry(evlist, evsel) {
>>>>>>     		struct perf_mmap *maps = evlist->mmap; @@ -815,6 +817,9
>>>> @@ static
>>>>>> int perf_evlist__mmap_per_evsel(struct
>>>>>> perf_evlist *evlist, int idx,
>>>>>>     		if (evsel->attr.write_backward) {
>>>>>>     			output = _output_backward;
>>>>>>     			maps = evlist->backward_mmap;
>>>>>> +			backward_mp = *mp;
>>>>>> +			backward_mp.prot &= ~PROT_WRITE;
>>>>>> +			mp = &backward_mp;
>>>>>>
>>>>>>     			if (!maps) {
>>>>>>     				maps = perf_evlist__alloc_mmap(evlist);
>>>>> So it's trying to support per-event overwrite.
>>>>> How about the global --overwrite option?
>>>> Not only the per-event overwrite. See the example above. The overall --
>>>> overwrite option is also respected. In perf_evsel__config, per-event evsel
>>>> 'backward' setting is set based on overall '--overwrite' and per-event
>>>> '/overwrite/' setting.
>>> But how about evlist->overwrite? I think it still keeps the wrong setting.
>>> The overwrite is implicitly applied. Some settings are inconsistent.
>>>
>>> Is there any drawback if you use opts->overwrite for
>> perf_evlist__mmap_ex?
>>
>> We will always face such inconsistency, because we have
>> an /no-overwrite/ option which can be set per-evsel.
>> Setting evlist->overwrite won't make things more consistent,
>> because in a evlist, different evsel can have different
>> overwrite setting. A simple solution is making evlist
>> non-overwrite by default, and watch all overwrite evsels
>> a special cases. Then we have only 2 cases to consider:
>>
>> 1. overwrite evsel in a non-overwrite evlist.
>> 2. non-overwrite evsel in a non-overwrite evlist.
>>
> If evlist->overwrite is always non-overwrite, why not remove it?
>   

Some testcases require it.

Thank you.

  reply	other threads:[~2017-10-12 14:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-12 14:00 Wang Nan
2017-10-11 13:16 ` Liang, Kan
2017-10-12  1:03   ` Wangnan (F)
2017-10-12 12:56     ` Liang, Kan
2017-10-12 14:35       ` Wangnan (F)
2017-10-12 14:45         ` Liang, Kan
2017-10-12 14:46           ` Wangnan (F) [this message]
2017-10-12 14:52             ` Wangnan (F)
2017-10-12 15:11               ` Liang, Kan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1a46c859-13a1-ec6e-b27a-e54570ee8e11@huawei.com \
    --to=wangnan0@huawei.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®