forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cpufreq: Move scheduler-related code to the sched directory
Create cpufreq.c under kernel/sched/ and move the cpufreq code related to the scheduler to that file and to sched.h. Redefine cpufreq_update_util() as a static inline function to avoid function calls at its call sites in the scheduler code (as suggested by Peter Zijlstra). Also move the definition of struct update_util_data and declaration of cpufreq_set_update_util_data() from include/linux/cpufreq.h to include/linux/sched.h. Signed-off-by: Rafael J. Wysocki <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]>
- Loading branch information
Showing
7 changed files
with
96 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Scheduler code and data structures related to cpufreq. | ||
* | ||
* Copyright (C) 2016, Intel Corporation | ||
* Author: Rafael J. Wysocki <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
*/ | ||
|
||
#include "sched.h" | ||
|
||
DEFINE_PER_CPU(struct update_util_data *, cpufreq_update_util_data); | ||
|
||
/** | ||
* cpufreq_set_update_util_data - Populate the CPU's update_util_data pointer. | ||
* @cpu: The CPU to set the pointer for. | ||
* @data: New pointer value. | ||
* | ||
* Set and publish the update_util_data pointer for the given CPU. That pointer | ||
* points to a struct update_util_data object containing a callback function | ||
* to call from cpufreq_update_util(). That function will be called from an RCU | ||
* read-side critical section, so it must not sleep. | ||
* | ||
* Callers must use RCU-sched callbacks to free any memory that might be | ||
* accessed via the old update_util_data pointer or invoke synchronize_sched() | ||
* right after this function to avoid use-after-free. | ||
*/ | ||
void cpufreq_set_update_util_data(int cpu, struct update_util_data *data) | ||
{ | ||
if (WARN_ON(data && !data->func)) | ||
return; | ||
|
||
rcu_assign_pointer(per_cpu(cpufreq_update_util_data, cpu), data); | ||
} | ||
EXPORT_SYMBOL_GPL(cpufreq_set_update_util_data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters