Received: by 10.223.164.221 with SMTP id h29csp721343wrb; Sat, 4 Nov 2017 02:15:49 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TOVXmOwqH8DFDJhhcukLsUPFgDiPev3uDLiKZ+L4o0LlDAT3Zn8Xsvyp3HmyczrsHiEPjx X-Received: by 10.101.93.140 with SMTP id f12mr9678887pgt.60.1509786949367; Sat, 04 Nov 2017 02:15:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509786949; cv=none; d=google.com; s=arc-20160816; b=XWaFukQ3eOt39EDJLhHfo7TY6DEktYRk8RV5YK6LqvVDTM91s/Kj7H6PsGE5Hzp9nl sLDoQZlAMOgZuu8nlA00BHoKlMeZqK7W3xMIWWlS7gCFhORq/chrPry+YbBSxxwmEmEG ClcJNe2NSyfkz8VVLzM+NmFBntd3pK3ek9ri0bTsY2CAP5rl9nnFGsrbHIEsPjOlFJ+O eokDA+U+yajdJTHe2XUdfap0KUzBf8KiNWcqkiPAJRmOyJi696qVzQxYVWQc9kqkw4/A JxB5GkXRgSjx1epttL8dqHEoknA2Kj87xZ57sKf4JdNAjtyYfMJHZn4bWnqLWRc8X83E /mFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=mfEd7gcmbT4G6MehFEz/NcwJ3/Ne4gfU9MB0GSVtQxo=; b=0LIiMI0Qwjiq7PKceCPWOT6tckjw2k60Fl9R9sdKwG9HbvKMtPZ4mgkH38IGQG6qDN H6aYwArlJw9NAJ8cKS0rtp/OwKL2dKQEvV3sRBTWYoq9daCb4mGidN8gNeTmZJdkNreK lnlQAZoSzwEI0+EF+l1nCVK8tBNbR1FJ+CMHF7uiE2AxS39AkRyUQfj64xWVAnlZFvmZ CoOgJ1uQ1OsN8qM2vjNtBxmDwBzPAkK3aOSLQkjlejwenmV6RpJbw2ecob6MLoedGn63 wIE08LMFlyNl+l6YYJbIV0kXUCA5D+a6C6BkYyJosIPTNa2VoK6ljXl4ODMKzODc2eY8 qmvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qrOUVnrA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g17si5864522plo.542.2017.11.04.02.15.35; Sat, 04 Nov 2017 02:15:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qrOUVnrA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756544AbdKDJO5 (ORCPT + 93 others); Sat, 4 Nov 2017 05:14:57 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:47672 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756478AbdKDJOz (ORCPT ); Sat, 4 Nov 2017 05:14:55 -0400 Received: by mail-wm0-f68.google.com with SMTP id r196so5401676wmf.2 for ; Sat, 04 Nov 2017 02:14:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=mfEd7gcmbT4G6MehFEz/NcwJ3/Ne4gfU9MB0GSVtQxo=; b=qrOUVnrAsGi0PX6Xvgz1ZtEWkyJBPvgjvhBdzIYdld8fDN3EsQK8garF0zykkaTXur nVRJBu6PmMSL58aAIcu5QnGL+WiDSRvFfd6uoAWE1gO+0mYZ1WFooNVq18864Sp6eEWC VJqItE7T7MgTD7ZVgAmw1YDK/LQSU08/Up88clCebRbFAv3yvauwrG8hGHyJOvJL0gXI F6XEEdPeRfcrJCDLpXegvDFwr+JxrzWdmFQ6xJmZRR7fP5p2lcSIqZXrneOisb2gtQRo 7W2/G7enrKVyLIOVZNFHQ2yCh/X8iJ1bABdjOA4bWkDbM90hbccNDR2R7nJCH72wpGb/ NkBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=mfEd7gcmbT4G6MehFEz/NcwJ3/Ne4gfU9MB0GSVtQxo=; b=lvRysGUWTDAL30vUB3HmR64KzismCVi9QBhMTnIufM7neNIJS2+I4OleR1xDEydxCK 7TkIx3BBjtreuOWMnAMOPWAhIi1CavisC01unVEIsy/sm55FvjAlTtMs1H/9wqN3Gb9n PxQeBwIoTqmk1WB/aYJlGJVIV5EfnOFnw8Pq6GGzhPWXGVHn0uthib1H0w/sdUgu5p4c pwHf2T6fk0cT05shj4Gw2lWoaCQuOms1hcs3mRkFulVAOJzBjDwmXpCEFJTnjfJd9hE6 Eb6ogmBTiGB+VKXXQ0Ef1g1FzT6s59RJQO59q5YltEJYL84nFJVpx/8Y4lMmtD9HS+uK U6Qw== X-Gm-Message-State: AJaThX6erLgZ42IEpsbZ6S1OxhIAC9t5S5lDO+YrCDyPrSndgw5h/Swf qzElehqR20pLriW5B+Ry+Oc= X-Received: by 10.28.55.197 with SMTP id e188mr1179293wma.60.1509786894166; Sat, 04 Nov 2017 02:14:54 -0700 (PDT) Received: from localhost.localdomain (x4e36179f.dyn.telefonica.de. [78.54.23.159]) by smtp.gmail.com with ESMTPSA id p79sm6809437wmf.43.2017.11.04.02.14.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 04 Nov 2017 02:14:53 -0700 (PDT) From: Nicolai Stange To: Luiz Capitulino Cc: fweisbec@gmail.com, tglx@linutronix.de, mtosatti@redhat.com, williams@redhat.com, nicstange@gmail.com, linux-kernel@vger.kernel.org, John Stultz Subject: Re: [nohz_full/apic] multiple timer interrupts a second References: <20171103170703.46d72a31@redhat.com> Date: Sat, 04 Nov 2017 10:14:52 +0100 In-Reply-To: <20171103170703.46d72a31@redhat.com> (Luiz Capitulino's message of "Fri, 3 Nov 2017 17:12:03 -0400") Message-ID: <878tfm76cz.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Luiz, [John Stultz added to CC] On Fri, Nov 03 2017, Luiz Capitulino wrote: > [CC'ing lkml this time] > > I've observed that smp_apic_timer_interrupt() is sometimes called > two or more times a second on a nohz_full core which has a single > task taking 100% of the core. In one of the calls, hrtimer_interrupt() > runs tick_sched_timer(), but in others it doesn't call any handler. > Here's an example (Linus HEAD f34157878): > > <...>-1831 [008] 1060.115578: funcgraph_entry: | smp_apic_timer_interrupt() { > <...>-1831 [008] 1060.115578: funcgraph_entry: | hrtimer_interrupt() { > <...>-1831 [008] 1060.115578: hrtimer_expire_entry: hrtimer=0xffff8edfefd12d60 function=tick_sched_timer now=1060079001980 > <...>-1831 [008] 1060.115578: funcgraph_entry: 1.172 us | tick_sched_timer(); > <...>-1831 [008] 1060.115580: funcgraph_exit: 1.757 us | } > <...>-1831 [008] 1060.115580: hrtimer_start: hrtimer=0xffff8edfefd12d60 function=tick_sched_timer expires=1061079000000 softexpires=1061079000000 > <...>-1831 [008] 1060.115581: funcgraph_exit: 3.026 us | } > <...>-1831 [008] 1061.115577: funcgraph_entry: | smp_apic_timer_interrupt() { > <...>-1831 [008] 1061.115577: funcgraph_entry: 0.261 us | hrtimer_interrupt(); <---------- NO handler called > <...>-1831 [008] 1061.115578: funcgraph_exit: 1.349 us | } > <...>-1831 [008] 1061.115579: funcgraph_entry: | smp_apic_timer_interrupt() { > <...>-1831 [008] 1061.115579: funcgraph_entry: | hrtimer_interrupt() { > <...>-1831 [008] 1061.115579: hrtimer_expire_entry: hrtimer=0xffff8edfefd12d60 function=tick_sched_timer now=1061079001473 > <...>-1831 [008] 1061.115580: funcgraph_entry: 1.413 us | tick_sched_timer(); > <...>-1831 [008] 1061.115581: funcgraph_exit: 2.124 us | } > <...>-1831 [008] 1061.115582: hrtimer_start: hrtimer=0xffff8edfefd12d60 function=tick_sched_timer expires=1062079000000 softexpires=1062079000000 > <...>-1831 [008] 1061.115582: funcgraph_exit: 3.255 us | } > > Is this expected for some reason? > > I guess what's happening is that the deadline timer is firing > earlier than expected. From a few dozen to a few hundreds > nanoseconds earlier. When this happens, hrtimer_interrupt() > skips calling the hrtimer handler (since it's early) and the > apic is programmed to fire in the next microsecond. Exactly. > On further research I saw that Nicolai tried to fix a very similar > problem last year: > > commit 1a9e4c564ab174e53ed86def922804a5ddc63e7d > Author: Nicolai Stange > Date: Thu Jul 14 17:22:54 2016 +0200 > > x86/timers/apic: Fix imprecise timer interrupts by eliminating TSC clockevents frequency roundoff error > > I noticed the following bug/misbehavior on certain Intel systems: with a > single task running on a NOHZ CPU on an Intel Haswell, I recognized > that I did not only get the one expected local_timer APIC interrupt, but > two per second at minimum. (!) Note that there's also 6731b0d611a1 ("x86/timers/apic: Inform TSC deadline clockevent device about recalibration"). > Maybe this issue is still present? Yes it is. The reason is that NTP frequency adjustments would make it into the mono clocksource's frequency but not into the clock_event_device's. I sent a series back then [1] addressing this. However, in the meanwhile, I changed jobs and thus, got somehow distracted. My bad :/ The result is that this got merged only up to what corresponds to [10/28] in [1]. I'll pick this up again now and try to get the rest accepted for inclusion. Thanks, Nicolai [1] last time I sent this series as a whole can be found at http://lkml.kernel.org/r/20161119160055.12491-2-nicstange@gmail.com From 1583080882010256173@xxx Fri Nov 03 21:12:57 +0000 2017 X-GM-THRID: 1583080882010256173 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread