Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2442657ybl; Thu, 19 Dec 2019 13:47:07 -0800 (PST) X-Google-Smtp-Source: APXvYqwssb568NMWtb7I/bGURbsU8Zg+y9Zm1N19TW4zA/Gz118Q6LYS5MZs4Zdb6gl7sp73D4V4 X-Received: by 2002:a9d:74c4:: with SMTP id a4mr11287145otl.119.1576792027262; Thu, 19 Dec 2019 13:47:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576792027; cv=none; d=google.com; s=arc-20160816; b=iNTj42oDBflEwQHeLK7n2SuYfrbJlZ7WROaNh+lfUawnUimQH9pxuS4wdz5p4tzwth GAbMwycDO6DyQL+TjWxKOcdZyMHwE8x4tmB9zKbXfe46OsDS2VfVQ/A2c/L0DDGHsuKG giS9sAW6RYO5RUi2hj9iz7iJsQyEBi/ozqiPo/9G3HD6IHirPUXepKy0pOFFiYNA0edi 11jdQ5b/VVL2H0wGXTIEMLkiqeKTBh6XjYCuQKTfW8it5kqft00jyBTDVH1iZpcBdDbr QtGvluuQto5crVH+q464143kAmAOZ7zuFQ6JjCum1SmbZikXx5kBzvX6nc1xFEiG0NjT 3Giw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:subject:cc:to :from:date:user-agent:message-id; bh=pNzwKna2IV7C9sf7z5wOi9HlFsHonMI5j46qqP//k7A=; b=FGRXB1xN6a/DQ9doCTLERNAkv9wt6Y2vmAkqzp/4QekBhw/ZwMkXwDaPUytborpZ+1 y8X0KQAhFNwPuh3R0CGzx8lIHt9eFnVN9VXJR7VTWOaqBSOfJJb45Mri1egddzk0r/zU ODwdbhprvMIcBfzSp1hBPifBDW51o76pKfON7sjR2r+Z43R9O8XhDvMEMgFWh4rujYF4 6JL9S9yTJWAIm+hZ/NH0bH3vIwqTh0qdAzAmUYdWTALyjx/g40i6f1cuG2VfJSE2AoEn rDVDLW/rc4LsNBYcU3YjEE1EnjmVugjnQETPPm9fT4lbSmaxZ6FsL0NlCOvDqPurdFjz 0G4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w11si3781068oic.62.2019.12.19.13.46.54; Thu, 19 Dec 2019 13:47:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727523AbfLSVqD (ORCPT + 99 others); Thu, 19 Dec 2019 16:46:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:35668 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727056AbfLSVqB (ORCPT ); Thu, 19 Dec 2019 16:46:01 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 822412467F; Thu, 19 Dec 2019 21:45:59 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.92.3) (envelope-from ) id 1ii3cM-000UlS-Kv; Thu, 19 Dec 2019 16:45:58 -0500 Message-Id: <20191219214558.510271353@goodmis.org> User-Agent: quilt/0.65 Date: Thu, 19 Dec 2019 16:44:52 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Kirill Tkhai , Kirill Tkhai , Peter Zijlstra , "mingo@redhat.com" , "juri.lelli@redhat.com" , "vincent.guittot@linaro.org" , "dietmar.eggemann@arm.com" , "bsegall@google.com" , "mgorman@suse.de" , Ingo Molnar , Andrew Morton Subject: [RFC][PATCH 1/4] sched: Force the address order of each sched class descriptor References: <20191219214451.340746474@goodmis.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Steven Rostedt (VMware)" In order to make a micro optimization in pick_next_task(), the order of the sched class descriptor address must be in the same order as their priority to each other. That is: &idle_sched_class < &fair_sched_class < &rt_sched_class < &dl_sched_class < &stop_sched_class In order to guarantee this order of the sched class descriptors, add each one into their own data section and force the order in the linker script. Link: https://lore.kernel.org/r/157675913272.349305.8936736338884044103.stgit@localhost.localdomain Signed-off-by: Steven Rostedt (VMware) --- include/asm-generic/vmlinux.lds.h | 19 +++++++++++++++++++ kernel/sched/deadline.c | 3 ++- kernel/sched/fair.c | 3 ++- kernel/sched/idle.c | 3 ++- kernel/sched/rt.c | 3 ++- kernel/sched/stop_task.c | 3 ++- 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index e00f41aa8ec4..772d961c69a5 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -108,6 +108,24 @@ #define SBSS_MAIN .sbss #endif +#ifdef CONFIG_SMP +#define STOP_SCHED_CLASS *(__stop_sched_class) +#else +#define STOP_SCHED_CLASS +#endif + +/* + * The order of the sched class addresses are important, as they are + * used to determine the order of the priority of each sched class in + * relation to each other. + */ +#define SCHED_DATA \ + *(__idle_sched_class) \ + *(__fair_sched_class) \ + *(__rt_sched_class) \ + *(__dl_sched_class) \ + STOP_SCHED_CLASS + /* * Align to a 32 byte boundary equal to the * alignment gcc 4.5 uses for a struct @@ -308,6 +326,7 @@ #define DATA_DATA \ *(.xiptext) \ *(DATA_MAIN) \ + SCHED_DATA \ *(.ref.data) \ *(.data..shared_aligned) /* percpu related */ \ MEM_KEEP(init.data*) \ diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 43323f875cb9..5abdbe569f93 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -2428,7 +2428,8 @@ static void prio_changed_dl(struct rq *rq, struct task_struct *p, } } -const struct sched_class dl_sched_class = { +const struct sched_class dl_sched_class + __attribute__((section("__dl_sched_class"))) = { .next = &rt_sched_class, .enqueue_task = enqueue_task_dl, .dequeue_task = dequeue_task_dl, diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 08a233e97a01..e745fe0e0cd3 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -10745,7 +10745,8 @@ static unsigned int get_rr_interval_fair(struct rq *rq, struct task_struct *task /* * All the scheduling class methods: */ -const struct sched_class fair_sched_class = { +const struct sched_class fair_sched_class + __attribute__((section("__fair_sched_class"))) = { .next = &idle_sched_class, .enqueue_task = enqueue_task_fair, .dequeue_task = dequeue_task_fair, diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index ffa959e91227..700a9c826f0e 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -454,7 +454,8 @@ static void update_curr_idle(struct rq *rq) /* * Simple, special scheduling class for the per-CPU idle tasks: */ -const struct sched_class idle_sched_class = { +const struct sched_class idle_sched_class + __attribute__((section("__idle_sched_class"))) = { /* .next is NULL */ /* no enqueue/yield_task for idle tasks */ diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index e591d40fd645..5d3f9bcddaeb 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -2354,7 +2354,8 @@ static unsigned int get_rr_interval_rt(struct rq *rq, struct task_struct *task) return 0; } -const struct sched_class rt_sched_class = { +const struct sched_class rt_sched_class + __attribute__((section("__rt_sched_class"))) = { .next = &fair_sched_class, .enqueue_task = enqueue_task_rt, .dequeue_task = dequeue_task_rt, diff --git a/kernel/sched/stop_task.c b/kernel/sched/stop_task.c index 4c9e9975684f..03bc7530ff75 100644 --- a/kernel/sched/stop_task.c +++ b/kernel/sched/stop_task.c @@ -115,7 +115,8 @@ static void update_curr_stop(struct rq *rq) /* * Simple, special scheduling class for the per-CPU stop tasks: */ -const struct sched_class stop_sched_class = { +const struct sched_class stop_sched_class + __attribute__((section("__stop_sched_class"))) = { .next = &dl_sched_class, .enqueue_task = enqueue_task_stop, -- 2.24.0