Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4377967pxf; Tue, 16 Mar 2021 11:55:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkv85crOQPNv2JzsWxD8omUvK+uLz3f+ZgiYohSic10LS9lj6vII2fQenxNzo1dI2x9wbv X-Received: by 2002:aa7:dd98:: with SMTP id g24mr37656960edv.75.1615920953320; Tue, 16 Mar 2021 11:55:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615920953; cv=none; d=google.com; s=arc-20160816; b=0gCULJ0idD0wR6BZnRfbF8QjiZcOwM8BetqwAxH0XWXY+pTZLS0pd/DDMW2gdOj9WG Vc2tGZFRKrKWS/hsThtNf4IGBKUTk7M3LLb2ifyyCAFd3gtOoi3X7dluObTSa/X8Bi4M 1EhonhY8pJcyFT3l6AzY9esj+yR3LB8p6XLKKYvgS5VPQyjl+otsxY/4MuNdYjHWJZOz Lvvaz/Z+Fv3GG7Dnm9TM2pzAgTbcZGvmEPG3EKYNV7SdFceRDguyeb7QqD1p21K4T+dU OXy+ULh1UcMGeoq+/F3CzV7qqWfz9U1h6m14unVotMSiNrnq1kJLS6zbgUJctJJmNGip 2nCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Ryq5JraLWwmrZbOIDM5SRRh6a4iXNMWbds4wIizdRSU=; b=jpqYj7n9VK01HI+6tH4dIOaGygbODKX6AkUIxswBQvi/1DTobD3CkntrmSn2EJaMrO ZMCDdZ+pqA5j2KFC+YJWAUJu1TAgHrKHv5xYmkkM1VPFPFby+AfVIDzbMSoC0xSYubEg x7GChspuEzNvFXaqkZ1nDWWEKWXNdoYoshXUBQLuA1+ZuGFqtSHCIQEtZ2t7gASHjhim ATJ9sBTR9o2Oc2u6aNOydWq326OCBPUJyqGv5DXyT0bGaPmHO/Wy/v0yjUNyf3ANAZbT DfV7DnZIi6qvoAFXjy57sRU98Mp6TtEyKes/CEQwHFTxG0fhjelk+Xi+pEM+crxnySBb Kg+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=FWG8uvM7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si14815626ejj.228.2021.03.16.11.55.30; Tue, 16 Mar 2021 11:55:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=FWG8uvM7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232107AbhCPMjC (ORCPT + 99 others); Tue, 16 Mar 2021 08:39:02 -0400 Received: from casper.infradead.org ([90.155.50.34]:52928 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232197AbhCPMid (ORCPT ); Tue, 16 Mar 2021 08:38:33 -0400 X-Greylist: delayed 974 seconds by postgrey-1.27 at vger.kernel.org; Tue, 16 Mar 2021 08:38:32 EDT DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Ryq5JraLWwmrZbOIDM5SRRh6a4iXNMWbds4wIizdRSU=; b=FWG8uvM7wEwDTZ8xoeJ2MGUiKH hWy4nMsZfpCZDNiJ3NgeNpKoh5XnT5RA4bf+GXanCDpyFAiR2QmigeJ8BoJJc9NympBVZKEMK7zlx 3gJ8zCSLn+Dm5/f8GIBgCD1b0RzjX65sFyQ0Wg2ecdo+V2WZNdMrcBfSGvkS459tmXiJRHEVPGWTQ Buhvd57775aiOzcl7QppUP5CdU6CRyssM5ntsbOqVfib18Z4l4IywgGY1rMj/jOtqrJcDBT77TBD5 eylTvh2hG9HMwPEi8f7F8tSl81z8kdETm/S/fRGcYbN80+BFD2EerR4YgWCRMvmpF8nQSy5bIxppw 9tQdO2Yg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lM8hW-0002Cc-UY; Tue, 16 Mar 2021 12:21:33 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id B72343012DF; Tue, 16 Mar 2021 13:21:29 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 65B1620B05D7A; Tue, 16 Mar 2021 13:21:29 +0100 (CET) Date: Tue, 16 Mar 2021 13:21:29 +0100 From: Peter Zijlstra To: Frederic Weisbecker Cc: Thomas Gleixner , LKML , "Zhou Ti (x2019cwm)" , "Rafael J . Wysocki" , Yunfeng Ye , "Paul E . McKenney" , Marcelo Tosatti , Ingo Molnar Subject: Re: [PATCH 01/10] tick/nohz: Prevent tick_nohz_get_sleep_length() from returning negative value Message-ID: References: <20210311123708.23501-1-frederic@kernel.org> <20210311123708.23501-2-frederic@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210311123708.23501-2-frederic@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 11, 2021 at 01:36:59PM +0100, Frederic Weisbecker wrote: > From: "Zhou Ti (x2019cwm)" > > If the hardware clock happens to fire its interrupts late, two possible > issues can happen while calling tick_nohz_get_sleep_length(). Either: > > 1) The next clockevent device event is due past the last idle entry time. > > or: > > 2) The last timekeeping update happened before the last idle entry time > and the next timer callback expires before the last idle entry time. > > Make sure that both cases are handled to avoid returning a negative > duration to the cpuidle governors. Why? ... and wouldn't it be cheaper the fix the caller to check negative once, instead of adding two branches here?