Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4430462ioa; Wed, 27 Apr 2022 03:49:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygQ382aa7QitSFQgbCc2wNJJH5o7n++X+w09La/4csJ97ULR1MLbv0Jtkpz4ONU6VsA2hQ X-Received: by 2002:a17:902:f64d:b0:151:3895:46bf with SMTP id m13-20020a170902f64d00b00151389546bfmr28510047plg.31.1651056584086; Wed, 27 Apr 2022 03:49:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651056584; cv=none; d=google.com; s=arc-20160816; b=sw8xYPTIJ3YV6wO3e+ewwMGsMdQaIecZ1JdWihfmcg3qzLEvJnXCyB1xpA223cfOF7 Xm1sAfQc08fypvGHSRXXOnhNT9mlN/aTwpuNQlnsbDdl5InqyqUZHpOQNCUH9e+LYsMX eVINCz/GcfNsvfyQufMQLK+JXDQYKbVwlwvD4AXc8RetOG+R4/0keDT99EN1i0lFxHw3 ykGeqzJ3VKacw2x5RqAaYviXj+ZkX2+w3e6oV2ncbYrcPSLEQM6ZTzWheOW8TgqWUsfi iBOhY3rCYtrGNu5il1DL/pSNAx9ypDWPHDMLEtrbMlVkfg7lvpl/vt47fuYgFc4xflIt bjsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=vFLr6SeRCSuxjMA6GTzB7LHQDHSnRaJltcyEgh+cjO0=; b=gQF4l2R1FuVO+injbNfAZwRJCItB1p0gFfm7BfbRrAzAmAUzCLm0/qsEHTVoDdT0E+ 6deIz7qThA0cSeCXdlq+58l0cGqjA3SgSIJMeZJsjbjRrPEpzBfMF7KHMaRiINpdty9B u6wZDmQ4Ga7exNfmeS4Ffp0BIhVIyzQG6K7yKOi2vwELopi63t6V2o46Ejafxy0RlznC 4t1xTY1nZcSgN+Xr6rnbyxRyF2klpC7pbSf6EX6mQK9pCtD1Gj5Y4ed78Z7jHYp7xQIX Jcc01b2ciOtRI1niukQ/jb0TsDn0/1bSeCXgeDl0G7Cv0rLJAntS3MqEXVZy1uHeWzMg ddhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="aJF2X2/a"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id f13-20020a170902ce8d00b0015d4a5e3aa9si1355808plg.226.2022.04.27.03.49.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:49:44 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="aJF2X2/a"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4AAA041A972; Wed, 27 Apr 2022 02:57:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359338AbiD0IUm (ORCPT + 99 others); Wed, 27 Apr 2022 04:20:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344335AbiD0IUl (ORCPT ); Wed, 27 Apr 2022 04:20:41 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAA7928E12; Wed, 27 Apr 2022 01:17:30 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1651047449; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vFLr6SeRCSuxjMA6GTzB7LHQDHSnRaJltcyEgh+cjO0=; b=aJF2X2/avz3+HF2QHdBbVS8weBIsDYKXE2x5xzBvLNkaG25WRChNDiMnkb/dZdfco7RXYy te5oqgi+ax/n+a3oRYq6GEyss7oTKwh7fPEIS9qjRbni5vlFuV0mUUom4VjbFlcuy+MiGT Vfq5Wp2xh9OIzVEbjtsPBvqxVSKCt6hDak3PJA64SWMWfM5r3mxRHsCN1v0HL6XWWVyM/g eHsQJmKek//gAmI+vuzAbKpzJQkAoifOlgeM8dfCMAgHSA7yx/nrufs0rhI4laH/4qJsnL DP6XsV7RjcSMiYoIhaksmyEO02stdyp6MMU0Rjz3X2FdavzrdRMrmty819f8FQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1651047449; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vFLr6SeRCSuxjMA6GTzB7LHQDHSnRaJltcyEgh+cjO0=; b=d58LPj7BSSvwfgRcJr+dM16qMOmnuSCGuGOTWRo5CPHVqoYGqDpadPlAp1ENXtVVvkuJfQ KgkXi6C/4vYwQXAw== To: Steven Rostedt , Kurt Kanzenbach Cc: John Stultz , Stephen Boyd , Ingo Molnar , Jonathan Corbet , Richard Cochran , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/3] timekeeping: Introduce fast accessor to clock tai In-Reply-To: <20220426175338.3807ca4f@gandalf.local.home> References: <20220414091805.89667-1-kurt@linutronix.de> <20220414091805.89667-2-kurt@linutronix.de> <20220426175338.3807ca4f@gandalf.local.home> Date: Wed, 27 Apr 2022 10:17:28 +0200 Message-ID: <87pml3x7mv.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 26 2022 at 17:53, Steven Rostedt wrote: >> +/** >> + * ktime_get_tai_fast_ns - NMI safe and fast access to tai clock. >> + * >> + * The same limitations as described for ktime_get_boot_fast_ns() apply. The >> + * mono time and the TAI offset are not read atomically which may yield wrong >> + * readouts. However, an update of the TAI offset is an rare event e.g., caused >> + * by settime or adjtimex with an offset. The user of this function has to deal >> + * with the possibility of wrong timestamps in post processing. >> + */ >> +u64 notrace ktime_get_tai_fast_ns(void) >> +{ >> + struct timekeeper *tk = &tk_core.timekeeper; >> + >> + return (ktime_get_mono_fast_ns() + ktime_to_ns(data_race(tk->offs_tai))); > > As you are using this for tracing, can you open code the > ktime_get_mono_fast_ns(), otherwise we need to mark that function as > notrace. which we should do anyway.... kernel/trace/trace.c: { ktime_get_mono_fast_ns, "mono", 1 }, > Not to mention, this is a fast path and using the noinline of > __ktime_get_fast_ns() should be less overhead. > > That said, I hit this too: > > less-5071 [000] d.h2. 498087876.351330: do_raw_spin_trylock <-_raw_spin_lock > less-5071 [000] d.h4. 498087876.351334: ktime_get_mono_fast_ns <-ktime_get_tai_fast_ns > less-5071 [000] d.h5. 498087876.351334: ktime_get_mono_fast_ns <-ktime_get_tai_fast_ns > less-5071 [000] d.h3. 498087876.351334: rcu_read_lock_sched_held <-lock_acquired > less-5071 [000] d.h5. 498087876.351337: ktime_get_mono_fast_ns <-ktime_get_tai_fast_ns > kworker/u8:1-45 [003] d.h7. 1651009380.982749: ktime_get_mono_fast_ns <-ktime_get_tai_fast_ns > kworker/u8:1-45 [003] d.h7. 1651009380.982749: ktime_get_mono_fast_ns <-ktime_get_tai_fast_ns > kworker/u8:1-45 [003] d.h5. 1651009380.982749: rcu_read_lock_held_common <-rcu_read_lock_sched_held > kworker/u8:1-45 [003] d.h7. 498087876.375905: ktime_get_mono_fast_ns <-ktime_get_tai_fast_ns > kworker/u8:1-45 [003] d.h7. 498087876.375905: ktime_get_mono_fast_ns <-ktime_get_tai_fast_ns > kworker/u8:1-45 [003] d.h5. 498087876.375905: update_cfs_group <-task_tick_fair > kworker/u8:1-45 [003] d.h7. 498087876.375909: ktime_get_mono_fast_ns <-ktime_get_tai_fast_ns > > The clock seems to be toggling between 1651009380 and 498087876 causing the > ftrace ring buffer to shutdown (it doesn't allow for time to go backwards). That does not make sense. offs_tai changes only when clock is set via adjtimex() or settimeofday(). Thanks, tglx