linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Wangnan (F)" <wangnan0@huawei.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: <pi3orama@163.com>, <linux-kernel@vger.kernel.org>,
	He Kuang <hekuang@huawei.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>, Zefan Li <lizefan@huawei.com>
Subject: Re: [PATCH v7 7/8] perf tools: Check write_backward during evlist config
Date: Mon, 20 Jun 2016 12:09:44 +0800	[thread overview]
Message-ID: <57676C88.2080908@huawei.com> (raw)
In-Reply-To: <20160616214724.GI13337@kernel.org>



On 2016/6/17 5:47, Arnaldo Carvalho de Melo wrote:
> Em Wed, Jun 15, 2016 at 02:23:34AM +0000, Wang Nan escreveu:
>> Before this patch, when using overwritable ring buffer on an old
>> kernel, error message is misleading:
>>
>>   # ~/perf record -m 1 -e raw_syscalls:*/overwrite/ -a
>>   Error:
>>   The raw_syscalls:sys_enter event is not supported.
>>
>> This patch output clear error message to tell user his/her kernel
>> is too old:
>>
>>   # ~/perf record -m 1 -e raw_syscalls:*/overwrite/ -a
>>   Reading from overwrite event is not supported by this kernel
>>   Error:
>>   The raw_syscalls:sys_enter event is not supported.
> So I went to see if exposing that missing_features struct outside
> evsel.c was strictly needed and found that we already have fallbacking
> for this feature (attr.write_backwards) i.e. if we set it and
> sys_perf_event_open() fails, we will check if we are asking the kernel
> for some attr. field that it doesn't supports, set that missing_features
> and try again.
>
> But the way this was done for attr.write_backwards was buggy, as we need
> to check features in the inverse order of their introduction to the
> kernel, so that a newer tool checks first the newest perf_event_attr
> fields, detecting that the older kernel doesn't have support for them.
> The patch that introduced write_backwards support ([1]) in perf_evsel__open()
> did this checking after all the other older attributes, wrongly.
>
> [1]: b90dc17a5d14 ("perf evsel: Add overwrite attribute and check write_backward")
>
> Also we shouldn't even try to call sys_perf_event_open if
> perf_missing_features.write_backward is true and evsel->overwrite is
> also true, the old code would check this only after successfully opening
> the fd, do it before the open loop.
>
> Please take a look at the following patch, see if it is sufficient for
> handling older kernels, probably we need to emit a message to the user,
> but that has to be done at the builtin- level, i.e. at the tool, i.e.
> perf_evsel_open__strerror() should have what it takes to figure out this
> extra error and provide/ a proper string, lemme add this to the patch...
> done, please check:
>
> write_backwards_fallback.patch:

[SNIP]

>   
> @@ -1496,7 +1493,10 @@ try_fallback:
>   	 * Must probe features in the order they were added to the
>   	 * perf_event_attr interface.
>   	 */

I read this comment but misunderstand. I thought 'order' means newest last.

Will try your patch. Thank you.

> -	if (!perf_missing_features.clockid_wrong && evsel->attr.use_clockid) {
> +	if (!perf_missing_features.write_backward && evsel->attr.write_backward) {
> +		perf_missing_features.write_backward = true;
> +		goto fallback_missing_features;
> +	} else if (!perf_missing_features.clockid_wrong && evsel->attr.use_clockid) {
>   		perf_missing_features.clockid_wrong = true;
>   		goto fallback_missing_features;
>   	} else if (!perf_missing_features.clockid && evsel->attr.use_clockid) {
> @@ -1521,10 +1521,6 @@ try_fallback:
>   			  PERF_SAMPLE_BRANCH_NO_FLAGS))) {
>   		perf_missing_features.lbr_flags = true;
>   		goto fallback_missing_features;
> -	} else if (!perf_missing_features.write_backward &&
> -			evsel->attr.write_backward) {
> -		perf_missing_features.write_backward = true;
> -		goto fallback_missing_features;
>   	}
>   
>   out_close:
> @@ -2409,6 +2405,8 @@ int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target,
>   	"We found oprofile daemon running, please stop it and try again.");
>   		break;
>   	case EINVAL:
> +		if (evsel->overwrite && perf_missing_features.write_backward)
> +			return scnprintf(msg, size, "Reading from overwrite event is not supported by this kernel.");
>   		if (perf_missing_features.clockid)
>   			return scnprintf(msg, size, "clockid feature not supported.");
>   		if (perf_missing_features.clockid_wrong)

  reply	other threads:[~2016-06-20  4:11 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-15  2:23 [PATCH v7 0/8] perf tools: Support overwritable ring buffer Wang Nan
2016-06-15  2:23 ` [PATCH v7 1/8] perf evlist: Introduce aux evlist Wang Nan
2016-06-15  2:23 ` [PATCH v7 2/8] perf tests: Add testcase for auxiliary evlist Wang Nan
2016-06-15  2:23 ` [PATCH v7 3/8] perf record: Introduce rec->overwrite_evlist for overwritable events Wang Nan
2016-06-15  2:23 ` [PATCH v7 4/8] perf record: Toggle overwrite ring buffer for reading Wang Nan
2016-06-15  2:23 ` [PATCH v7 5/8] perf tools: Enable overwrite settings Wang Nan
2016-06-15  2:23 ` [PATCH v7 6/8] perf tools: Don't warn about out of order event if write_backward is used Wang Nan
2016-06-15  2:23 ` [PATCH v7 7/8] perf tools: Check write_backward during evlist config Wang Nan
2016-06-16 21:47   ` Arnaldo Carvalho de Melo
2016-06-20  4:09     ` Wangnan (F) [this message]
2016-06-22  7:43     ` [tip:perf/core] perf evsel: Fix write_backwards fallback tip-bot for Arnaldo Carvalho de Melo
2016-06-15  2:23 ` [PATCH v7 8/8] perf record: Unmap overwrite evlist when event terminate Wang Nan
2016-06-16 20:59   ` Arnaldo Carvalho de Melo
2016-06-20  8:04     ` Wangnan (F)
  -- strict thread matches above, loose matches on Subject: below --
2016-06-20 10:47 [PATCH v8 0/8] perf tools: Support overwritable ring buffer Wang Nan
2016-06-20 10:47 ` [PATCH v8 1/8] perf tools: Fix write_backwards fallback Wang Nan
2016-06-20 10:47 ` [PATCH v8 2/8] perf evlist: Introduce aux evlist Wang Nan
2016-06-20 20:36   ` Arnaldo Carvalho de Melo
2016-06-21  1:31     ` Wangnan (F)
2016-06-20 10:47 ` [PATCH v8 3/8] perf tests: Add testcase for auxiliary evlist Wang Nan
2016-06-21 21:05   ` Arnaldo Carvalho de Melo
2016-06-22  4:10     ` Wangnan (F)
2016-06-20 10:47 ` [PATCH v8 4/8] perf record: Introduce rec->overwrite_evlist for overwritable events Wang Nan
2016-06-21 21:30   ` Arnaldo Carvalho de Melo
2016-06-20 10:47 ` [PATCH v8 5/8] perf record: Toggle overwrite ring buffer for reading Wang Nan
2016-06-20 10:47 ` [PATCH v8 6/8] perf tools: Enable overwrite settings Wang Nan
2016-06-21 21:49   ` Arnaldo Carvalho de Melo
2016-06-20 10:47 ` [PATCH v8 7/8] perf tools: Don't warn about out of order event if write_backward is used Wang Nan
2016-06-20 10:47 ` [PATCH v8 8/8] perf tools: Add --tail-synthesize option Wang Nan

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=57676C88.2080908@huawei.com \
    --to=wangnan0@huawei.com \
    --cc=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=hekuang@huawei.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=mhiramat@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=pi3orama@163.com \
    /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;
as well as URLs for NNTP newsgroup(s).