Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp331058imn; Thu, 4 Aug 2022 07:38:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR4rFI4DlAmuMFMTorNc467QRqcRhqJgikf68NqXT9KTzYqCZdRPbERvPoaRFGWz1lIj3x8F X-Received: by 2002:a50:ed82:0:b0:43d:5334:9d19 with SMTP id h2-20020a50ed82000000b0043d53349d19mr2294554edr.232.1659623923122; Thu, 04 Aug 2022 07:38:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659623923; cv=none; d=google.com; s=arc-20160816; b=iKUeCmdEpdIOj45Ro3wpJlMQg+bUEovpf4D7QWdglsQkY70YnKdV839y2tRgzpb+N1 Y/LOhmSRpFBszTWaC/kMkOqOx/1AfRqEiGqxSqoda0oxhd3BYtnwx8voxm53bgfMZdop Fry+fcQocNN9tArImCWSY5hpOJloDXfXyc0qeihcIvb/I14lZsEcr8P1mFeQhWBU8kam VsX3SB7nvjDkgmxhf9bnUBlzu1Mkp5zsAstpANA75fOQ/7lTpuBbUqg4VYRSWGthLted WirX0w+kEs3ngXrGkKs3IRuzueg3HjDrSuMl1vUHsLrzEMUjC0eLJd3PWbmIi2kmMJw9 laHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=XF/jTkd05dQedS7HV8r1N+P78sB4TfXKFNA44VD3ayA=; b=FwPCeqV5xAAtgLAIL57vc5I9ouuyVLEuFDBGfh29t6FINCX+bl3jysBI1YCK/klMm4 ZxQPjNAd07bAbiiS951Q1+GCb5vgEeTnKOxgM0vVj6btfn6gOmhXqeWVakO+IV1Mo+6r zDtBQKY378A8nGFdu0SGHbIiGQUxKS0qfKvPJFu5/+rrMPt5yKcqkLhqrv7JGCi+V5FO nFIAaSK9oIYH2AsjOR6nFqIdof/IipSedPH2Lu2fqg66FGBBsrOgB7pWT9ynnoes1lih P0NZgffxUFH2eXQOyD9H1tPuij0RKHpVUj5zdlppjkgO2B8EYB5ZLyvFT/LF5CwdjaLs hESQ== 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a17-20020a509b51000000b0043c158735b6si1454102edj.108.2022.08.04.07.38.17; Thu, 04 Aug 2022 07:38:43 -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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234258AbiHDOgh (ORCPT + 99 others); Thu, 4 Aug 2022 10:36:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239600AbiHDOge (ORCPT ); Thu, 4 Aug 2022 10:36:34 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7F88831903 for ; Thu, 4 Aug 2022 07:36:33 -0700 (PDT) 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 CB20211FB; Thu, 4 Aug 2022 07:36:33 -0700 (PDT) Received: from localhost.localdomain (unknown [10.57.10.177]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9A5983F73B; Thu, 4 Aug 2022 07:36:31 -0700 (PDT) From: Qais Yousef To: Ingo Molnar , "Peter Zijlstra (Intel)" , Vincent Guittot , Dietmar Eggemann Cc: linux-kernel@vger.kernel.org, Xuewen Yan , Lukasz Luba , Wei Wang , Jonathan JMChen , Hank , Qais Yousef Subject: [PATCH v2 0/9] Fix relationship between uclamp and fits_capacity() Date: Thu, 4 Aug 2022 15:36:00 +0100 Message-Id: <20220804143609.515789-1-qais.yousef@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE autolearn=ham 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 Relationship between uclamp and fits_capacity() is currently broken. Mostly due to how uclamp should interact with migration margin and capacity pressure. But also due not all users were converted to consider uclamp before calling fits_capacity(). Namely cpu_overutilized(). The meat of the series is patch 1 where we introduce a new function, util_fits_cpu(), that takes uclamp into account. The new function should replace all call sits to fits_capacity(), which what subsequent patches do. Except for patch 7 where we fix handling of early exit condition in find_energy_efficient_cpu(AKA feec()) that must be uclamp aware too. util_fits_cpu() will revert back to a simple call to fits_capacity() if uclamp is not being used on the system. Last two patches still need testing and verification, but they address the various thermal handling issues raised in v1. We can re-order the patches, but added at the end to facilitate review at this stage. Hope the approach and the logic make sense. I'll be on holidays, so if I don't respond to review comments fast enough, apologies in advance. Changes in v2: * use uclamp_rq_is_idle() in uclamp_rq_util_with() (Xuewen) * Simplify logic in update_sg_wakeup_stats() when converting task_fits_cpu() (Vincent) * Better handling of thermal pressure (Vincent) - We consider thermal pressure for uclamp_min in patch 1 - 2 new patches to handle capacity inversion which improves handling when: + There're multiple big cpus on separate perf domains. + A task is boosted by uclamp_min and inspite of thermal pressure, the big cpu is still the best placement. e.g: p0->util_avg = 300, p0->uclamp_min = 1024 This task should stay on big CPU until thermal pressure is in capacity inversion. v1 discussion: https://lore.kernel.org/lkml/20220629194632.1117723-1-qais.yousef@arm.com/ Thanks for all reviewers on v1! Qais Yousef (9): sched/uclamp: Fix relationship between uclamp and migration margin sched/uclamp: Make task_fits_capacity() use util_fits_cpu() sched/uclamp: Fix fits_capacity() check in feec() sched/uclamp: Make select_idle_capacity() use util_fits_cpu() sched/uclamp: Make asym_fits_capacity() use util_fits_cpu() sched/uclamp: Make cpu_overutilized() use util_fits_cpu() sched/uclamp: Cater for uclamp in find_energy_efficient_cpu()'s early exit condition sched/fair: Detect capacity inversion sched/fair: Consider capacity inversion in util_fits_cpu() kernel/sched/core.c | 10 +- kernel/sched/fair.c | 290 ++++++++++++++++++++++++++++++++++++++----- kernel/sched/sched.h | 70 ++++++++++- 3 files changed, 329 insertions(+), 41 deletions(-) -- 2.25.1