Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754210Ab3ILThz (ORCPT ); Thu, 12 Sep 2013 15:37:55 -0400 Received: from www.linutronix.de ([62.245.132.108]:60582 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752753Ab3ILThx (ORCPT ); Thu, 12 Sep 2013 15:37:53 -0400 Date: Thu, 12 Sep 2013 21:37:42 +0200 (CEST) From: Thomas Gleixner To: David Miller cc: herbert@gondor.hengli.com.au, fan.du@windriver.com, steffen.klassert@secunet.com, dborkman@redhat.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCHv3 linux-next] hrtimer: Add notifier when clock_was_set was called In-Reply-To: <20130912.133252.425268707009916773.davem@davemloft.net> Message-ID: References: <20130912134409.GB21212@gondor.apana.org.au> <20130912.133252.425268707009916773.davem@davemloft.net> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001,URIBL_BLOCKED=0.001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3650 Lines: 114 On Thu, 12 Sep 2013, David Miller wrote: > From: Thomas Gleixner > Date: Thu, 12 Sep 2013 16:43:37 +0200 (CEST) > > > So what about going back to timer_list timers and simply utilize > > register_pm_notifier(), which will tell you that the system resumed? > > The thing to understand is that there are two timeouts for an IPSEC > rule, a soft and a hard timeout. > > There is a gap between these two exactly so that we can negotiate a > new encapsulation with the IPSEC gateway before communication ceases > to be possible over the IPSEC protected path. > > So the idea is that the soft timeout triggers the re-negotiation, > and after a hard timeout the IPSEC path is no longer usable and > all communication will fail. > > Simply triggering a re-negoation after every suspend/resume makes > no sense at all. Spurious re-negotiations are undesirable. > > What we want are real timers. We want that rather than a "we > suspended so just assume all timers expired" event which is not very > useful for this kind of application. Your argumentation makes no sense at all. Where is the difference between the "real timer" plus a clock was set notification and a timer list timer and a resume notification? In both cases you need to walk through the timers and reevaluate them. Just in the clock was set notification case you need to deal with NTP/settimeofday/PPS and whatever cases which are completely irrelevant to the life time management. So what's wrong with: now = get_seconds(); x->timeout = now + x->soft_timeout; x->timeout_active = SOFT; start_timer(x->timer, jiffies + sec_to_jiffies(x->soft_timeout)); In the timer handler: switch (x->timeout_active) { case SOFT: trigger_renegotiation(); hts = x->hard_timeout - x->soft_timeout; x->timeout += hts; x->timeout_active = HARD; start_timer(x->timer, jiffies + sec_to_jiffies(hts)); break; case HARD: stop_connection(); break: } If the negotiation succeeds: now = get_seconds(); x->t_timeout = now + x->soft_timeout; x->timeout_active = SOFT; mod_timer(x->timer, jiffies + sec_to_jiffies(x->soft_timeout)); Now in the resume notification you walk the active timers and do for each timer: now = get_seconds(); switch (x->timeout_active) { case SOFT: if (now >= x->timeout) { hts = x->hard_timeout - x->soft_timeout; x->timeout += hts; if (now >= x->timeout) { del_timer(x->timeout); stop_connection(); break: } trigger_renegotiation(); x->timeout_active = HARD; mod_timer(x->timer, jiffies + sec_to_jiffies(hts)); break; } delta = x->timeout - now; mod_timer(x->timer, jiffies + sec_to_jiffies(delta)); break; case HARD: if (now >= x->timeout) { del_timer(x->timeout); stop_connection(); } delta = x->timeout - now; mod_timer(x->timer, jiffies + sec_to_jiffies(delta)); break; } That's what you have to do with a clock was set notification as well. And what's worse is that you need to figure out whether the clock change was due to a suspend/resume cycle or just because NTP/settimeofday/PPS or whatever decided to fiddle with the wall time. And you need to do that to avoid the spurious renegotiations which you are afraid of. Thanks, tglx -- 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/