Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1281958
| Path | csiph.com!usenet.pasdenom.info!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Peter Zijlstra <peterz@infradead.org> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 3/7] perf: Migrate perf to use new tick dependency mask model |
| Date | Wed, 02 Dec 2015 17:20:02 +0100 |
| Message-ID | <qBiim-161-3@gated-at.bofh.it> (permalink) |
| References | <qunwt-7y6-9@gated-at.bofh.it> <qunwu-7y6-33@gated-at.bofh.it> <qyotY-21n-35@gated-at.bofh.it> <qyHwC-6ho-19@gated-at.bofh.it> |
| X-Original-To | Frederic Weisbecker <fweisbec@gmail.com> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Disposition | inline |
| User-Agent | Mutt/1.5.21 (2012-12-30) |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 67 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Chris Metcalf <cmetcalf@ezchip.com>, LKML <linux-kernel@vger.kernel.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> |
| X-Original-Date | Wed, 2 Dec 2015 17:17:58 +0100 |
| X-Original-Message-ID | <20151202161758.GS3816@twins.programming.kicks-ass.net> |
| X-Original-References | <1447424529-13671-1-git-send-email-fweisbec@gmail.com> <1447424529-13671-4-git-send-email-fweisbec@gmail.com> <56548E15.5050004@ezchip.com> <20151125123428.GD16609@lerouge> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1281958 |
Show key headers only | View raw
On Wed, Nov 25, 2015 at 01:34:30PM +0100, Frederic Weisbecker wrote:
> On Tue, Nov 24, 2015 at 11:19:33AM -0500, Chris Metcalf wrote:
> > 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.
>
> Hmm, how did I miss that...
>
> So in the case of perf, either we need locking, in which case we may want
> to use something like tick_nohz_add_dep() which takes care of counting.
> But perf would be the only user.
Right; so you could use something like atomic_dec_and_mutex_lock(), that
would only globally serialize the 0<->1 transitions without incurring
overhead to any other state transitions.
A possibly even less expensive option might be something along the lines
of:
tick_nohz_update_perf_dep()
{
static DEFINE_SPINLOCK(lock);
bool freq;
spin_lock(&lock);
freq = !!atomic_read(&nr_freq_events);
if (freq ^ !!tick_nohz_test_dep(PERF)) {
if (freq)
tick_nohz_set_dep(PERF);
else
tick_nohz_clear_dep(PERF);
}
spin_unlock(&lock);
}
if (atomic_inc_return(&nr_freq_events) == 1)
tick_nohz_update_perf_dep();
if (atomic_dec_return(&nr_freq_events) == 0)
tick_nohz_update_perf_dep();
That avoids the atomic_add_unless() muckery.
> _ sched_clock_stable: that one is more obscure. It seems that set_sched_clock_stable()
> and clear_sched_clock_stable() can race on static keys if running concurrently, and
> that would concern tick mask as well.
All you need to ensure here is that clear wins. Once we clear
sched_clock_stable we should _never_ set it again.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
Re: [PATCH 3/7] perf: Migrate perf to use new tick dependency mask model Peter Zijlstra <peterz@infradead.org> - 2015-12-02 17:20 +0100
Re: [PATCH 3/7] perf: Migrate perf to use new tick dependency mask model Frederic Weisbecker <fweisbec@gmail.com> - 2015-12-02 18:10 +0100
Re: [PATCH 3/7] perf: Migrate perf to use new tick dependency mask model Peter Zijlstra <peterz@infradead.org> - 2015-12-02 18:20 +0100
csiph-web