Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp332508pxx; Thu, 29 Oct 2020 03:54:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLtIPGc7dMJ/Ar2Y8yjWD1XowdllydeLZpjwsO0wqC1NMHwu++ooKJBYFyMRfc8Vj3uMq5 X-Received: by 2002:a17:906:814:: with SMTP id e20mr3618235ejd.367.1603968872002; Thu, 29 Oct 2020 03:54:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603968871; cv=none; d=google.com; s=arc-20160816; b=McH9rM07ocD+GR7oYr96qB5uE4XHaDMbmn3Rb+Ek+jHr2lhhAqBxy1jwRR2nttxapN 2dLYA/Hv+jR3p6Rqc+WuIBMKzL/cs8frY4SV8+qkWTDmCrbDIvQaPgbwGYNEJon13R7s Gp+N28vfYAYHAVIUdov8gWumFuFpKW2JAIqDUtldyiskKNETKRRAbPl3TGuNsAP781Zn M5Gg/KhO5Mc4stl4WcwF4DS95HCpX/n1ysdSeFR7k+qgHvlpYuAt4lj8LaUG6ooOF4fk +oUoqpT8AHcFm0enpH4riwn33z9JZlOhWUr3LOv2CuE+uQBpvvo5gA1ISmOzbfve/OAf uT+Q== 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=fnX4T+Yu+tpptypCpXVJawwc6puGWhEcbA1bI1Ml53s=; b=UUCiLSx35JBrcU43oGdDakEj2aCtLJKtM7zcovTNyJB1nBFQAT0mj4C+AqwNF2+cHc kYtfympAbaAlCZCllPcw4raqKTfBPGGL/NgTvGRJOlNMPymXx9c6nlfQ8YgWRVP/xuun J8m7SegnKxOL9rG5cQEuiNBIC4YDDAN/bs48zINZB8Raw2co8KcIbJF9FWVNFVWz8YNS Y5p5Xzoecqp14HJl3t8gaAT0aldiXtqOwXPsdPmu786vj9FVvdY3xYYYom6uJ6x9aPLk 76s3uqyk6l6aRKVc496jHGMCIL28nDuZBqpH8irPx5gNCH1lPODpQX0StOan4PrnPk0c rC3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=yh0fwPdd; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r12si1479667ejr.690.2020.10.29.03.54.08; Thu, 29 Oct 2020 03:54:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=yh0fwPdd; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1727277AbgJ2KwT (ORCPT + 99 others); Thu, 29 Oct 2020 06:52:19 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:60756 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726882AbgJ2Kvw (ORCPT ); Thu, 29 Oct 2020 06:51:52 -0400 Date: Thu, 29 Oct 2020 10:51:50 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1603968711; 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=fnX4T+Yu+tpptypCpXVJawwc6puGWhEcbA1bI1Ml53s=; b=yh0fwPddMvhUsDxktJVf5MmiwymvuPZ51UJADcLv02urGSjQ1e4lQVMZMeYow9KCKqQwh2 yMJJQirSicQ6iVmnB4I79gfoCzt7Ki2Da1/qiMKpnPdiw8nri48Jb6Ot+rSrB2upJNE/4t wtBxOmSkkq5UKiBBTvBtdUnFDR3+noQt3HJW1a0p8qL7loAa6OHeYyjXr472S0+zuwCU9n GujhbZU6JsZPZuyRAL6X02PNsVZcrXg9xz5UJ2vrsN7XMWHS2SeIyaDbeLMQdujt8H6vJ+ YQA1vyYgM/vZir0q+fJJTAuOWXN7rC0Guc27TdD+4CZ/97kKSROL5CEQazQaqg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1603968711; 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=fnX4T+Yu+tpptypCpXVJawwc6puGWhEcbA1bI1Ml53s=; b=QNEsP7NJGZZy1qYKllPjXyhi6Md8ZaFXIKtHfKdchGxWPZyN0POC9EoO0EYMJyvYJXdZPT 4jw9KQ8m2f/9LeDA== From: "tip-bot2 for Dietmar Eggemann" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/cpupri: Remove pri_to_cpu[CPUPRI_IDLE] Cc: Dietmar Eggemann , "Peter Zijlstra (Intel)" , x86 , LKML In-Reply-To: <20200922083934.19275-2-dietmar.eggemann@arm.com> References: <20200922083934.19275-2-dietmar.eggemann@arm.com> MIME-Version: 1.0 Message-ID: <160396871056.397.17031098897920284601.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: 5e054bca44fe92323de5e9b71478d1904b8bb1b7 Gitweb: https://git.kernel.org/tip/5e054bca44fe92323de5e9b71478d1904b8bb1b7 Author: Dietmar Eggemann AuthorDate: Tue, 22 Sep 2020 10:39:33 +02:00 Committer: Peter Zijlstra CommitterDate: Thu, 29 Oct 2020 11:00:29 +01:00 sched/cpupri: Remove pri_to_cpu[CPUPRI_IDLE] pri_to_cpu[CPUPRI_IDLE=0] isn't used since cpupri_set(..., newpri) is never called with newpri = MAX_PRIO (140). Current mapping: p->rt_priority p->prio newpri cpupri -1 -1 (CPUPRI_INVALID) 140 0 (CPUPRI_IDLE) 100 1 (CPUPRI_NORMAL) 1 98 98 3 ... 49 50 50 51 50 49 49 52 ... 99 0 0 101 Even when cpupri was introduced with commit 6e0534f27819 ("sched: use a 2-d bitmap for searching lowest-pri CPU") in v2.6.27, only (1) CPUPRI_INVALID (-1), (2) MAX_RT_PRIO (100), (3) an RT prio (RT1..RT99) were used as newprio in cpupri_set(..., newpri) -> convert_prio(newpri). MAX_RT_PRIO is used only in dec_rt_tasks() -> dec_rt_prio() -> dec_rt_prio_smp() -> cpupri_set() in case of !rt_rq->rt_nr_running. I.e. it stands for a non-rt task, including the IDLE task. Commit 57785df5ac53 ("sched: Fix task priority bug") removed code in v2.6.33 which did set the priority of the IDLE task to MAX_PRIO. Although this happened after the introduction of cpupri, it didn't have an effect on the values used for cpupri_set(..., newpri). Remove CPUPRI_IDLE and adapt the cpupri implementation accordingly. This will save a useless for loop with an atomic_read in cpupri_find_fitness() calling __cpupri_find(). New mapping: p->rt_priority p->prio newpri cpupri -1 -1 (CPUPRI_INVALID) 100 0 (CPUPRI_NORMAL) 1 98 98 2 ... 49 50 50 50 50 49 49 51 ... 99 0 0 100 Signed-off-by: Dietmar Eggemann Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20200922083934.19275-2-dietmar.eggemann@arm.com --- kernel/sched/cpupri.c | 10 ++++------ kernel/sched/cpupri.h | 7 +++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/kernel/sched/cpupri.c b/kernel/sched/cpupri.c index 0033731..a5d14ed 100644 --- a/kernel/sched/cpupri.c +++ b/kernel/sched/cpupri.c @@ -11,7 +11,7 @@ * This code tracks the priority of each CPU so that global migration * decisions are easy to calculate. Each CPU can be in a state as follows: * - * (INVALID), IDLE, NORMAL, RT1, ... RT99 + * (INVALID), NORMAL, RT1, ... RT99 * * going from the lowest priority to the highest. CPUs in the INVALID state * are not eligible for routing. The system maintains this state with @@ -19,24 +19,22 @@ * in that class). Therefore a typical application without affinity * restrictions can find a suitable CPU with O(1) complexity (e.g. two bit * searches). For tasks with affinity restrictions, the algorithm has a - * worst case complexity of O(min(102, nr_domcpus)), though the scenario that + * worst case complexity of O(min(101, nr_domcpus)), though the scenario that * yields the worst case search is fairly contrived. */ #include "sched.h" -/* Convert between a 140 based task->prio, and our 102 based cpupri */ +/* Convert between a 140 based task->prio, and our 101 based cpupri */ static int convert_prio(int prio) { int cpupri; if (prio == CPUPRI_INVALID) cpupri = CPUPRI_INVALID; - else if (prio == MAX_PRIO) - cpupri = CPUPRI_IDLE; else if (prio >= MAX_RT_PRIO) cpupri = CPUPRI_NORMAL; else - cpupri = MAX_RT_PRIO - prio + 1; + cpupri = MAX_RT_PRIO - prio; return cpupri; } diff --git a/kernel/sched/cpupri.h b/kernel/sched/cpupri.h index efbb492..1a16236 100644 --- a/kernel/sched/cpupri.h +++ b/kernel/sched/cpupri.h @@ -1,11 +1,10 @@ /* SPDX-License-Identifier: GPL-2.0 */ -#define CPUPRI_NR_PRIORITIES (MAX_RT_PRIO + 2) +#define CPUPRI_NR_PRIORITIES (MAX_RT_PRIO + 1) #define CPUPRI_INVALID -1 -#define CPUPRI_IDLE 0 -#define CPUPRI_NORMAL 1 -/* values 2-101 are RT priorities 0-99 */ +#define CPUPRI_NORMAL 0 +/* values 2-100 are RT priorities 0-99 */ struct cpupri_vec { atomic_t count;