LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Jiri Olsa <jolsa@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Adrian Hunter <adrian.hunter@intel.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Corey Ashford <cjashfor@linux.vnet.ibm.com>,
	David Ahern <dsahern@gmail.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Ingo Molnar <mingo@kernel.org>,
	Jean Pihet <jean.pihet@linaro.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Paul Mackerras <paulus@samba.org>
Subject: Re: [PATCH 01/20] perf: Add PERF_EVENT_STATE_EXIT state for events with exited task
Date: Mon, 11 Aug 2014 14:01:02 +0200
Message-ID: <20140811120102.GY9918@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1407747014-18394-2-git-send-email-jolsa@kernel.org>


[-- Attachment #1: Type: text/plain, Size: 2402 bytes --]

On Mon, Aug 11, 2014 at 10:49:55AM +0200, Jiri Olsa wrote:
> ---
>  include/linux/perf_event.h |  1 +
>  kernel/events/core.c       | 12 ++++++++++--
>  2 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
> index 707617a8c0f6..54f3a6241386 100644
> --- a/include/linux/perf_event.h
> +++ b/include/linux/perf_event.h
> @@ -268,6 +268,7 @@ struct pmu {
>   * enum perf_event_active_state - the states of a event
>   */
>  enum perf_event_active_state {
> +	PERF_EVENT_STATE_EXIT		= -3,
>  	PERF_EVENT_STATE_ERROR		= -2,
>  	PERF_EVENT_STATE_OFF		= -1,
>  	PERF_EVENT_STATE_INACTIVE	=  0,
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 14086e45c5c4..dde0eefa410a 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -3499,7 +3499,8 @@ perf_read_hw(struct perf_event *event, char __user *buf, size_t count)
>  	 * error state (i.e. because it was pinned but it couldn't be
>  	 * scheduled on to the CPU at some point).
>  	 */
> -	if (event->state == PERF_EVENT_STATE_ERROR)
> +	if ((event->state == PERF_EVENT_STATE_ERROR) ||
> +	    (event->state == PERF_EVENT_STATE_EXIT))
>  		return 0;
>  
>  	if (count < event->read_size)
> @@ -3526,9 +3527,13 @@ static unsigned int perf_poll(struct file *file, poll_table *wait)
>  {
>  	struct perf_event *event = file->private_data;
>  	struct ring_buffer *rb;
> -	unsigned int events = POLL_HUP;
> +	unsigned int events = POLLHUP;

Should not that be an independent bugfix? It is a silly little thing
indeed, but it does change behaviour.

>  	poll_wait(file, &event->waitq, wait);
> +
> +	if (event->state == PERF_EVENT_STATE_EXIT)
> +		return POLLHUP;
> +

So, seeing how events is already POLLHUP here, why not return that?

>  	/*
>  	 * Pin the event->rb by taking event->mmap_mutex; otherwise
>  	 * perf_event_set_output() can swizzle our rb and make us miss wakeups.
> @@ -7484,6 +7489,9 @@ __perf_event_exit_task(struct perf_event *child_event,
>  	if (child_event->parent) {
>  		sync_child_event(child_event, child);
>  		free_event(child_event);
> +	} else {
> +		child_event->state = PERF_EVENT_STATE_EXIT;
> +		perf_event_wakeup(child_event);
>  	}
>  }

In any case, ACK on this patch, I'll assume you want to take the lot
through acme seeing how its mostly tools bits.

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

  reply index

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-11  8:49 [RFC 00/20] perf: Finish sampling commands when events are closed Jiri Olsa
2014-08-11  8:49 ` [PATCH 01/20] perf: Add PERF_EVENT_STATE_EXIT state for events with exited task Jiri Olsa
2014-08-11 12:01   ` Peter Zijlstra [this message]
2014-08-11 12:22     ` Jiri Olsa
2014-08-24 14:59     ` [tip:perf/core] perf: Fix perf_poll to return proper POLLHUP value tip-bot for Jiri Olsa
2014-08-24 14:59     ` [tip:perf/core] perf: Add PERF_EVENT_STATE_EXIT state for events with exited task tip-bot for Jiri Olsa
2014-08-11  8:49 ` [PATCH 02/20] perf tools: Add poller object to handle polling globaly Jiri Olsa
2014-08-11  8:49 ` [PATCH 03/20] perf tests: Add poller object test Jiri Olsa
2014-08-11  8:49 ` [PATCH 04/20] perf tools: Add support to traverse xyarrays Jiri Olsa
2014-08-11  8:49 ` [PATCH 05/20] perf tools: Introduce perf_evsel__fd function Jiri Olsa
2014-08-11  8:50 ` [PATCH 06/20] perf tools: Add evlist/evsel poller object support Jiri Olsa
2014-08-11  8:50 ` [PATCH 07/20] perf record: Add support to see event's ERR and HUP poll errors Jiri Olsa
2014-08-11  8:50 ` [PATCH 08/20] perf tools: Add set_term_quiet_input helper function Jiri Olsa
2014-08-14  8:43   ` [tip:perf/core] perf tools: Introduce " tip-bot for Jiri Olsa
2014-08-11  8:50 ` [PATCH 09/20] perf tui browser: Add interface to terminate browser from uotside Jiri Olsa
2014-08-11  8:50 ` [PATCH 10/20] perf top: Add support to see event's ERR and HUP poll errors Jiri Olsa
2014-08-11  8:50 ` [PATCH 11/20] perf top: Join the display thread on exit Jiri Olsa
2014-08-14  8:43   ` [tip:perf/core] " tip-bot for Jiri Olsa
2014-08-11  8:50 ` [PATCH 12/20] perf top: Use set_term_quiet_input for terminal input Jiri Olsa
2014-08-11  8:50 ` [PATCH 13/20] perf top: Setup signals for terminal output Jiri Olsa
2014-08-14  8:43   ` [tip:perf/core] " tip-bot for Jiri Olsa
2014-08-11  8:50 ` [PATCH 14/20] perf top: Use poller object for display thread stdin Jiri Olsa
2014-08-11  8:50 ` [PATCH 15/20] perf kvm: Fix stdin handling for 'kvm stat live' command Jiri Olsa
2014-08-14  8:43   ` [tip:perf/core] " tip-bot for Jiri Olsa
2014-08-11  8:50 ` [PATCH 16/20] perf kvm: Add support to see event's ERR and HUP poll errors Jiri Olsa
2014-08-11  8:50 ` [PATCH 17/20] perf trace: " Jiri Olsa
2014-08-11  8:50 ` [PATCH 18/20] perf python: Use poller object for polling Jiri Olsa
2014-08-11  8:50 ` [PATCH 19/20] perf tests: " Jiri Olsa
2014-08-11  8:50 ` [PATCH 20/20] perf tools: Remove pollfd stuff out of evlist object Jiri Olsa
2014-08-11 20:12 ` [RFC 00/20] perf: Finish sampling commands when events are closed Arnaldo Carvalho de Melo
2014-08-11 20:28   ` Arnaldo Carvalho de Melo
2014-08-12  7:33     ` Jiri Olsa
2014-08-12  7:29   ` Jiri Olsa

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=20140811120102.GY9918@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=cjashfor@linux.vnet.ibm.com \
    --cc=dsahern@gmail.com \
    --cc=fweisbec@gmail.com \
    --cc=jean.pihet@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=paulus@samba.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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git