From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752225AbcAFSNW (ORCPT ); Wed, 6 Jan 2016 13:13:22 -0500 Received: from www.linutronix.de ([62.245.132.108]:37849 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751777AbcAFSNQ (ORCPT ); Wed, 6 Jan 2016 13:13:16 -0500 Date: Wed, 6 Jan 2016 19:12:22 +0100 (CET) From: Thomas Gleixner To: Prarit Bhargava cc: John Stultz , lkml , Ingo Molnar , Xunlei Pang , Peter Zijlstra , Baolin Wang , Arnd Bergmann Subject: Re: [PATCH 1/2] kernel, timekeeping, add trylock option to ktime_get_with_offset() In-Reply-To: <568D5844.8030409@redhat.com> Message-ID: References: <1452085234-10667-1-git-send-email-prarit@redhat.com> <1452085234-10667-2-git-send-email-prarit@redhat.com> <568D5844.8030409@redhat.com> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) 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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 6 Jan 2016, Prarit Bhargava wrote: > On 01/06/2016 12:34 PM, Thomas Gleixner wrote: > > On Wed, 6 Jan 2016, John Stultz wrote: > >> On Wed, Jan 6, 2016 at 5:00 AM, Prarit Bhargava wrote: > >>> -ktime_t ktime_get_with_offset(enum tk_offsets offs) > >>> +ktime_t ktime_get_with_offset(enum tk_offsets offs, int trylock) > >>> { > >>> struct timekeeper *tk = &tk_core.timekeeper; > >>> unsigned int seq; > >>> ktime_t base, *offset = offsets[offs]; > >>> s64 nsecs; > >>> + unsigned long flags = 0; > >>> + > >>> + if (unlikely(!timekeeping_initialized)) > >>> + return ktime_set(0, 0); > >>> > >>> WARN_ON(timekeeping_suspended); > >>> > >>> + if (trylock && !raw_spin_trylock_irqsave(&timekeeper_lock, flags)) > >>> + return ktime_set(KTIME_MAX, 0); > >> > >> Wait.. this doesn't make sense. The timekeeper lock is only for reading. > >> > >> What I was suggesting to you off line is to have something that avoids > >> spinning on the seqcounter should if a bug occurs and we IPI all the > >> cpus, that we don't deadlock or block any printk messages. > > > > We could also extend the fast timekeeper with boot/real/tai extensions and use > > that for printk. You can use ktime_get_mono_fast_ns() today. > > > > Thanks tglx -- I thought about doing that but was put off by the comments > in __ktime_get_fast_ns() which point out that we could see backwards time > stamps. But I see your point -- I could do the same "last_time_stamp" check > and use "??" in the output. We talk about single digit nanoseconds here and in the case of a crash/bug we really do not care about that at all. Thanks, tglx