mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Metcalf <cmetcalf@ezchip.com>
To: Frederic Weisbecker <fweisbec@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Luiz Capitulino <lcapitulino@redhat.com>,
	Christoph Lameter <cl@linux.com>, Ingo Molnar <mingo@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Rik van Riel <riel@redhat.com>
Subject: Re: [PATCH 3/7] perf: Migrate perf to use new tick dependency mask model
Date: Tue, 24 Nov 2015 11:19:33 -0500	[thread overview]
Message-ID: <56548E15.5050004@ezchip.com> (raw)
In-Reply-To: <1447424529-13671-4-git-send-email-fweisbec@gmail.com>

On 11/13/2015 09:22 AM, Frederic Weisbecker wrote:
> Instead of providing asynchronous checks for the nohz subsystem to verify
> perf event tick dependency, migrate perf to the new mask.
>
> Perf needs the tick for two situations:
>
> 1) Freq events. We could set the tick dependency when those are
> installed on a CPU context. But setting a global dependency on top of
> the global freq events accounting is much easier. If people want that
> to be optimized, we can still refine that on the per-CPU tick dependency
> level. This patch dooesn't change the current behaviour anyway.
>
> 2) Throttled events: this is a per-cpu dependency.
>
>
> @@ -3540,8 +3530,10 @@ static void unaccount_event(struct perf_event *event)
>   		atomic_dec(&nr_comm_events);
>   	if (event->attr.task)
>   		atomic_dec(&nr_task_events);
> -	if (event->attr.freq)
> -		atomic_dec(&nr_freq_events);
> +	if (event->attr.freq) {
> +		if (atomic_dec_and_test(&nr_freq_events))
> +			tick_nohz_clear_dep(TICK_PERF_EVENTS_BIT);
> +	}
>   	if (event->attr.context_switch) {
>   		static_key_slow_dec_deferred(&perf_sched_events);
>   		atomic_dec(&nr_switch_events);
>
> @@ -7695,7 +7687,7 @@ static void account_event(struct perf_event *event)
>   		atomic_inc(&nr_task_events);
>   	if (event->attr.freq) {
>   		if (atomic_inc_return(&nr_freq_events) == 1)
> -			tick_nohz_full_kick_all();
> +			tick_nohz_set_dep(TICK_PERF_EVENTS_BIT);
>   	}
>   	if (event->attr.context_switch) {
>   		atomic_inc(&nr_switch_events);

It would be helpful to have a comment explaining why these two
can't race with each other, e.g. this race:

[cpu 1]  atomic_dec_and_test
[cpu 2] atomic_inc_return
[cpu 2] tick_nohz_set_dep()
[cpu 1] tick_nohz_clear_dep()

Or perhaps this is a true race condition possibility?

I think we're OK for the sched cases since they're protected under
the rq lock, I think.  I'm not sure about the POSIX cpu timers.

-- 
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com


  reply	other threads:[~2015-11-24 16:19 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-13 14:22 [PATCH 0/7] nohz: Tick dependency mask v3 Frederic Weisbecker
2015-11-13 14:22 ` [PATCH 1/7] atomic: Export fetch_or() Frederic Weisbecker
2015-11-24 15:58   ` Chris Metcalf
2015-11-24 21:19     ` Frederic Weisbecker
2015-11-24 21:48       ` Chris Metcalf
2015-11-30 17:36         ` Frederic Weisbecker
2015-11-30 18:17           ` Chris Metcalf
2015-11-25  9:13       ` Peter Zijlstra
2015-11-13 14:22 ` [PATCH 2/7] nohz: New tick dependency mask Frederic Weisbecker
2015-11-24 16:19   ` Chris Metcalf
2015-11-25 11:32     ` Frederic Weisbecker
2015-12-01 20:41   ` Peter Zijlstra
2015-12-01 22:20     ` Frederic Weisbecker
2015-12-02 10:56       ` Peter Zijlstra
2015-12-02 14:08         ` Frederic Weisbecker
2015-12-02 15:09           ` Peter Zijlstra
2015-12-08 15:57             ` Frederic Weisbecker
2015-12-02 12:45       ` Peter Zijlstra
2015-12-02 14:10         ` Frederic Weisbecker
2015-12-02 12:48       ` Peter Zijlstra
2015-12-02 14:11         ` Frederic Weisbecker
2015-11-13 14:22 ` [PATCH 3/7] perf: Migrate perf to use new tick dependency mask model Frederic Weisbecker
2015-11-24 16:19   ` Chris Metcalf [this message]
2015-11-25 12:34     ` Frederic Weisbecker
2015-12-02 16:17       ` Peter Zijlstra
2015-12-02 17:03         ` Frederic Weisbecker
2015-12-02 17:15           ` Peter Zijlstra
2015-11-13 14:22 ` [PATCH 4/7] sched: Account rr and fifo tasks separately Frederic Weisbecker
2015-12-02 12:53   ` Peter Zijlstra
2015-12-02 14:16     ` Frederic Weisbecker
2015-11-13 14:22 ` [PATCH 5/7] sched: Migrate sched to use new tick dependency mask model Frederic Weisbecker
2015-11-13 14:22 ` [PATCH 6/7] posix-cpu-timers: Migrate " Frederic Weisbecker
2015-11-13 14:22 ` [PATCH 7/7] sched-clock: " Frederic Weisbecker

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=56548E15.5050004@ezchip.com \
    --to=cmetcalf@ezchip.com \
    --cc=cl@linux.com \
    --cc=fweisbec@gmail.com \
    --cc=lcapitulino@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=riel@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=viresh.kumar@linaro.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

Powered by JetHome