Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423548AbbEENbE (ORCPT ); Tue, 5 May 2015 09:31:04 -0400 Received: from cantor2.suse.de ([195.135.220.15]:41650 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422666AbbEENa4 (ORCPT ); Tue, 5 May 2015 09:30:56 -0400 Date: Tue, 5 May 2015 15:30:54 +0200 From: Jiri Bohac To: linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, mhocko@suse.cz Subject: running hrtimer_start on an already active hrtimer? Message-ID: <20150505133054.GA20643@midget.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1459 Lines: 57 Hi, I came across a strange bug (in a very old kernel) that triggers the BUG_ON(timer->state != HRTIMER_STATE_CALLBACK); in __run_hrtimer(). The code runs hrtimer_start() on an already started hrtimer. Looking at the description of hrtimer_start() it looks like something that is allowed: /** * hrtimer_start - (re)start an hrtimer on the current CPU ... * Returns: * 0 on success * 1 when the timer was active Is this really supposed to work? I think it's not immune to this race condition: CPU0 CPU1 __run_hrtimer() __remove_hrtimer(...HRTIMER_STATE_CALLBACK) //clears HRTIMER_STATE_ENQUEUED ... raw_spin_unlock(&cpu_base->lock); restart = fn(timer); hrtimer_start() __hrtimer_start_range_ns() //remove_hrtimer() does nothing because // HRTIMER_STATE_ENQUEUED is not set enqueue_hrtimer() raw_spin_lock(&cpu_base->lock); ... BUG_ON(timer->state != HRTIMER_STATE_CALLBACK); // state has HRTIMER_STATE_ENQUEUED set Should __hrtimer_start_range_ns() do something like hrtimer_cancel - i.e. explicitly check for ... HRTIMER_STATE_CALLBACK? Thanks, -- Jiri Bohac SUSE Labs, SUSE CZ -- 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/