linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Song Liu <songliubraving@fb.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: open list <linux-kernel@vger.kernel.org>,
	Kernel Team <Kernel-team@fb.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Alexey Budankov <alexey.budankov@linux.intel.com>,
	Namhyung Kim <namhyung@kernel.org>, Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH v9] perf: Sharing PMU counters across compatible events
Date: Thu, 16 Jan 2020 23:59:13 +0000	[thread overview]
Message-ID: <CDB64D32-4E89-4884-88B8-66DCB1DFA8E3@fb.com> (raw)
In-Reply-To: <CF654118-59C1-46AA-B9DB-CA14D9FFACF7@fb.com>

Hi Peter, 

> On Jan 10, 2020, at 9:37 AM, Song Liu <songliubraving@fb.com> wrote:
> 
>>> 
>>> @@ -2242,9 +2494,9 @@ static void __perf_event_disable(struct perf_event *event,
>>> 	}
>>> 
>>> 	if (event == event->group_leader)
>>> -		group_sched_out(event, cpuctx, ctx);
>>> +		group_sched_out(event, cpuctx, ctx, true);
>>> 	else
>>> -		event_sched_out(event, cpuctx, ctx);
>>> +		event_sched_out(event, cpuctx, ctx, true);
>>> 
>>> 	perf_event_set_state(event, PERF_EVENT_STATE_OFF);
>>> }
>> 
>> So the above event_sched_out(.remove_dup) is very inconsistent with the
>> below ctx_resched(.event_add_dup).
> 
> [...]
> 
>>> @@ -2810,7 +3069,7 @@ static void __perf_event_enable(struct perf_event *event,
>>> 	if (ctx->task)
>>> 		WARN_ON_ONCE(task_ctx != ctx);
>>> 
>>> -	ctx_resched(cpuctx, task_ctx, get_event_type(event));
>>> +	ctx_resched(cpuctx, task_ctx, get_event_type(event), event);
>>> }
>>> 
>>> /*
>> 
>> We basically need:
>> 
>> * perf_event_setup_dup() after add_event_to_ctx(), but before *sched_in()
>>  - perf_install_in_context()
>>  - perf_event_enable()
>>  - inherit_event()
>> 
>> * perf_event_remove_dup() after *sched_out(), but before list_del_event()
>>  - perf_remove_from_context()
>>  - perf_event_disable()

Quick question:

For the remove_dup() path, if we do it after *_sched_out(), we will need to 
disable-then-enable the pmu for one extra time. In current version, we only
call perf_event_remove_dup() in event_sched_out(), where extra disable/enable
is not necessary. Is it a good tradeoff to add one extra disable-enable for 
cleaner code?

Thanks,
Song

      reply	other threads:[~2020-01-17  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-17 17:59 [PATCH v9] perf: Sharing PMU counters across compatible events Song Liu
2020-01-02 18:45 ` Song Liu
2020-01-10 12:59 ` Peter Zijlstra
2020-01-10 17:37   ` Song Liu
2020-01-16 23:59     ` Song Liu [this message]

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=CDB64D32-4E89-4884-88B8-66DCB1DFA8E3@fb.com \
    --to=songliubraving@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=acme@redhat.com \
    --cc=alexey.budankov@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tj@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;
as well as URLs for NNTP newsgroup(s).