From: Peter Zijlstra <peterz@infradead.org>
To: Kirill Tkhai <tkhai@yandex.ru>
Cc: "umgwanakikbuti@gmail.com" <umgwanakikbuti@gmail.com>,
"mingo@elte.hu" <mingo@elte.hu>,
"ktkhai@parallels.com" <ktkhai@parallels.com>,
"rostedt@goodmis.org" <rostedt@goodmis.org>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"juri.lelli@gmail.com" <juri.lelli@gmail.com>,
"pang.xunlei@linaro.org" <pang.xunlei@linaro.org>,
"oleg@redhat.com" <oleg@redhat.com>,
"wanpeng.li@linux.intel.com" <wanpeng.li@linux.intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 8/9] hrtimer: Allow hrtimer::function() to free the timer
Date: Thu, 4 Jun 2015 12:58:55 +0200 [thread overview]
Message-ID: <20150604105855.GU18673@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20150604105537.GT18673@twins.programming.kicks-ass.net>
On Thu, Jun 04, 2015 at 12:55:37PM +0200, Peter Zijlstra wrote:
> On Thu, Jun 04, 2015 at 12:49:02PM +0200, Peter Zijlstra wrote:
> > Needs more comments at the very least, its fully of trickery.
> >
> > @@ -1118,10 +1125,16 @@ static void __run_hrtimer(struct hrtimer
> > enum hrtimer_restart (*fn)(struct hrtimer *);
> > int restart;
> >
> > - WARN_ON(!irqs_disabled());
> > + lockdep_assert_held(&cpu_base->lock);
> >
> > debug_deactivate(timer);
> > - base->running = timer;
> > + cpu_base->running = timer;
> > +
> > + /*
> > + * separate the ->running assignment from the ->state assignment
> > + */
> > + write_seqcount_begin(&cpu_base->seq);
>
> Maybe these need to be raw_write_seqcount_latch()..
I'm properly confusing my self, so let me write a little more detail;
I didn't think it needed the double wmb because:
[S] running = timer;
[S] seq++;
WMB
[S] state = INACTIVE
I don't think it matters if we re-order the first two stores, since at
that point ->state is still ENQUEUED and we're good.
Similar for the case below, you can flip the seq increment and the
->running clear, but at that time ->state should already be ENQUEUED
again (if indeed the timer got re-armed), otherwise its not active
anymore.
> > __remove_hrtimer(timer, base, HRTIMER_STATE_INACTIVE, 0);
> > timer_stats_account_hrtimer(timer);
> > fn = timer->function;
> > @@ -1150,8 +1163,13 @@ static void __run_hrtimer(struct hrtimer
> > !(timer->state & HRTIMER_STATE_ENQUEUED))
> > enqueue_hrtimer(timer, base);
> >
> > - WARN_ON_ONCE(base->running != timer);
> > - base->running = NULL;
> > + /*
> > + * separate the ->running assignment from the ->state assignment
> > + */
> > + write_seqcount_end(&cpu_base->seq);
> > +
> > + WARN_ON_ONCE(cpu_base->running != timer);
> > + cpu_base->running = NULL;
> > }
> >
> > static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t now)
next prev parent reply other threads:[~2015-06-04 10:59 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-03 13:29 [PATCH 0/9] sched: balance callbacks Peter Zijlstra
2015-06-03 13:29 ` [PATCH 1/9] sched: Replace post_schedule with a balance callback list Peter Zijlstra
2015-06-03 13:29 ` [PATCH 2/9] sched: Use replace normalize_task() with __sched_setscheduler() Peter Zijlstra
2015-06-03 13:29 ` [PATCH 3/9] sched: Allow balance callbacks for check_class_changed() Peter Zijlstra
2015-06-03 13:29 ` [PATCH 4/9] sched,rt: Remove return value from pull_rt_task() Peter Zijlstra
2015-06-03 13:29 ` [PATCH 5/9] sched,rt: Convert switched_{from,to}_rt() / prio_changed_rt() to balance callbacks Peter Zijlstra
2015-06-03 13:29 ` [PATCH 6/9] sched,dl: Remove return value from pull_dl_task() Peter Zijlstra
2015-06-03 13:29 ` [PATCH 7/9] sched,dl: Convert switched_{from,to}_dl() / prio_changed_dl() to balance callbacks Peter Zijlstra
2015-06-03 13:29 ` [PATCH 8/9] hrtimer: Allow hrtimer::function() to free the timer Peter Zijlstra
2015-06-03 16:26 ` Kirill Tkhai
2015-06-03 21:13 ` Peter Zijlstra
2015-06-04 9:07 ` Kirill Tkhai
2015-06-04 10:49 ` Peter Zijlstra
2015-06-04 10:55 ` Peter Zijlstra
2015-06-04 10:58 ` Peter Zijlstra [this message]
2015-06-05 9:02 ` Kirill Tkhai
2015-06-05 9:03 ` Kirill Tkhai
2015-06-05 9:11 ` Peter Zijlstra
2015-06-05 9:10 ` Peter Zijlstra
2015-06-05 9:27 ` Kirill Tkhai
2015-06-03 17:41 ` Thomas Gleixner
2015-06-03 21:29 ` Peter Zijlstra
2015-06-04 5:59 ` Ingo Molnar
2015-06-04 10:07 ` Peter Zijlstra
2015-06-04 12:37 ` Ingo Molnar
2015-06-03 13:29 ` [PATCH 9/9] sched,dl: Fix sched class hopping CBS hole Peter Zijlstra
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=20150604105855.GU18673@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=juri.lelli@gmail.com \
--cc=ktkhai@parallels.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@redhat.com \
--cc=pang.xunlei@linaro.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=tkhai@yandex.ru \
--cc=umgwanakikbuti@gmail.com \
--cc=wanpeng.li@linux.intel.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.