Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4435678pxf; Tue, 16 Mar 2021 13:27:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoB6Gm0Xjkz1cmXm8HPfG/EyFKORdWBAG2IeaMd+cexEI6yopAICy270BjmdM+krXYBaDT X-Received: by 2002:a17:906:b318:: with SMTP id n24mr20093379ejz.372.1615926440525; Tue, 16 Mar 2021 13:27:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615926440; cv=none; d=google.com; s=arc-20160816; b=ICX46nm3Wc2WSYpABIrSEklNvdSwassB8JNgMyBup8SNyz7cWhfuQAWePY8IZoLiju sFvoAGQr304fZIkcIVDCO7MnLCqoG2kvy81XwWhRM5YEo7jFr1TCiI9ZxQm829J21bCi uBq+AyDYABQKGtkFJxWKHgLmHBYb2d6k0WbbeRtoV6sKTTXsPv3WCsJ3uPMsjiSQNE5e KD6Ishb7vWp2Lhj/a9VbMPXt0kzsSWYhptJLhhErhk7Ok6CGELMHDi4eV6da2bK+HQw8 DwGIeYrBaesgGw8ORhXlYga49kj/CpkSKD7l56fOx7ShwynNWztpWBYqY6VWW7W9XSc3 aYHQ== 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=W0lz3MhKNP6+4E2CL9Vp5MR4w2DHObbmpdpdVCRAZ3k=; b=WfLuYBkJgDQinhIExHFRvxZk15zBVt35RXMTX8RxDl04DnmsIa+soRMYx/edHXBW+r 1Y5mjC1xdKjEAzTjsZmkm4fFZ1VnMeGUzdrQyet4tlXPLi3XHN4utIeUCS0MoFdJv2an NcBtp93Mj1L+BhRQT2voZ5IG3MABxxVOSICHHRwzH87L1jRhRBl2gOSPFGA3iV/uC/Ot qRuBVCUSLEms1oSp6P7N5keyDc5I/GzCawjs/ipChHa+gVAhrUjA5pmZDrNyDYDCObT6 VGSA80no97b//7vENojJ1QXtozsi7FthGmFMQqqFIvqZ7xbS3ZGKDfGCxLXHP3tjAaHn 5O3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZucTS18h; 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 jo5si15647997ejb.644.2021.03.16.13.26.57; Tue, 16 Mar 2021 13:27:20 -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=ZucTS18h; 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 S235243AbhCPNhO (ORCPT + 99 others); Tue, 16 Mar 2021 09:37:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:51236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235192AbhCPNhG (ORCPT ); Tue, 16 Mar 2021 09:37:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BF2436500A; Tue, 16 Mar 2021 13:37:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615901826; bh=Yg9oeOO4X/in9ARGZA4zEauVUk8GipYuND6vVZtMxnU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZucTS18hS1xL28ujRkmN9bAoZrtlBj5P+RjEJm79ORm9ImWrrVb0lpUGt8FxlIYc5 Nt90A/NEqlBKYgrebPlg8EJuc+qqyokX9PG7+Xa6yXUUlZN858z3er5dxieA4HnscF 88nxpuuWJdNxLUgUvT9AXB8mASHnQ5COlPHMTpUWKs2hdttixOownEDPiSnnhrVOU4 brFwzVBoBgBdGPDZx3nKNc+QyLzZ/TyQkmU1Av/1ZAHPmjMFcvxmb/yi7niA8V7CV2 4F55bqi5au7BZnAh+dyHf92PSB/qL7pO1WgCnqYLdVnLkE/q72zkh5QiQ3caDGBSId mm/44PPEsehmQ== Date: Tue, 16 Mar 2021 14:37:03 +0100 From: Frederic Weisbecker To: Peter Zijlstra 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: <20210316133703.GC639918@lothringen> 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.