Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4272844pxf; Tue, 16 Mar 2021 09:26:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+KAnxnnUQ3It2mbXXOFlkm2yPPW0V+kYpLyxr9vOsC/K9y/mKMucdiQEM7kAE7iyBimOy X-Received: by 2002:a17:906:3c18:: with SMTP id h24mr30266735ejg.435.1615911983285; Tue, 16 Mar 2021 09:26:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615911983; cv=none; d=google.com; s=arc-20160816; b=wdjnUJ/rOxJCfbD1UWABvsBmUXT0Y3xuiTI5hOkos3DlO7aPQHfzVNnAzVRJLkpZ3J PAvss2VtVu7gdzKAd4YjO94WcGCoaZIWO0cpwt3UFkW+X6BZYVvpFDEeECPshw9hOsB6 QE8JJrUmLFW6Mb54yuVnGNpvWdQW8oCwyUBRsC2OU0yo0eT3kS+Rk/T0EiZYZbmuN9Q/ rCrdQiCXpuoFtW2q3J2f+9XvyTj56VCm8zeudJmr+Dnw4nJ3gKYqlJaEPeNO5HwGkSvS JQ5dN8/TGJHbzkcsQ+k4Agg2DZPovOs4wrQBQN+nv+YxiQxWLca8+8kgH7mUIdyuc7Oi Dalg== 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=g7fHWJA7sbsVtmFIUlMQw5fJCVfAjzklpe5toosTlvg=; b=FeMw2ef8wRjHLdPz4SofYwMHyrlVBC3q6fPLzfDBj6Or4fLOkyVgL3FyofJK8MtSKS ZmXsGcZjPhZF3jqCoI/H4MR6MFBcnOTK94PggOC7firwcFLvrZQS1LSKIEPl1dEKzV8V ArKwJokIma0NjbnWFJM76rr8C5sLjlOFH0t8UE92b88elsbEE7s/3E6My+6eEDg7+tYr NryGRpJ0E0nytEG/m5aL8VZ7+O2H+QO3QcnPrtSsgNsiCnqVmd49/WVISCzo8CYaGnPz qJATcvPAIu1evsW4nt3WmH6clc27YVL9uJttrzamgy/W2sg7RGmwUlzfx8sMIeKtxqN+ f0nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oAvXHV1S; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i2si13376598ejg.669.2021.03.16.09.26.00; Tue, 16 Mar 2021 09:26:23 -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=@kernel.org header.s=k20201202 header.b=oAvXHV1S; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237612AbhCPOyc (ORCPT + 99 others); Tue, 16 Mar 2021 10:54:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:53996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231277AbhCPOxz (ORCPT ); Tue, 16 Mar 2021 10:53:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 475DE6508C; Tue, 16 Mar 2021 14:53:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615906434; bh=iDvKivvZe2AXkjSJBSIKjW2/ReT9lsm6+x92RtUJwP0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oAvXHV1ScYZF8wjabtZwQG2KTgM9YxZJ4ZhCefyUz8MAPSnHJYDC1xaHBeTfaVVD/ mKP7soyeQSXgCzC4NhJpa0daF9kB+VqmKI+XS4TgnYFDvANG6Hx5YewXFlY1Wzpy/5 8BgpfHN+G4j1kUR25iRRYCVJO8MJvhGMAe9zcd/cmS3F+kRsyg/RMc7D2sv1nMPsTs aN5dmPJ8/qwbB+mHm6hDFQzKJk8Yqz2eXA8luVq/MaxzURXL0d6KLv2bmYo3rrZjM3 0VApLMnJngKfNmnvtyDChxG/UWnxg9QRNKjX379x+l5/RIy3NJsho28x2KBYPmGqEO bL5NqW0tNARUA== Date: Tue, 16 Mar 2021 15:53:52 +0100 From: Frederic Weisbecker To: Peter Zijlstra , "Rafael J . Wysocki" Cc: Thomas Gleixner , LKML , "Zhou Ti (x2019cwm)" , 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: <20210316145352.GE639918@lothringen> References: <20210311123708.23501-1-frederic@kernel.org> <20210311123708.23501-2-frederic@kernel.org> <20210316133703.GC639918@lothringen> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 16, 2021 at 03:35:37PM +0100, Peter Zijlstra wrote: > On Tue, Mar 16, 2021 at 02:37:03PM +0100, Frederic Weisbecker wrote: > > On Tue, Mar 16, 2021 at 01:21:29PM +0100, Peter Zijlstra wrote: > > > 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? > > > > There are already two callers and potentially two return values to check > > for each because the function returns two values. > > > > I'd rather make the API more robust instead of fixing each callers and worrying > > about future ones. > > But what's the actual problem? The Changelog doesn't say why returning a > negative value is a problem, and in fact the return value is explicitly > signed. > > Anyway, I don't terribly mind the patch, I was just confused by the lack > of actual justification. And you're right, the motivation is pure FUD: I don't know exactly how the cpuidle governors may react to such negative values and so this is just to prevent from potential accident. Rafael, does that look harmless to you?