Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3764230pxk; Tue, 22 Sep 2020 01:43:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVOPEfbnqgs10ZfDzycGhMHKvWTCi9N4eNU4t3clZY0uRlcPgk//47mL1zj3d64RSLh1vx X-Received: by 2002:a05:6402:1254:: with SMTP id l20mr2801073edw.312.1600764220265; Tue, 22 Sep 2020 01:43:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600764220; cv=none; d=google.com; s=arc-20160816; b=Zr3h2CbFgtJI1/Tsn/YSly4pu3uIve8gIJysjtp/dgK97UZH1LXz5IuW7D+gkvtWMU ECQbZS5AclOtxIDD4EbJVnQ6FC8NhZz5lJQ+tCXNtFr/CepRPERHTEdF3kaB0rKLiMOg RugXSnrCPbzsltN0wuS8WxwmM3rGkmeef4ZwQh99+jHlMqPtoLX2B969uHUiQnkbhs0O YdshcMXuMWHtZKnsL5Pothja/vxtDHM7obHMzR3Lu6IS+RV98s2QIChBt2af/AALzMEJ 9kQpzYRcTl+6+4zSBercivAjJ51CxIPEfK7O00Et/VD5h09y+IxI6r5OD/V+btI+ee4N 23kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=AsJaBT8XdHxYWb4Q0iD0ZBmL2d7gj/E6P/+9Tx4j8lY=; b=bDvrDXWUGAEF77gU91N/YnH1BeUOg7h4tnXM9dBNVFOTfRSD2dHYV7nQrFExwoyeWq PA41RN1plyDXX0S1KyR9uny6PZdpedKhLFRqCnQfFveN7yQNzTWzbXJHrkpRiDIo2Fi8 pg1Nqz9l+Osg9/JTJmFO9XmwEpOEEuxWk1CWcHmh75iXGu1+EsaU/rOiKavpVHyshti5 F+Rr9LE3kYhaAjy/AWH6sVkzIYaYn34a62TFoabVH63RSLHi4Wpr3Z6lJTQHIL6BPwYp lYZWhs4cuf83mJAxkS2o3gh6zW7Khh841ZQv2blz3shlLTH6XSzHeDRn3O67J8/z5DkY PAXQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o12si10032787eje.30.2020.09.22.01.43.16; Tue, 22 Sep 2020 01:43:40 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726544AbgIVIjy (ORCPT + 99 others); Tue, 22 Sep 2020 04:39:54 -0400 Received: from foss.arm.com ([217.140.110.172]:57006 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726098AbgIVIjw (ORCPT ); Tue, 22 Sep 2020 04:39:52 -0400 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 6EB0013D5; Tue, 22 Sep 2020 01:39:51 -0700 (PDT) Received: from dell3630.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 37B3E3F718; Tue, 22 Sep 2020 01:39:49 -0700 (PDT) From: Dietmar Eggemann To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira Cc: linux-kernel@vger.kernel.org Subject: [PATCH 2/2] sched/cpupri: Remove pri_to_cpu[1] Date: Tue, 22 Sep 2020 10:39:34 +0200 Message-Id: <20200922083934.19275-3-dietmar.eggemann@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200922083934.19275-1-dietmar.eggemann@arm.com> References: <20200922083934.19275-1-dietmar.eggemann@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pri_to_cpu[1] isn't used since cpupri_set(..., newpri) is never called with newpri = 99. The valid RT priorities RT1..RT99 (p->rt_priority = [1..99]) map into cpupri (idx of pri_to_cpu[]) = [2..100] Current 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 So cpupri = 1 isn't used. Reduce the size of pri_to_cpu[] by 1 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 1 ... 49 50 50 49 50 49 49 50 ... 99 0 0 99 Signed-off-by: Dietmar Eggemann --- kernel/sched/cpupri.c | 6 +++--- kernel/sched/cpupri.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/sched/cpupri.c b/kernel/sched/cpupri.c index a5d14ed485f4..8d9952a51664 100644 --- a/kernel/sched/cpupri.c +++ b/kernel/sched/cpupri.c @@ -19,12 +19,12 @@ * 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(101, nr_domcpus)), though the scenario that + * worst case complexity of O(min(100, 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 101 based cpupri */ +/* Convert between a 140 based task->prio, and our 100 based cpupri */ static int convert_prio(int prio) { int cpupri; @@ -34,7 +34,7 @@ static int convert_prio(int prio) else if (prio >= MAX_RT_PRIO) cpupri = CPUPRI_NORMAL; else - cpupri = MAX_RT_PRIO - prio; + cpupri = MAX_RT_PRIO - prio - 1; return cpupri; } diff --git a/kernel/sched/cpupri.h b/kernel/sched/cpupri.h index 1a162369b8d4..e28e1ed12e3d 100644 --- a/kernel/sched/cpupri.h +++ b/kernel/sched/cpupri.h @@ -1,10 +1,10 @@ /* SPDX-License-Identifier: GPL-2.0 */ -#define CPUPRI_NR_PRIORITIES (MAX_RT_PRIO + 1) +#define CPUPRI_NR_PRIORITIES MAX_RT_PRIO #define CPUPRI_INVALID -1 #define CPUPRI_NORMAL 0 -/* values 2-100 are RT priorities 0-99 */ +/* values 1-99 are for RT1-RT99 priorities */ struct cpupri_vec { atomic_t count; -- 2.17.1