From: David Ahern <dsahern@gmail.com>
To: Adrian Hunter <adrian.hunter@intel.com>,
David Ahern <david.ahern@oracle.com>,
acme@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf: Fix probing for PERF_FLAG_FD_CLOEXEC flag
Date: Thu, 19 Feb 2015 07:55:31 -0700 [thread overview]
Message-ID: <54E5F963.50200@gmail.com> (raw)
In-Reply-To: <54E58B64.9010902@intel.com>
On 2/19/15 12:06 AM, Adrian Hunter wrote:
>> /* not supported, confirm error related to PERF_FLAG_FD_CLOEXEC */
>> - fd = sys_perf_event_open(&attr, pid, cpu, -1, 0);
>> + fd = sys_perf_event_open(&attr, 0, cpu, -1, 0);
>
> I would prefer to avoid pid = 0 unless necessary and so just do the same
> thing again i.e.
>
> while (1) {
> fd = sys_perf_event_open(&attr, pid, cpu, -1, 0);
> if (fd < 0 && pid == -1 && errno == EACCES) {
> pid = 0;
> continue;
> }
> break;
> }
>
The probing is getting of hand. In this case the intent is a probe for a
flag and flags are the first thing checked kernel side. Given that the
parameters passed to sys_perf_event_open should be as simple and known
safe as possible. pid = -1 has known limitations. Why can't pid just be
getpid() in both cases?
Simplifies this function a lot and removes the need for sched_getcpu(). So
pid = getpid();
fd = sys_perf_event_open(&attr, pid, -1, -1, PERF_FLAG_FD_CLOEXEC);
and if that fails
fd = sys_perf_event_open(&attr, pid, -1, -1, 0);
Why is anything more complicated needed?
David
next prev parent reply other threads:[~2015-02-19 14:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-19 0:01 [PATCH] perf: Fix probing for PERF_FLAG_FD_CLOEXEC flag David Ahern
2015-02-19 7:06 ` Adrian Hunter
2015-02-19 14:55 ` David Ahern [this message]
2015-02-19 16:17 ` Adrian Hunter
2015-02-19 16:22 ` David Ahern
2015-02-19 17:28 ` Adrian Hunter
2015-02-24 11:31 ` Adrian Hunter
2015-02-24 16:31 ` David Ahern
2015-03-01 16:50 ` [tip:perf/urgent] perf tools: " tip-bot for Adrian Hunter
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=54E5F963.50200@gmail.com \
--to=dsahern@gmail.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=david.ahern@oracle.com \
--cc=linux-kernel@vger.kernel.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