From patchwork Fri Oct 28 06:42:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 12115 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp659770wru; Thu, 27 Oct 2022 23:46:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6IXbOfn74vHDvnbd/2JtXevXyPyhmrpPPPzp8j1REoSnG0RFxezwvR8eMQOhEi1rAA6YvA X-Received: by 2002:aa7:c552:0:b0:462:d3c3:4e17 with SMTP id s18-20020aa7c552000000b00462d3c34e17mr1062438edr.29.1666939612553; Thu, 27 Oct 2022 23:46:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666939612; cv=none; d=google.com; s=arc-20160816; b=DXQuix1pNlub0D7ZsyXhg0P9/p0IaVtvwhBbZCa+Yr802g/lidvA31pPBu5gNn+MbF 6NQeqsb98Gk3pH61TQojUaBXiISvOadfiuo9XoKTkLMKk3I2b+3xkey4E+fyQ2Ox+y95 SRA58vm+FzqGaO7wkhnZy5mRJDjVHPvXhWHXCGDUScXwpLenSC2kMxU16Ui7KlTL5ntN sy7Vhoy/lUXGNQds/XRYCoLBWI8YOrjAuD37he7MvVGCxV3WgbPERLSrAAdViJTv6rTt RaV08C09StjJcNtsOXPSxrwxSJ6wGkEcr9jDV6W8XhEfXNOmhV1Kgb28slNn11kp1iGk NFfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=8FPWy9dxsvJ87AQ4H7NffNmNm1H6ObkOEShfWh8apPE=; b=isDKhpkz48RQD0IA1MmP/LxcnFUZj4yupdEPlTIiuw0XS3UcCIn7Ad/hCaNiTL7F6o wEyBr4GzMPeuz8eUbtUWMLBhvL/HEPCieQfssP/SWwYNNK0F/EKd4OQl7WPDDj3PqSFk xYfzVeVjtTztto8aIBNSkTqVa8xwVSmmajNMejQgjgXOAagMRlr76VMSnk2LEB1E2WTC Oh/fRZcUa93XgV2Eni2bpX4BTKiz42dZzScrWCXsouVAU4P9gxqENMg2Fx+RSYCRxRgR 1v2ur4hboMcyj0uC4jkVfP+wqgHKOTp5LR8zTNhvW3c6kDsm1ypd2nUUhhniBv3SbSMO tlxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tIOzD8rU; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dr11-20020a170907720b00b007abafd4d7d9si1740674ejc.935.2022.10.27.23.46.28; Thu, 27 Oct 2022 23:46:52 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tIOzD8rU; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229933AbiJ1Gor (ORCPT + 99 others); Fri, 28 Oct 2022 02:44:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230038AbiJ1GnV (ORCPT ); Fri, 28 Oct 2022 02:43:21 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D9051BB543; Thu, 27 Oct 2022 23:42:27 -0700 (PDT) Date: Fri, 28 Oct 2022 06:42:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666939345; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8FPWy9dxsvJ87AQ4H7NffNmNm1H6ObkOEShfWh8apPE=; b=tIOzD8rUycxDvTDSH0LU8qsf9BjDt4RjkAhkPrlS4v8KSc8J+fRQPwHTMuaGRykqWwrBST pr6v1hwfGGZr1vj/zGQNF6hd2nHO7v3uIbm3L5gQU8xZcjPsO68wxmcaWyVaFxF7rq6KQt x/CGD6s6T/cwgxzFwR9N7dmVZ1DmRvvCrojOYVak1cR345mhS5UqmUkJ+Q49m5wvbHgbTM SnTzopDIRRKqhB6qNTLdFpZL2oJjlhdHOf9XPtN+MkCnbfrWwUXZheD+QmUzDfgvh6nm2L Ea/jsSlKxZGpiuPRr0MP7a3ovH7S7CKd/QfXC7ouNrsyaGEME2E5Dvt4DKUd0w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666939345; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8FPWy9dxsvJ87AQ4H7NffNmNm1H6ObkOEShfWh8apPE=; b=UZ/QgsJo6U9wHS+0AFlhx+xHF9wV7fCWxG5+0mrp5BriLCm7UWFSznufZ3H8l0/uEG6HBU REBTSAWcN91LXxCQ== From: "tip-bot2 for Qais Yousef" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/uclamp: Make task_fits_capacity() use util_fits_cpu() Cc: Qais Yousef , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220804143609.515789-3-qais.yousef@arm.com> References: <20220804143609.515789-3-qais.yousef@arm.com> MIME-Version: 1.0 Message-ID: <166693934440.29415.7141115817055522938.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747912871124363068?= X-GMAIL-MSGID: =?utf-8?q?1747912871124363068?= The following commit has been merged into the sched/core branch of tip: Commit-ID: b48e16a69792b5dc4a09d6807369d11b2970cc36 Gitweb: https://git.kernel.org/tip/b48e16a69792b5dc4a09d6807369d11b2970cc36 Author: Qais Yousef AuthorDate: Thu, 04 Aug 2022 15:36:02 +01:00 Committer: Peter Zijlstra CommitterDate: Thu, 27 Oct 2022 11:01:18 +02:00 sched/uclamp: Make task_fits_capacity() use util_fits_cpu() So that the new uclamp rules in regard to migration margin and capacity pressure are taken into account correctly. Fixes: a7008c07a568 ("sched/fair: Make task_fits_capacity() consider uclamp restrictions") Co-developed-by: Vincent Guittot Signed-off-by: Qais Yousef Signed-off-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/20220804143609.515789-3-qais.yousef@arm.com --- kernel/sched/fair.c | 26 ++++++++++++++++---------- kernel/sched/sched.h | 9 +++++++++ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 0d193ef..db6174b 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4549,10 +4549,12 @@ static inline int util_fits_cpu(unsigned long util, return fits; } -static inline int task_fits_capacity(struct task_struct *p, - unsigned long capacity) +static inline int task_fits_cpu(struct task_struct *p, int cpu) { - return fits_capacity(uclamp_task_util(p), capacity); + unsigned long uclamp_min = uclamp_eff_value(p, UCLAMP_MIN); + unsigned long uclamp_max = uclamp_eff_value(p, UCLAMP_MAX); + unsigned long util = task_util_est(p); + return util_fits_cpu(util, uclamp_min, uclamp_max, cpu); } static inline void update_misfit_status(struct task_struct *p, struct rq *rq) @@ -4565,7 +4567,7 @@ static inline void update_misfit_status(struct task_struct *p, struct rq *rq) return; } - if (task_fits_capacity(p, capacity_of(cpu_of(rq)))) { + if (task_fits_cpu(p, cpu_of(rq))) { rq->misfit_task_load = 0; return; } @@ -8399,7 +8401,7 @@ static int detach_tasks(struct lb_env *env) case migrate_misfit: /* This is not a misfit task */ - if (task_fits_capacity(p, capacity_of(env->src_cpu))) + if (task_fits_cpu(p, env->src_cpu)) goto next; env->imbalance = 0; @@ -9404,6 +9406,10 @@ static inline void update_sg_wakeup_stats(struct sched_domain *sd, memset(sgs, 0, sizeof(*sgs)); + /* Assume that task can't fit any CPU of the group */ + if (sd->flags & SD_ASYM_CPUCAPACITY) + sgs->group_misfit_task_load = 1; + for_each_cpu(i, sched_group_span(group)) { struct rq *rq = cpu_rq(i); unsigned int local; @@ -9423,12 +9429,12 @@ static inline void update_sg_wakeup_stats(struct sched_domain *sd, if (!nr_running && idle_cpu_without(i, p)) sgs->idle_cpus++; - } + /* Check if task fits in the CPU */ + if (sd->flags & SD_ASYM_CPUCAPACITY && + sgs->group_misfit_task_load && + task_fits_cpu(p, i)) + sgs->group_misfit_task_load = 0; - /* Check if task fits in the group */ - if (sd->flags & SD_ASYM_CPUCAPACITY && - !task_fits_capacity(p, group->sgc->max_capacity)) { - sgs->group_misfit_task_load = 1; } sgs->group_capacity = group->sgc->capacity; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index a4a2004..0ab091b 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -3060,6 +3060,15 @@ static inline bool uclamp_is_used(void) return static_branch_likely(&sched_uclamp_used); } #else /* CONFIG_UCLAMP_TASK */ +static inline unsigned long uclamp_eff_value(struct task_struct *p, + enum uclamp_id clamp_id) +{ + if (clamp_id == UCLAMP_MIN) + return 0; + + return SCHED_CAPACITY_SCALE; +} + static inline unsigned long uclamp_rq_util_with(struct rq *rq, unsigned long util, struct task_struct *p)