Received: by 10.192.165.156 with SMTP id m28csp573968imm; Thu, 19 Apr 2018 04:07:25 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/T2wedvOuh9VOatxhqsgBFRoFWcUHkX5cXh/S+QCBH2CCmfJI5mHP92xC1UpbITOQDKqHg X-Received: by 10.99.120.138 with SMTP id t132mr4805284pgc.280.1524136045869; Thu, 19 Apr 2018 04:07:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524136045; cv=none; d=google.com; s=arc-20160816; b=HVyq73sQ3rAwq3Xjx2xLwOb+YKidgvEfrzCZ8kElnv/7cnM2Axgu9EPLMXcY7YtTRp 6X4TkhKi3egZA+jhjsNCWH54/uT+eS/LMX2+pQgx+0+XXeUs3a0NbAg4I1EkeVYi7VG5 5SmGFP35w+LuPs3xulM6pZz4WEtg6HBR4HjYBJT0KClxsqdJ8jH/TBzBV+l+mu1vCxz0 +52LRkrrSi+xx7wIVrD+TZWtNEg37tX2IMQGSWoNUIxanRSnMjUCpnzpCvubPc0zwQMJ b98z5cwSXOAquj25p7Ip6+TLT71vpU0I0kCtd/0zM10f9hCY+ehGELwPFdkVPLMCoMfP JWIw== 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:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=0JU9hVQnHM1LlwWMX2nx/PIv+KVPke4+MjlCQQNhyuA=; b=oxGo0Blzw5IfzPU4jG+kdxcpLyVWG4P5kKHT9ONOjATld1DZ0dnjnTdIJigXVDMsDH Elc/VNx0nZmkq2iqXMvfHNExp57SI/ffGhalnx3tagFI5x2I3GN/aWBukWl/4X7s59hZ vXd2/DDnJ3O/WWu/lRthS6pT76+DcNrtbGy+RLQOLOaItbygP9XwYcP125X4DwW7KGdw Zcpade12shFd7P6knRXJdUO2B2OKLfA5eGZK5hu6FID5JjzOr3VjixWACukEOHcbxG8q 2PQ5Ivv6vS/1Cdk/AMOuizfB+8laUdFLBdl9ncigd1+gDgi2ympZj1hoRPQrcLMNyycu aATA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j5si2161803pgt.196.2018.04.19.04.07.12; Thu, 19 Apr 2018 04:07:25 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752892AbeDSLFt (ORCPT + 99 others); Thu, 19 Apr 2018 07:05:49 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:39134 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751870AbeDSLFs (ORCPT ); Thu, 19 Apr 2018 07:05:48 -0400 Received: from static-242-42-24-46.ipcom.comunitel.net ([46.24.42.242] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1f97No-0001Ig-QD; Thu, 19 Apr 2018 13:05:45 +0200 Date: Thu, 19 Apr 2018 13:05:39 +0200 (CEST) From: Thomas Gleixner To: Imre Deak cc: LKML , Peter Zijlstra Subject: Re: Early timeouts due to inaccurate jiffies during system suspend/resume In-Reply-To: <20180419013200.wxkzqfdacfsijci5@ideak-desk.fi.intel.com> Message-ID: References: <20180419013200.wxkzqfdacfsijci5@ideak-desk.fi.intel.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 19 Apr 2018, Imre Deak wrote: > Hi, > > while checking bug [1], I noticed that jiffies based timing loops like > > expire = jiffies + timeout + 1; > while (!time_after(jiffies, expire)) > do_something; > > can last shorter than expected (that is less than timeout). Yes, that can happen when the timer interrupt is delayed long enough for whatever reason. If you need accurate timing then you need to use ktime_get(). > After some ftracing it seems like jiffies gets stale due to a missed > LAPIC timer interrupt after the interrupt is armed in > lapic_next_deadline() and before jiffies is sampled at 2. above. > Eventually the interrupt does get delivered, at which point jiffies gets > updated via tick_do_update_jiffies64() with a >1 ticks increment. > Between lapic_next_deadline() and the - late - delivery of the interrupt > the CPU on which the interrupt is armed doesn't go idle. That's odd. I have no real explanation for that. Thanks, tglx