Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753466AbbFHPMn (ORCPT ); Mon, 8 Jun 2015 11:12:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48986 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753440AbbFHPMf (ORCPT ); Mon, 8 Jun 2015 11:12:35 -0400 Date: Mon, 8 Jun 2015 17:11:35 +0200 From: Oleg Nesterov To: Peter Zijlstra Cc: umgwanakikbuti@gmail.com, mingo@elte.hu, ktkhai@parallels.com, rostedt@goodmis.org, tglx@linutronix.de, juri.lelli@gmail.com, pang.xunlei@linaro.org, wanpeng.li@linux.intel.com, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] hrtimer: turn newstate arg of __remove_hrtimer() into clear_enqueued Message-ID: <20150608151135.GC23138@redhat.com> References: <20150605084836.364306429@infradead.org> <20150605085205.723058588@infradead.org> <20150607223317.GA5193@redhat.com> <20150608091417.GM19282@twins.programming.kicks-ass.net> <20150608141709.GX18673@twins.programming.kicks-ass.net> <20150608151039.GA23138@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150608151039.GA23138@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2983 Lines: 83 No functional changes. Change __remove_hrtimer() to accept the boolean and change only the HRTIMER_STATE_ENQUEUED bit. This preserves HRTIMER_STATE_CALLBACK (which we are going to kill) automatically, the only complication is that __run_hrtimer() should set it by hand. --- kernel/time/hrtimer.c | 19 +++++++++---------- 1 files changed, 9 insertions(+), 10 deletions(-) diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 005fd44..5fceb3d 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -871,7 +871,7 @@ static int enqueue_hrtimer(struct hrtimer *timer, */ static void __remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base, - unsigned long newstate, int reprogram) + bool clear_enqueued, int reprogram) { struct timerqueue_node *next_timer; if (!(timer->state & HRTIMER_STATE_ENQUEUED)) @@ -895,7 +895,8 @@ static void __remove_hrtimer(struct hrtimer *timer, if (!timerqueue_getnext(&base->active)) base->cpu_base->active_bases &= ~(1 << base->index); out: - timer->state = newstate; + if (clear_enqueued) + timer->state &= ~HRTIMER_STATE_ENQUEUED; } /* @@ -905,7 +906,6 @@ static inline int remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base) { if (hrtimer_is_queued(timer)) { - unsigned long state; int reprogram; /* @@ -920,12 +920,10 @@ remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base) timer_stats_hrtimer_clear_start_info(timer); reprogram = base->cpu_base == this_cpu_ptr(&hrtimer_bases); /* - * We must preserve the CALLBACK state flag here, - * otherwise we could move the timer base in - * switch_hrtimer_base. + * This preserves the CALLBACK flag, otherwise we could move + * the timer base in switch_hrtimer_base. */ - state = timer->state & HRTIMER_STATE_CALLBACK; - __remove_hrtimer(timer, base, state, reprogram); + __remove_hrtimer(timer, base, true, reprogram); return 1; } return 0; @@ -1204,7 +1202,8 @@ static void __run_hrtimer(struct hrtimer *timer, ktime_t *now) WARN_ON(!irqs_disabled()); debug_deactivate(timer); - __remove_hrtimer(timer, base, HRTIMER_STATE_CALLBACK, 0); + timer->state |= HRTIMER_STATE_CALLBACK; + __remove_hrtimer(timer, base, true, 0); timer_stats_account_hrtimer(timer); fn = timer->function; @@ -1644,7 +1643,7 @@ static void migrate_hrtimer_list(struct hrtimer_clock_base *old_base, * timer could be seen as !active and just vanish away * under us on another CPU */ - __remove_hrtimer(timer, old_base, HRTIMER_STATE_ENQUEUED, 0); + __remove_hrtimer(timer, old_base, false, 0); timer->base = new_base; /* * Enqueue the timers on the new cpu. This does not -- 1.5.5.1 -- 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/