Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4438717pxf; Tue, 16 Mar 2021 13:32:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2nVTE1cgY8enz9aX1OTuZpXAHovI6kqPOTb35TFRuteB6LPFbxmYFuvTU8Qmax+w7mV8J X-Received: by 2002:a50:ee95:: with SMTP id f21mr28452433edr.130.1615926740531; Tue, 16 Mar 2021 13:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615926740; cv=none; d=google.com; s=arc-20160816; b=C2rop7PjeXIVpBzEalJsDmE/MlYfk41DnOnBiwy1AsINijaRB7tHhujA7WiC3E8Lph MVf1Jf2N4IwJmNZgPcGPIRQCacIgZYLQTb/Nh/V4OWudjB6Ke4GfSh05wo2U4vsxZF2C zTG2w7fX2mVAfNDEp5pf3wyPdrE4Qr0k1JJoeHlgSO+DY/a45+qI6x5fQvA/KjEoPEBK GFIn57kMrUUdTxlEepk5phxxvUtXJEEieaS6ePXTVnBuhS9BQ/z6M2ZWRSfnZIs3gO/V jdh7eF/ykx1NflQzROQ+sQngGcCYIYbgHJ8d/pDJkRYUkQvx2ef+BOcdMxtN0NYOfx6T fYBw== 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=Rjw1WKumRyJtsR4bEBFv737F1QPjf5K33LJyF0RbOX4=; b=bc8HI4rxRu736P00chZIUlFNqrvijPCjjMGsiL3MJlGWc9EU1yWUGuzuAKtKBnlpWR aRYxAklUdPb/G5Pqaj4A6o1UhoMvh4MEizlTgw8zFAtvHdL2go9o5WxSEP9uatK5EfQI ya7L82/7mHQDg9UyPMeOH+phfUYKHYTs9nahP/n9P/sU6ll/nv14R6WQBetwEx3Ua0rL Xs/3ozb+clnNw/D1wArKtEbeusGevxu0FevGN8nMzSEei3qcf0mguV/m5X2v5du9VZdi MAVmxoLnoywdRpa0GY7n9cqcl4KJDqE6y8uUF86t575gowQgqySwlkEvHw0cuc57qopQ ei4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=KOm0ME0Z; 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 gf19si3208103ejb.500.2021.03.16.13.31.57; Tue, 16 Mar 2021 13:32: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=@infradead.org header.s=casper.20170209 header.b=KOm0ME0Z; 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 S233024AbhCPOgb (ORCPT + 99 others); Tue, 16 Mar 2021 10:36:31 -0400 Received: from casper.infradead.org ([90.155.50.34]:34786 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235595AbhCPOgY (ORCPT ); Tue, 16 Mar 2021 10:36:24 -0400 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=Rjw1WKumRyJtsR4bEBFv737F1QPjf5K33LJyF0RbOX4=; b=KOm0ME0ZCooVqAJKYEgrgA7Ah3 5i5Nirsw6NK9IBlXMNB0MLcB98NeQ45Hsy5GKnX7LDyac2tJVJ2OJ9ogW79SoIjpjGFjhSCXYPV55 JpCQ3RXlA3cHj4ddkb94as4qt9ssAC4TOm2NHr0YHNbbIl4oCHWzX4RhqFmdBTLuOcfV+KNyzwjiJ 2zvNo6CMZfSMGl8KoCjpsG8sbzS/QZeTEL/LJhw4HFThiV2cD+/yFGORc+E+Ox7oQ+AwnNX5m3M09 VKV+Zb8cMX3bVAI73DTepwna5jS7d32LOaEvfALOALMOkxfhacwpirZONh0rs8JT5I8roaNp9fMPn SynoETEQ==; 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 1lMAnK-000BYm-8s; Tue, 16 Mar 2021 14:35:46 +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 767BE305C22; Tue, 16 Mar 2021 15:35:37 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 167342DAC4D5B; Tue, 16 Mar 2021 15:35:37 +0100 (CET) Date: Tue, 16 Mar 2021 15:35:37 +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> <20210316133703.GC639918@lothringen> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210316133703.GC639918@lothringen> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.