Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp885672rdg; Fri, 11 Aug 2023 03:10:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHo5axb3UWVzVRkh0pMN9aS4zpr8z5G0hoexPhKxT+jIHB4CtL1Ffb1RRBV5UZaGZ7wrwZ9 X-Received: by 2002:a05:6512:ea1:b0:4fd:fc3d:cce7 with SMTP id bi33-20020a0565120ea100b004fdfc3dcce7mr1163649lfb.44.1691748641395; Fri, 11 Aug 2023 03:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691748641; cv=none; d=google.com; s=arc-20160816; b=qaIDACxCG+LkSSNOODojbFyFwfivAWl3A6UT2x5ZRs8oh625Oi0HtTJBdIbgQF/3s7 RKmeAtPp8NWOB5LztBu+R0bWAom9bdMVxeHyEX4+csA4agLRP3VhpTHt5aKb6DIBZVnQ yZXh6Ueq/tczsdRf9OCaMTR79OKKs7ftIJsbA+TwdOxz0dbqIU/9OFYMHnN2VK1XoFYB oHrL2dCJFGJrAXB+rou0NIJ6ZeMhZNKSJ0oeoqRb7e+9jDt1G59LDax1nihRvBe6MOJl OaYrJ12XGVoMT/nmUeydOW845vbTkNsOjTsbIFyAAxU4v08VqszWQlW/5Zziazix/Na2 xq2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=zOu7O9S3BXG7K2rtWSgAVdP2eUTNvhe/0S1pKzpGaEk=; fh=a5Pq3Y2a17IquuDSiqGctImGhr04KQeb6tXvCr2ORtM=; b=IW2H1fmg6F7L+fi3Nv9YlDMAHA3Le50TpNu5TLd3huJn3PQyvtjFaFaNikv1QjbNn1 jlD9/G0SvGCgPTtijWYkVq9DbgX9sUqJkycOYoeud3Tsv3UqX0ziTq2X7Grp+kI8O035 tutjX1UMuPJ4hhoWm7QqTP/BWZChZ9lpLE+3sC7l5j0fFVkNTGsL7WRy+arCDQ9ORhBr InxWLAaJFvd3vYk4TI59UPlFQ4UmjaOPfQDib3Tpi+razCX9fSptgHRLTznPggq4rGvl YnbIctYJ06VK1jWuZi5PUqwAfGnbH0P3OcxWApQk96L7eACJAuEf87E9c4MW6oIgJkNA BLFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k15-20020a05640212cf00b00523108dab21si2945648edx.147.2023.08.11.03.10.17; Fri, 11 Aug 2023 03:10:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231956AbjHKJkp convert rfc822-to-8bit (ORCPT + 99 others); Fri, 11 Aug 2023 05:40:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235174AbjHKJk3 (ORCPT ); Fri, 11 Aug 2023 05:40:29 -0400 Received: from mail-oo1-f51.google.com (mail-oo1-f51.google.com [209.85.161.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFF2D35B0; Fri, 11 Aug 2023 02:40:24 -0700 (PDT) Received: by mail-oo1-f51.google.com with SMTP id 006d021491bc7-56d67c5e87cso279352eaf.0; Fri, 11 Aug 2023 02:40:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691746824; x=1692351624; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4iES/w1U21fZ5HBN+a1vc2Ejc13Aw9VFT0tg5NlV+Wc=; b=eZV4fgZ66RP930FCuzwcb4/S+be3ulNemM2EMEKJKCcEsROL2cWu5I/LP6Fw5PVkV4 q7gUEljMZeFxuPQpL8QiyRNKHaZO0p3/r3oZtMc9j5chtsLrA1k+5kHWMx0qMZKoNGxK kddpQoGYiGF/W3f2Vehs2Jm7YJAZWgTYg0mXQ8yGXiJcISsul64GycmooCPWCObB0I0K 8d5KKLE131iEwdxkXf42Kgfg6t0vGyTYT3g4AbGsxJY02gw8b3e28h9rut9pmgt8+4BB d1MzBGAWXKBwbE605FLldHKSu6IxM+ja/L3eS5LSaLwYaFVk3jCzAHoBSKZVisYrxb6o bMzg== X-Gm-Message-State: AOJu0Yz7X/PEh8QOt3GTnesH8d16qAWrVPP7UabS3NTCsMNDmtZEB5bL UzsHuA76UazLzHimuOOarM5fD5AXU70SzzZRLuLzYOFmgW4= X-Received: by 2002:a4a:a3c1:0:b0:563:3b56:5dc1 with SMTP id t1-20020a4aa3c1000000b005633b565dc1mr869443ool.0.1691746824155; Fri, 11 Aug 2023 02:40:24 -0700 (PDT) MIME-Version: 1.0 References: <5712331.DvuYhMxLoT@kreacher> <2167194.irdbgypaU6@kreacher> <28e2d9ce-89db-807a-9d39-f2fcccfb2ad4@linutronix.de> In-Reply-To: <28e2d9ce-89db-807a-9d39-f2fcccfb2ad4@linutronix.de> From: "Rafael J. Wysocki" Date: Fri, 11 Aug 2023 11:40:13 +0200 Message-ID: Subject: Re: [RFT][PATCH v2 2/3] cpuidle: teo: Skip tick_nohz_get_sleep_length() call in some cases To: Anna-Maria Behnsen Cc: "Rafael J. Wysocki" , Linux PM , Peter Zijlstra , LKML , Frederic Weisbecker , Kajetan Puchalski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, Aug 11, 2023 at 10:52 AM Anna-Maria Behnsen wrote: > > Hi Rafael, > > On Thu, 3 Aug 2023, Rafael J. Wysocki wrote: > > > Index: linux-pm/drivers/cpuidle/governors/teo.c > > =================================================================== > > --- linux-pm.orig/drivers/cpuidle/governors/teo.c > > +++ linux-pm/drivers/cpuidle/governors/teo.c > > @@ -166,6 +166,12 @@ > > */ > > #define NR_RECENT 9 > > > > +/* > > + * Idle state target residency threshold used for deciding whether or not to > > + * check the time till the closest expected timer event. > > + */ > > +#define RESIDENCY_THRESHOLD_NS (15 * NSEC_PER_USEC) > > + > > I would like to understand why this residency threshold is a fixed value > and not related to TICK_NSEC. I'm sure there is a reason for it - but for > me it is not obvious. Can you please explain it to me? First off, I'm not convinced that there is any direct connection between the TICK_NSEC value and which idle states can be regarded as shallow. HZ may vary between 100 and 1000 (an order of magnitude) and this doesn't affect the target residencies of idle states in any way. Next, the checks involving this value don't influence the tick-stopping decision in any way, so I don't see a reason why they should depend on TICK_NSEC. Finally, it can be observed that ideally, the return value of tick_nohz_get_sleep_length() should always be taken into consideration, because it may influence the idle state selection in any case. However, if the target residency of the idle state selected so far is really small, calling it may be skipped in case it is costly, because its contribution is not likely to be significant. Worst-case we would end up with a CPU wakeup before the target residency of the selected idle state has elapsed, so some energy will be lost and some exit latency will be incurred in vain, so this really should be done when the numbers involved are small enough. Now, what does "small enough" mean? My answer is 15 us.