From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1AE9F22A7E4; Thu, 16 Jan 2025 13:27:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737034070; cv=none; b=XRcy2+gVEfxbfU8rOeV9zOInUNasu16tofseRmfSj+YXAwzY3Pol77GtSTo+EzM1l3iAWeph9L6U3wai4s7kNgO5HZlnnBGS7W76XPGlvfpLebO5TquecUo67oZnmLbA7PeD5C+TrUstED+t5gvFNb3qCab6EHDV/rxwfFFmgO8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737034070; c=relaxed/simple; bh=FtfcWd01mSXm76DD2MYj54nNhXTffDs79k+HGqbaueo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ntKoW4s71spJaaeT83U2jm1ETJR2Uc0mkbmcqHyeSQRgMqu9JdAofDRnBPHVEqD7gljFwKH3wCeEY89bRbq+mcc0puDhGGJ9G0XXawGJ9sexvRG50+2VtSP35mf6nnhoq5DsuTqvBGU/fy8Fy1q4eBCVQbRSAgkHzXFq+yir88M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BB3C0106F; Thu, 16 Jan 2025 05:28:15 -0800 (PST) Received: from [192.168.0.16] (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 524D73F673; Thu, 16 Jan 2025 05:27:45 -0800 (PST) Message-ID: Date: Thu, 16 Jan 2025 13:27:39 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 2/9] cpuidle: teo: Reorder candidate state index checks To: "Rafael J. Wysocki" , Linux PM Cc: LKML , Daniel Lezcano , Artem Bityutskiy References: <6116275.lOV4Wx5bFT@rjwysocki.net> <1907276.tdWV9SEqCh@rjwysocki.net> Content-Language: en-US From: Christian Loehle In-Reply-To: <1907276.tdWV9SEqCh@rjwysocki.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 1/13/25 18:36, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Since constraint_idx may be 0, the candidate state index may change to 0 > after assigning constraint_idx to it, so first check if it is greater > than constraint_idx (and update it if so) and then check it against 0. > > Signed-off-by: Rafael J. Wysocki Fine with me now, since the posted patch addresses my concern. Reviewed-by: Christian Loehle > --- > > This is a rebased variant of > > https://lore.kernel.org/linux-pm/8476650.T7Z3S40VBb@rjwysocki.net/ > > --- > drivers/cpuidle/governors/teo.c | 15 ++++++++------- > 1 file changed, 8 insertions(+), 7 deletions(-) > > --- a/drivers/cpuidle/governors/teo.c > +++ b/drivers/cpuidle/governors/teo.c > @@ -428,6 +428,14 @@ > break; > } > } > + > + /* > + * If there is a latency constraint, it may be necessary to select an > + * idle state shallower than the current candidate one. > + */ > + if (idx > constraint_idx) > + idx = constraint_idx; > + > if (!idx && prev_intercept_idx) { > /* > * We have to query the sleep length here otherwise we don't > @@ -439,13 +447,6 @@ > } > > /* > - * If there is a latency constraint, it may be necessary to select an > - * idle state shallower than the current candidate one. > - */ > - if (idx > constraint_idx) > - idx = constraint_idx; > - > - /* > * Skip the timers check if state 0 is the current candidate one, > * because an immediate non-timer wakeup is expected in that case. > */ > > >