From: Jiri Olsa <jolsa@redhat.com>
To: Mengting Zhang <zhangmengting@huawei.com>
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
acme@redhat.com, huawei.libin@huawei.com, wangnan0@huawei.com,
cj.chengjian@huawei.com
Subject: Re: [PATCH v3] perf evsel: Enable ignore_missing_thread for pid option
Date: Wed, 13 Dec 2017 14:56:56 +0100 [thread overview]
Message-ID: <20171213135656.GC14376@krava> (raw)
In-Reply-To: <1513148513-6974-1-git-send-email-zhangmengting@huawei.com>
On Wed, Dec 13, 2017 at 03:01:53PM +0800, Mengting Zhang wrote:
> While monitoring a multithread process with pid option, perf sometimes
> may return sys_perf_event_open failure with 3(No such process) if any
> of the process's threads die before we open the event. However, we want
> perf continue monitoring the remaining threads and do not exit with error.
>
> Here, the patch enables perf_evsel::ignore_missing_thread for -p option
> to ignore complete failure if any of threads die before we open the event.
> But it may still return sys_perf_event_open failure with 22(Invalid) if we
> monitors several event groups.
>
> sys_perf_event_open: pid 28960 cpu 40 group_fd 118202 flags 0x8
> sys_perf_event_open: pid 28961 cpu 40 group_fd 118203 flags 0x8
> WARNING: Ignored open failure for pid 28962
> sys_perf_event_open: pid 28962 cpu 40 group_fd [118203] flags 0x8
> sys_perf_event_open failed, error -22
>
> That is because when we ignore a missing thread, we change the thread_idx
> without dealing with its fds, FD(evsel, cpu, thread). Then get_group_fd()
> may return a wrong group_fd for the next thread and sys_perf_event_open()
> return with 22.
>
> sys_perf_event_open(){
> ...
> if (group_fd != -1)
> perf_fget_light()//to get corresponding group_leader by group_fd
> ...
> if (group_leader)
> if (group_leader->ctx->task != ctx->task)//should on the same task
> goto err_context
> ...
> }
>
> This patch also fixes this bug by introducing perf_evsel__remove_fd() and
> update_fds to allow removing fds for the missing thread.
>
> Changes since v1:
> - Change group_fd__remove() into a more genetic way without changing code logic
> - Remove redundant condition
>
> Changes since v2:
> - Use a proper function name and add some comment.
> - Multiline comment style fixes.
Acked-by: Jiri Olsa <jolsa@kernel.org>
thanks,
jirka
next prev parent reply other threads:[~2017-12-13 13:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-13 7:01 [PATCH v3] perf evsel: Enable ignore_missing_thread for pid option Mengting Zhang
2017-12-13 7:01 ` Mengting Zhang
2017-12-13 13:56 ` Jiri Olsa [this message]
2017-12-13 20:54 ` Arnaldo Carvalho de Melo
2017-12-13 20:56 ` Arnaldo Carvalho de Melo
2017-12-28 15:35 ` [tip:perf/core] " tip-bot for Mengting Zhang
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=20171213135656.GC14376@krava \
--to=jolsa@redhat.com \
--cc=acme@redhat.com \
--cc=cj.chengjian@huawei.com \
--cc=huawei.libin@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=wangnan0@huawei.com \
--cc=zhangmengting@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.