Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753130AbbFHPu2 (ORCPT ); Mon, 8 Jun 2015 11:50:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34107 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753066AbbFHPuS (ORCPT ); Mon, 8 Jun 2015 11:50:18 -0400 Date: Mon, 8 Jun 2015 17:49:18 +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: Re: [PATCH 08/14] hrtimer: Allow hrtimer::function() to free the timer Message-ID: <20150608154918.GA23743@redhat.com> References: <20150605084836.364306429@infradead.org> <20150605085205.723058588@infradead.org> <20150607223317.GA5193@redhat.com> <20150608091417.GM19282@twins.programming.kicks-ass.net> <20150608124234.GW18673@twins.programming.kicks-ass.net> <20150608142749.GB13168@redhat.com> <20150608144231.GL3644@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150608144231.GL3644@twins.programming.kicks-ass.net> 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: 1343 Lines: 55 On 06/08, Peter Zijlstra wrote: > > On Mon, Jun 08, 2015 at 04:27:49PM +0200, Oleg Nesterov wrote: > > > > Most probably I missed something... I'll try to think more, but perhaps > > you see a hole immediately? > > This is something I proposed earlier; Kirill said: > > lkml.kernel.org/r/2134411433408823@web8j.yandex.ru > > Which I read like the below, imagine our timer expires periodically and > rearms itself: > > acquire > cpu_base->running = timer; > wmb > timer->state = INACTIVE; > release > [R] timer->state (== INACTIVE) > fn() > acquire > timer->state = ACTIVE > wmb > cpu_base->running = NULL > release > > [R] cpu_base->running (== NULL) > > acquire > cpu_base->running = timer; > wmb > timer->state = INACTIVE; > release > > [R] timer->state (== INACTIVE) Damn yes. Thanks Kirill and Peter. And I swear, I swear I was thinking about this race yesterday but forgot this problem today ;) Yes it seems that we can't avoid the seq counter. But perhaps we can increment/check it once in run_hrtimer/hrtimer_inactive ... I'll try to think. Thanks! Oleg. -- 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/