Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c04dca02 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Thomas Gleixner
Browse files

hrtimer: Remove HRTIMER_STATE_MIGRATE



I do not understand HRTIMER_STATE_MIGRATE. Unless I am totally
confused it looks buggy and simply unneeded.

migrate_hrtimer_list() sets it to keep hrtimer_active() == T, but this
is not enough: this can fool, say, hrtimer_is_queued() in
dequeue_signal().

Can't migrate_hrtimer_list() simply use HRTIMER_STATE_ENQUEUED?
This fixes the race and we can kill STATE_MIGRATE.

Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: ktkhai@parallels.com
Cc: rostedt@goodmis.org
Cc: juri.lelli@gmail.com
Cc: pang.xunlei@linaro.org
Cc: wanpeng.li@linux.intel.com
Cc: umgwanakikbuti@gmail.com
Link: http://lkml.kernel.org/r/20150611124743.072387650@infradead.org


Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 51a16c1e
Loading
Loading
Loading
Loading
+1 −5
Original line number Original line Diff line number Diff line
@@ -70,17 +70,13 @@ enum hrtimer_restart {
 * the handling of the timer.
 * the handling of the timer.
 *
 *
 * The HRTIMER_STATE_ENQUEUED bit is always or'ed to the current state
 * The HRTIMER_STATE_ENQUEUED bit is always or'ed to the current state
 * to preserve the HRTIMER_STATE_CALLBACK in the above scenario. This
 * to preserve the HRTIMER_STATE_CALLBACK in the above scenario.
 * also affects HRTIMER_STATE_MIGRATE where the preservation is not
 * necessary. HRTIMER_STATE_MIGRATE is cleared after the timer is
 * enqueued on the new cpu.
 *
 *
 * All state transitions are protected by cpu_base->lock.
 * All state transitions are protected by cpu_base->lock.
 */
 */
#define HRTIMER_STATE_INACTIVE	0x00
#define HRTIMER_STATE_INACTIVE	0x00
#define HRTIMER_STATE_ENQUEUED	0x01
#define HRTIMER_STATE_ENQUEUED	0x01
#define HRTIMER_STATE_CALLBACK	0x02
#define HRTIMER_STATE_CALLBACK	0x02
#define HRTIMER_STATE_MIGRATE	0x04


/**
/**
 * struct hrtimer - the basic hrtimer structure
 * struct hrtimer - the basic hrtimer structure
+2 −5
Original line number Original line Diff line number Diff line
@@ -1508,11 +1508,11 @@ static void migrate_hrtimer_list(struct hrtimer_clock_base *old_base,
		debug_deactivate(timer);
		debug_deactivate(timer);


		/*
		/*
		 * Mark it as STATE_MIGRATE not INACTIVE otherwise the
		 * Mark it as ENQUEUED not INACTIVE otherwise the
		 * timer could be seen as !active and just vanish away
		 * timer could be seen as !active and just vanish away
		 * under us on another CPU
		 * under us on another CPU
		 */
		 */
		__remove_hrtimer(timer, old_base, HRTIMER_STATE_MIGRATE, 0);
		__remove_hrtimer(timer, old_base, HRTIMER_STATE_ENQUEUED, 0);
		timer->base = new_base;
		timer->base = new_base;
		/*
		/*
		 * Enqueue the timers on the new cpu. This does not
		 * Enqueue the timers on the new cpu. This does not
@@ -1523,9 +1523,6 @@ static void migrate_hrtimer_list(struct hrtimer_clock_base *old_base,
		 * event device.
		 * event device.
		 */
		 */
		enqueue_hrtimer(timer, new_base);
		enqueue_hrtimer(timer, new_base);

		/* Clear the migration state bit */
		timer->state &= ~HRTIMER_STATE_MIGRATE;
	}
	}
}
}