Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp278438lqp; Mon, 10 Jun 2024 04:06:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUgeqnjbn6f+pmbNL8LdfZiwowhaDiaTYLt/W+RgaPYNI95f3FxB/gG+T/YJUrzvx/zQ/PcZVuUv9H7ZpzLzc87vBAE8nfHeD5QHn5MXg== X-Google-Smtp-Source: AGHT+IEjw/0NOEq0b2ZeFYl8pA/QqD5/wH+4Xpyxui3Jz3L9mt9p34f0tFZYQAF1pKDBechI9C+B X-Received: by 2002:a17:903:245:b0:1f4:5ad1:b65e with SMTP id d9443c01a7336-1f6d02f4821mr92927485ad.34.1718017586713; Mon, 10 Jun 2024 04:06:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718017586; cv=pass; d=google.com; s=arc-20160816; b=Ir8URPmyaqj1OgZ4dV6Eh0twBhebmFlMcbfEAAgVHiTLAxJZSXSSSULHEhz3FH7GZl /9bLKcGWgHDUNLQZrkDGaatKNrm41gZslAeB1GVH3vEM5DQsteMrDCGdZp4s1d1YN35c ckt4jrKHYbJWOi39XVdo1q8hTKPKGmAe21pTk6X2IJQiD3TdDDSSS3+OpyyudpkQgHqJ 3YlKaXCJ2n9OFpyhcgigU8ORJBkMdcn4iD63skC9FzIXPRN3lSQ4ZVEkJxipTiRlt/3c KizHcc3cXiqkYwsarCRkUnLQ3AX7UyITEx0SFDvJ3qZ+2fuRN8sxUmjiNfI46kyEbDCa WJlw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=LBIjTBrchCznbT3uElhRTeBzgD+XAn5euCCt4I+omzk=; fh=NjdQ47HIW+wby1OubpffvYqVPsVadBLT8VH3PxBXJes=; b=qIrOUEmItqWZ9a9GIM2S6xzepbkPsov25Y0yyRnvytmodWXx2+2m5nb1tXYOsqxShN oraQCQBl2cuDDs0FHLqLhlZfN5UBEwFO6i2xAu3jgEYnf2C/RLIRz8+YuYk2j6WCCzBf BCfWMlsVNmYdrJ8YbBOot4oQHAzeI9eOHwAR1Nx5/NQzZkWEAFOEwHjpWF4xOe5c0DPu kXHLCOGg7Pco2qrsjF86T0wnq4B6Cd+qW8+/EeyHm4fd/PuqNXg1RxDzRdF3mBqRO9ke 5VpBnzdezrT3exCgWW22HTFzOWUEUFEnfjMLaBfyFC8AMKCtQBGGkfgjB2Go+Cdx9+et A5aA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-208060-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208060-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f6bd760d89si73522245ad.122.2024.06.10.04.06.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 04:06:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208060-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-208060-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208060-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 57E022847A6 for ; Mon, 10 Jun 2024 11:06:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 449A27BB13; Mon, 10 Jun 2024 11:06:14 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F14B3FC01; Mon, 10 Jun 2024 11:06:11 +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=1718017573; cv=none; b=P0WdjUA80DsJS/sApvUKNCfNyzoovzFd4LZ6IyjjQuk/cVfa2yl0T9YPdJp3WxRQocyXzHbl6QC0FwrSequI0hVqHsjVkdM6U+FDtTisTHisJRN12XvVi/JcTNWa3/614SWdn0vUhx0QndcCPrw4vyUX2JToZrCB1H9aQwPpY48= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718017573; c=relaxed/simple; bh=jsL8Kw6PFgSnYlx7ILeB6Tn4nUKxwvpN9JhVhat3+u8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=XA1560SbhGFn3ADEWS+Puke/EagxUWBWzp+ZyhQ2eeqM/en3q7Os/txay3koq0yTImJ+J3w8+9kxKghaAfL9EXfTIN7HIkVg1X1sxJsUHybZPtnZKS++vx9S/ResjNChe9j+eFFaI38PWMyjdqR928lIVqPT72Zv3HDsOrYqQyU= 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 EB69612FC; Mon, 10 Jun 2024 04:06:35 -0700 (PDT) Received: from [10.57.71.68] (unknown [10.57.71.68]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0E06A3F73B; Mon, 10 Jun 2024 04:06:08 -0700 (PDT) Message-ID: <33405fa7-7102-407e-8cc8-851c808cd47a@arm.com> Date: Mon, 10 Jun 2024 12:06:08 +0100 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 6/6] cpuidle: teo: Don't count non-existent intercepts To: Dietmar Eggemann , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, rafael@kernel.org Cc: vincent.guittot@linaro.org, qyousef@layalina.io, peterz@infradead.org, daniel.lezcano@linaro.org, anna-maria@linutronix.de, kajetan.puchalski@arm.com, lukasz.luba@arm.com References: <20240606090050.327614-1-christian.loehle@arm.com> <20240606090050.327614-7-christian.loehle@arm.com> Content-Language: en-US From: Christian Loehle In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 6/7/24 11:17, Dietmar Eggemann wrote: > On 06/06/2024 11:00, Christian Loehle wrote: >> When bailing out early, teo will not query the sleep length anymore >> since commit 6da8f9ba5a87 ("cpuidle: teo: >> Skip tick_nohz_get_sleep_length() call in some cases") with an >> expected sleep_length_ns value of KTIME_MAX. >> This lead to state0 accumulating lots of 'intercepts' because >> the actually measured sleep length was < KTIME_MAX, so count KTIME_MAX >> as a hit (we have to count them as something otherwise we are stuck). >> >> Fundamentally we can only do one of the two: >> 1. Skip sleep_length_ns query when we think intercept is likely >> 2. Have accurate data if sleep_length_ns is actually intercepted when >> we believe it is currently intercepted. >> >> This patch chooses that latter as I've found the additional time it >> takes to query the sleep length to be negligible and the variants of >> option 1 (count all unknowns as misses or count all unknown as hits) >> had significant regressions (as misses had lots of too shallow idle >> state selections and as hits had terrible performance in >> intercept-heavy workloads). > > So '2.' is the 'if (prev_intercept_idx != idx && !idx)' case ? > > [...] Yes, we allow the logic to bail out early, but not without querying the expected sleep length. (For idx > 0 the logic will continue to query the expected sleep length later on.) > >> @@ -514,6 +521,14 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, >> first_suitable_idx = i; >> } >> } >> + if (prev_intercept_idx != idx && !idx) { > > if (!idx && prev_intercept_idx) ? > Thanks! I picked that up for the next version. >> + /* >> + * We have to query the sleep length here otherwise we don't >> + * know after wakeup if our guess was correct. >> + */ >> + duration_ns = tick_nohz_get_sleep_length(&delta_tick); >> + cpu_data->sleep_length_ns = duration_ns; >> + } >> >> /* >> * If there is a latency constraint, it may be necessary to select an >