2019-06-01 11:08:55 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2013-11-07 17:43:47 +04:00
|
|
|
/*
|
2021-06-21 09:50:48 +03:00
|
|
|
* kernel/sched/cpudeadline.c
|
2013-11-07 17:43:47 +04:00
|
|
|
*
|
|
|
|
* Global CPU deadline management
|
|
|
|
*
|
|
|
|
* Author: Juri Lelli <j.lelli@sssup.it>
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline int parent(int i)
|
|
|
|
{
|
|
|
|
return (i - 1) >> 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int left_child(int i)
|
|
|
|
{
|
|
|
|
return (i << 1) + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int right_child(int i)
|
|
|
|
{
|
|
|
|
return (i << 1) + 2;
|
|
|
|
}
|
|
|
|
|
2016-08-14 17:27:06 +03:00
|
|
|
static void cpudl_heapify_down(struct cpudl *cp, int idx)
|
2013-11-07 17:43:47 +04:00
|
|
|
{
|
|
|
|
int l, r, largest;
|
|
|
|
|
2016-08-14 17:27:07 +03:00
|
|
|
int orig_cpu = cp->elements[idx].cpu;
|
|
|
|
u64 orig_dl = cp->elements[idx].dl;
|
|
|
|
|
|
|
|
if (left_child(idx) >= cp->size)
|
|
|
|
return;
|
|
|
|
|
2013-11-07 17:43:47 +04:00
|
|
|
/* adapted from lib/prio_heap.c */
|
2018-03-02 21:20:07 +03:00
|
|
|
while (1) {
|
2016-08-14 17:27:07 +03:00
|
|
|
u64 largest_dl;
|
2018-03-02 21:20:07 +03:00
|
|
|
|
2013-11-07 17:43:47 +04:00
|
|
|
l = left_child(idx);
|
|
|
|
r = right_child(idx);
|
|
|
|
largest = idx;
|
2016-08-14 17:27:07 +03:00
|
|
|
largest_dl = orig_dl;
|
2013-11-07 17:43:47 +04:00
|
|
|
|
2016-08-14 17:27:07 +03:00
|
|
|
if ((l < cp->size) && dl_time_before(orig_dl,
|
|
|
|
cp->elements[l].dl)) {
|
2013-11-07 17:43:47 +04:00
|
|
|
largest = l;
|
2016-08-14 17:27:07 +03:00
|
|
|
largest_dl = cp->elements[l].dl;
|
|
|
|
}
|
|
|
|
if ((r < cp->size) && dl_time_before(largest_dl,
|
|
|
|
cp->elements[r].dl))
|
2013-11-07 17:43:47 +04:00
|
|
|
largest = r;
|
2016-08-14 17:27:07 +03:00
|
|
|
|
2013-11-07 17:43:47 +04:00
|
|
|
if (largest == idx)
|
|
|
|
break;
|
|
|
|
|
2016-08-14 17:27:07 +03:00
|
|
|
/* pull largest child onto idx */
|
|
|
|
cp->elements[idx].cpu = cp->elements[largest].cpu;
|
|
|
|
cp->elements[idx].dl = cp->elements[largest].dl;
|
|
|
|
cp->elements[cp->elements[idx].cpu].idx = idx;
|
2013-11-07 17:43:47 +04:00
|
|
|
idx = largest;
|
|
|
|
}
|
2016-08-14 17:27:07 +03:00
|
|
|
/* actual push down of saved original values orig_* */
|
|
|
|
cp->elements[idx].cpu = orig_cpu;
|
|
|
|
cp->elements[idx].dl = orig_dl;
|
|
|
|
cp->elements[cp->elements[idx].cpu].idx = idx;
|
2013-11-07 17:43:47 +04:00
|
|
|
}
|
|
|
|
|
2016-08-14 17:27:06 +03:00
|
|
|
static void cpudl_heapify_up(struct cpudl *cp, int idx)
|
2013-11-07 17:43:47 +04:00
|
|
|
{
|
2016-08-14 17:27:07 +03:00
|
|
|
int p;
|
|
|
|
|
|
|
|
int orig_cpu = cp->elements[idx].cpu;
|
|
|
|
u64 orig_dl = cp->elements[idx].dl;
|
|
|
|
|
|
|
|
if (idx == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
do {
|
|
|
|
p = parent(idx);
|
|
|
|
if (dl_time_before(orig_dl, cp->elements[p].dl))
|
|
|
|
break;
|
|
|
|
/* pull parent onto idx */
|
|
|
|
cp->elements[idx].cpu = cp->elements[p].cpu;
|
|
|
|
cp->elements[idx].dl = cp->elements[p].dl;
|
|
|
|
cp->elements[cp->elements[idx].cpu].idx = idx;
|
|
|
|
idx = p;
|
|
|
|
} while (idx != 0);
|
|
|
|
/* actual push up of saved original values orig_* */
|
|
|
|
cp->elements[idx].cpu = orig_cpu;
|
|
|
|
cp->elements[idx].dl = orig_dl;
|
|
|
|
cp->elements[cp->elements[idx].cpu].idx = idx;
|
2013-11-07 17:43:47 +04:00
|
|
|
}
|
|
|
|
|
2016-08-14 17:27:06 +03:00
|
|
|
static void cpudl_heapify(struct cpudl *cp, int idx)
|
|
|
|
{
|
|
|
|
if (idx > 0 && dl_time_before(cp->elements[parent(idx)].dl,
|
|
|
|
cp->elements[idx].dl))
|
|
|
|
cpudl_heapify_up(cp, idx);
|
|
|
|
else
|
|
|
|
cpudl_heapify_down(cp, idx);
|
|
|
|
}
|
|
|
|
|
2013-11-07 17:43:47 +04:00
|
|
|
static inline int cpudl_maximum(struct cpudl *cp)
|
|
|
|
{
|
|
|
|
return cp->elements[0].cpu;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* cpudl_find - find the best (later-dl) CPU in the system
|
|
|
|
* @cp: the cpudl max-heap context
|
|
|
|
* @p: the task
|
|
|
|
* @later_mask: a mask to fill in with the selected CPUs (or NULL)
|
|
|
|
*
|
2017-05-23 05:00:57 +03:00
|
|
|
* Returns: int - CPUs were found
|
2013-11-07 17:43:47 +04:00
|
|
|
*/
|
|
|
|
int cpudl_find(struct cpudl *cp, struct task_struct *p,
|
|
|
|
struct cpumask *later_mask)
|
|
|
|
{
|
|
|
|
const struct sched_dl_entity *dl_se = &p->dl;
|
|
|
|
|
2015-01-19 07:49:36 +03:00
|
|
|
if (later_mask &&
|
2020-10-01 17:05:39 +03:00
|
|
|
cpumask_and(later_mask, cp->free_cpus, &p->cpus_mask)) {
|
2020-05-20 16:42:43 +03:00
|
|
|
unsigned long cap, max_cap = 0;
|
|
|
|
int cpu, max_cpu = -1;
|
2020-05-20 16:42:42 +03:00
|
|
|
|
2022-07-29 14:13:03 +03:00
|
|
|
if (!sched_asym_cpucap_active())
|
2020-05-20 16:42:42 +03:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
/* Ensure the capacity of the CPUs fits the task. */
|
|
|
|
for_each_cpu(cpu, later_mask) {
|
2020-05-20 16:42:43 +03:00
|
|
|
if (!dl_task_fits_capacity(p, cpu)) {
|
2020-05-20 16:42:42 +03:00
|
|
|
cpumask_clear_cpu(cpu, later_mask);
|
2020-05-20 16:42:43 +03:00
|
|
|
|
|
|
|
cap = capacity_orig_of(cpu);
|
|
|
|
|
|
|
|
if (cap > max_cap ||
|
|
|
|
(cpu == task_cpu(p) && cap == max_cap)) {
|
|
|
|
max_cap = cap;
|
|
|
|
max_cpu = cpu;
|
|
|
|
}
|
|
|
|
}
|
2020-05-20 16:42:42 +03:00
|
|
|
}
|
|
|
|
|
2020-05-20 16:42:43 +03:00
|
|
|
if (cpumask_empty(later_mask))
|
|
|
|
cpumask_set_cpu(max_cpu, later_mask);
|
|
|
|
|
|
|
|
return 1;
|
2017-05-23 05:00:57 +03:00
|
|
|
} else {
|
|
|
|
int best_cpu = cpudl_maximum(cp);
|
2018-03-02 21:20:07 +03:00
|
|
|
|
2017-05-23 05:00:57 +03:00
|
|
|
WARN_ON(best_cpu != -1 && !cpu_present(best_cpu));
|
2013-11-07 17:43:47 +04:00
|
|
|
|
2020-10-01 17:05:39 +03:00
|
|
|
if (cpumask_test_cpu(best_cpu, &p->cpus_mask) &&
|
2017-05-23 05:00:57 +03:00
|
|
|
dl_time_before(dl_se->deadline, cp->elements[0].dl)) {
|
|
|
|
if (later_mask)
|
|
|
|
cpumask_set_cpu(best_cpu, later_mask);
|
2013-11-07 17:43:47 +04:00
|
|
|
|
2017-05-23 05:00:57 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2013-11-07 17:43:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
sched: Clean up and harmonize the coding style of the scheduler code base
A good number of small style inconsistencies have accumulated
in the scheduler core, so do a pass over them to harmonize
all these details:
- fix speling in comments,
- use curly braces for multi-line statements,
- remove unnecessary parentheses from integer literals,
- capitalize consistently,
- remove stray newlines,
- add comments where necessary,
- remove invalid/unnecessary comments,
- align structure definitions and other data types vertically,
- add missing newlines for increased readability,
- fix vertical tabulation where it's misaligned,
- harmonize preprocessor conditional block labeling
and vertical alignment,
- remove line-breaks where they uglify the code,
- add newline after local variable definitions,
No change in functionality:
md5:
1191fa0a890cfa8132156d2959d7e9e2 built-in.o.before.asm
1191fa0a890cfa8132156d2959d7e9e2 built-in.o.after.asm
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2018-03-03 16:01:12 +03:00
|
|
|
* cpudl_clear - remove a CPU from the cpudl max-heap
|
2013-11-07 17:43:47 +04:00
|
|
|
* @cp: the cpudl max-heap context
|
sched: Clean up and harmonize the coding style of the scheduler code base
A good number of small style inconsistencies have accumulated
in the scheduler core, so do a pass over them to harmonize
all these details:
- fix speling in comments,
- use curly braces for multi-line statements,
- remove unnecessary parentheses from integer literals,
- capitalize consistently,
- remove stray newlines,
- add comments where necessary,
- remove invalid/unnecessary comments,
- align structure definitions and other data types vertically,
- add missing newlines for increased readability,
- fix vertical tabulation where it's misaligned,
- harmonize preprocessor conditional block labeling
and vertical alignment,
- remove line-breaks where they uglify the code,
- add newline after local variable definitions,
No change in functionality:
md5:
1191fa0a890cfa8132156d2959d7e9e2 built-in.o.before.asm
1191fa0a890cfa8132156d2959d7e9e2 built-in.o.after.asm
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2018-03-03 16:01:12 +03:00
|
|
|
* @cpu: the target CPU
|
2013-11-07 17:43:47 +04:00
|
|
|
*
|
|
|
|
* Notes: assumes cpu_rq(cpu)->lock is locked
|
|
|
|
*
|
|
|
|
* Returns: (void)
|
|
|
|
*/
|
sched/deadline: Split cpudl_set() into cpudl_set() and cpudl_clear()
These 2 exercise independent code paths and need different arguments.
After this change, you call:
cpudl_clear(cp, cpu);
cpudl_set(cp, cpu, dl);
instead of:
cpudl_set(cp, cpu, 0 /* dl */, 0 /* is_valid */);
cpudl_set(cp, cpu, dl, 1 /* is_valid */);
Signed-off-by: Tommaso Cucinotta <tommaso.cucinotta@sssup.it>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Luca Abeni <luca.abeni@unitn.it>
Reviewed-by: Juri Lelli <juri.lelli@arm.com>
Cc: Juri Lelli <juri.lelli@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-dl@retis.sssup.it
Link: http://lkml.kernel.org/r/1471184828-12644-4-git-send-email-tommaso.cucinotta@sssup.it
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-08-14 17:27:08 +03:00
|
|
|
void cpudl_clear(struct cpudl *cp, int cpu)
|
2013-11-07 17:43:47 +04:00
|
|
|
{
|
|
|
|
int old_idx, new_cpu;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2014-02-17 18:12:33 +04:00
|
|
|
WARN_ON(!cpu_present(cpu));
|
2013-11-07 17:43:47 +04:00
|
|
|
|
|
|
|
raw_spin_lock_irqsave(&cp->lock, flags);
|
sched/deadline: Split cpudl_set() into cpudl_set() and cpudl_clear()
These 2 exercise independent code paths and need different arguments.
After this change, you call:
cpudl_clear(cp, cpu);
cpudl_set(cp, cpu, dl);
instead of:
cpudl_set(cp, cpu, 0 /* dl */, 0 /* is_valid */);
cpudl_set(cp, cpu, dl, 1 /* is_valid */);
Signed-off-by: Tommaso Cucinotta <tommaso.cucinotta@sssup.it>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Luca Abeni <luca.abeni@unitn.it>
Reviewed-by: Juri Lelli <juri.lelli@arm.com>
Cc: Juri Lelli <juri.lelli@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-dl@retis.sssup.it
Link: http://lkml.kernel.org/r/1471184828-12644-4-git-send-email-tommaso.cucinotta@sssup.it
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-08-14 17:27:08 +03:00
|
|
|
|
2014-05-14 18:13:56 +04:00
|
|
|
old_idx = cp->elements[cpu].idx;
|
sched/deadline: Split cpudl_set() into cpudl_set() and cpudl_clear()
These 2 exercise independent code paths and need different arguments.
After this change, you call:
cpudl_clear(cp, cpu);
cpudl_set(cp, cpu, dl);
instead of:
cpudl_set(cp, cpu, 0 /* dl */, 0 /* is_valid */);
cpudl_set(cp, cpu, dl, 1 /* is_valid */);
Signed-off-by: Tommaso Cucinotta <tommaso.cucinotta@sssup.it>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Luca Abeni <luca.abeni@unitn.it>
Reviewed-by: Juri Lelli <juri.lelli@arm.com>
Cc: Juri Lelli <juri.lelli@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-dl@retis.sssup.it
Link: http://lkml.kernel.org/r/1471184828-12644-4-git-send-email-tommaso.cucinotta@sssup.it
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-08-14 17:27:08 +03:00
|
|
|
if (old_idx == IDX_INVALID) {
|
|
|
|
/*
|
|
|
|
* Nothing to remove if old_idx was invalid.
|
|
|
|
* This could happen if a rq_offline_dl is
|
|
|
|
* called for a CPU without -dl tasks running.
|
|
|
|
*/
|
|
|
|
} else {
|
2013-11-07 17:43:47 +04:00
|
|
|
new_cpu = cp->elements[cp->size - 1].cpu;
|
|
|
|
cp->elements[old_idx].dl = cp->elements[cp->size - 1].dl;
|
|
|
|
cp->elements[old_idx].cpu = new_cpu;
|
|
|
|
cp->size--;
|
2014-05-14 18:13:56 +04:00
|
|
|
cp->elements[new_cpu].idx = old_idx;
|
|
|
|
cp->elements[cpu].idx = IDX_INVALID;
|
2016-08-14 17:27:06 +03:00
|
|
|
cpudl_heapify(cp, old_idx);
|
2013-11-07 17:43:47 +04:00
|
|
|
|
sched/deadline: Split cpudl_set() into cpudl_set() and cpudl_clear()
These 2 exercise independent code paths and need different arguments.
After this change, you call:
cpudl_clear(cp, cpu);
cpudl_set(cp, cpu, dl);
instead of:
cpudl_set(cp, cpu, 0 /* dl */, 0 /* is_valid */);
cpudl_set(cp, cpu, dl, 1 /* is_valid */);
Signed-off-by: Tommaso Cucinotta <tommaso.cucinotta@sssup.it>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Luca Abeni <luca.abeni@unitn.it>
Reviewed-by: Juri Lelli <juri.lelli@arm.com>
Cc: Juri Lelli <juri.lelli@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-dl@retis.sssup.it
Link: http://lkml.kernel.org/r/1471184828-12644-4-git-send-email-tommaso.cucinotta@sssup.it
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-08-14 17:27:08 +03:00
|
|
|
cpumask_set_cpu(cpu, cp->free_cpus);
|
2013-11-07 17:43:47 +04:00
|
|
|
}
|
sched/deadline: Split cpudl_set() into cpudl_set() and cpudl_clear()
These 2 exercise independent code paths and need different arguments.
After this change, you call:
cpudl_clear(cp, cpu);
cpudl_set(cp, cpu, dl);
instead of:
cpudl_set(cp, cpu, 0 /* dl */, 0 /* is_valid */);
cpudl_set(cp, cpu, dl, 1 /* is_valid */);
Signed-off-by: Tommaso Cucinotta <tommaso.cucinotta@sssup.it>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Luca Abeni <luca.abeni@unitn.it>
Reviewed-by: Juri Lelli <juri.lelli@arm.com>
Cc: Juri Lelli <juri.lelli@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-dl@retis.sssup.it
Link: http://lkml.kernel.org/r/1471184828-12644-4-git-send-email-tommaso.cucinotta@sssup.it
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-08-14 17:27:08 +03:00
|
|
|
raw_spin_unlock_irqrestore(&cp->lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* cpudl_set - update the cpudl max-heap
|
|
|
|
* @cp: the cpudl max-heap context
|
sched: Clean up and harmonize the coding style of the scheduler code base
A good number of small style inconsistencies have accumulated
in the scheduler core, so do a pass over them to harmonize
all these details:
- fix speling in comments,
- use curly braces for multi-line statements,
- remove unnecessary parentheses from integer literals,
- capitalize consistently,
- remove stray newlines,
- add comments where necessary,
- remove invalid/unnecessary comments,
- align structure definitions and other data types vertically,
- add missing newlines for increased readability,
- fix vertical tabulation where it's misaligned,
- harmonize preprocessor conditional block labeling
and vertical alignment,
- remove line-breaks where they uglify the code,
- add newline after local variable definitions,
No change in functionality:
md5:
1191fa0a890cfa8132156d2959d7e9e2 built-in.o.before.asm
1191fa0a890cfa8132156d2959d7e9e2 built-in.o.after.asm
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2018-03-03 16:01:12 +03:00
|
|
|
* @cpu: the target CPU
|
|
|
|
* @dl: the new earliest deadline for this CPU
|
sched/deadline: Split cpudl_set() into cpudl_set() and cpudl_clear()
These 2 exercise independent code paths and need different arguments.
After this change, you call:
cpudl_clear(cp, cpu);
cpudl_set(cp, cpu, dl);
instead of:
cpudl_set(cp, cpu, 0 /* dl */, 0 /* is_valid */);
cpudl_set(cp, cpu, dl, 1 /* is_valid */);
Signed-off-by: Tommaso Cucinotta <tommaso.cucinotta@sssup.it>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Luca Abeni <luca.abeni@unitn.it>
Reviewed-by: Juri Lelli <juri.lelli@arm.com>
Cc: Juri Lelli <juri.lelli@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-dl@retis.sssup.it
Link: http://lkml.kernel.org/r/1471184828-12644-4-git-send-email-tommaso.cucinotta@sssup.it
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-08-14 17:27:08 +03:00
|
|
|
*
|
|
|
|
* Notes: assumes cpu_rq(cpu)->lock is locked
|
|
|
|
*
|
|
|
|
* Returns: (void)
|
|
|
|
*/
|
|
|
|
void cpudl_set(struct cpudl *cp, int cpu, u64 dl)
|
|
|
|
{
|
|
|
|
int old_idx;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
WARN_ON(!cpu_present(cpu));
|
2013-11-07 17:43:47 +04:00
|
|
|
|
sched/deadline: Split cpudl_set() into cpudl_set() and cpudl_clear()
These 2 exercise independent code paths and need different arguments.
After this change, you call:
cpudl_clear(cp, cpu);
cpudl_set(cp, cpu, dl);
instead of:
cpudl_set(cp, cpu, 0 /* dl */, 0 /* is_valid */);
cpudl_set(cp, cpu, dl, 1 /* is_valid */);
Signed-off-by: Tommaso Cucinotta <tommaso.cucinotta@sssup.it>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Luca Abeni <luca.abeni@unitn.it>
Reviewed-by: Juri Lelli <juri.lelli@arm.com>
Cc: Juri Lelli <juri.lelli@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-dl@retis.sssup.it
Link: http://lkml.kernel.org/r/1471184828-12644-4-git-send-email-tommaso.cucinotta@sssup.it
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-08-14 17:27:08 +03:00
|
|
|
raw_spin_lock_irqsave(&cp->lock, flags);
|
|
|
|
|
|
|
|
old_idx = cp->elements[cpu].idx;
|
2013-11-07 17:43:47 +04:00
|
|
|
if (old_idx == IDX_INVALID) {
|
2016-08-14 17:27:06 +03:00
|
|
|
int new_idx = cp->size++;
|
2018-03-02 21:20:07 +03:00
|
|
|
|
2016-08-14 17:27:06 +03:00
|
|
|
cp->elements[new_idx].dl = dl;
|
|
|
|
cp->elements[new_idx].cpu = cpu;
|
|
|
|
cp->elements[cpu].idx = new_idx;
|
|
|
|
cpudl_heapify_up(cp, new_idx);
|
2013-11-07 17:43:47 +04:00
|
|
|
cpumask_clear_cpu(cpu, cp->free_cpus);
|
|
|
|
} else {
|
2016-08-14 17:27:06 +03:00
|
|
|
cp->elements[old_idx].dl = dl;
|
|
|
|
cpudl_heapify(cp, old_idx);
|
2013-11-07 17:43:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
raw_spin_unlock_irqrestore(&cp->lock, flags);
|
|
|
|
}
|
|
|
|
|
2015-01-19 07:49:36 +03:00
|
|
|
/*
|
|
|
|
* cpudl_set_freecpu - Set the cpudl.free_cpus
|
|
|
|
* @cp: the cpudl max-heap context
|
sched: Clean up and harmonize the coding style of the scheduler code base
A good number of small style inconsistencies have accumulated
in the scheduler core, so do a pass over them to harmonize
all these details:
- fix speling in comments,
- use curly braces for multi-line statements,
- remove unnecessary parentheses from integer literals,
- capitalize consistently,
- remove stray newlines,
- add comments where necessary,
- remove invalid/unnecessary comments,
- align structure definitions and other data types vertically,
- add missing newlines for increased readability,
- fix vertical tabulation where it's misaligned,
- harmonize preprocessor conditional block labeling
and vertical alignment,
- remove line-breaks where they uglify the code,
- add newline after local variable definitions,
No change in functionality:
md5:
1191fa0a890cfa8132156d2959d7e9e2 built-in.o.before.asm
1191fa0a890cfa8132156d2959d7e9e2 built-in.o.after.asm
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2018-03-03 16:01:12 +03:00
|
|
|
* @cpu: rd attached CPU
|
2015-01-19 07:49:36 +03:00
|
|
|
*/
|
|
|
|
void cpudl_set_freecpu(struct cpudl *cp, int cpu)
|
|
|
|
{
|
|
|
|
cpumask_set_cpu(cpu, cp->free_cpus);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* cpudl_clear_freecpu - Clear the cpudl.free_cpus
|
|
|
|
* @cp: the cpudl max-heap context
|
sched: Clean up and harmonize the coding style of the scheduler code base
A good number of small style inconsistencies have accumulated
in the scheduler core, so do a pass over them to harmonize
all these details:
- fix speling in comments,
- use curly braces for multi-line statements,
- remove unnecessary parentheses from integer literals,
- capitalize consistently,
- remove stray newlines,
- add comments where necessary,
- remove invalid/unnecessary comments,
- align structure definitions and other data types vertically,
- add missing newlines for increased readability,
- fix vertical tabulation where it's misaligned,
- harmonize preprocessor conditional block labeling
and vertical alignment,
- remove line-breaks where they uglify the code,
- add newline after local variable definitions,
No change in functionality:
md5:
1191fa0a890cfa8132156d2959d7e9e2 built-in.o.before.asm
1191fa0a890cfa8132156d2959d7e9e2 built-in.o.after.asm
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2018-03-03 16:01:12 +03:00
|
|
|
* @cpu: rd attached CPU
|
2015-01-19 07:49:36 +03:00
|
|
|
*/
|
|
|
|
void cpudl_clear_freecpu(struct cpudl *cp, int cpu)
|
|
|
|
{
|
|
|
|
cpumask_clear_cpu(cpu, cp->free_cpus);
|
|
|
|
}
|
|
|
|
|
2013-11-07 17:43:47 +04:00
|
|
|
/*
|
|
|
|
* cpudl_init - initialize the cpudl structure
|
|
|
|
* @cp: the cpudl max-heap context
|
|
|
|
*/
|
|
|
|
int cpudl_init(struct cpudl *cp)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
raw_spin_lock_init(&cp->lock);
|
|
|
|
cp->size = 0;
|
2014-05-14 18:13:56 +04:00
|
|
|
|
|
|
|
cp->elements = kcalloc(nr_cpu_ids,
|
|
|
|
sizeof(struct cpudl_item),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!cp->elements)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2015-01-19 07:49:36 +03:00
|
|
|
if (!zalloc_cpumask_var(&cp->free_cpus, GFP_KERNEL)) {
|
2014-05-14 18:13:56 +04:00
|
|
|
kfree(cp->elements);
|
2013-11-07 17:43:47 +04:00
|
|
|
return -ENOMEM;
|
2014-05-14 18:13:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
for_each_possible_cpu(i)
|
|
|
|
cp->elements[i].idx = IDX_INVALID;
|
|
|
|
|
2013-11-07 17:43:47 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* cpudl_cleanup - clean up the cpudl structure
|
|
|
|
* @cp: the cpudl max-heap context
|
|
|
|
*/
|
|
|
|
void cpudl_cleanup(struct cpudl *cp)
|
|
|
|
{
|
2014-04-17 06:05:02 +04:00
|
|
|
free_cpumask_var(cp->free_cpus);
|
2014-05-14 18:13:56 +04:00
|
|
|
kfree(cp->elements);
|
2013-11-07 17:43:47 +04:00
|
|
|
}
|