1 // SPDX-License-Identifier: GPL-2.0 1 2 /* 3 * Scheduler code and data structures related 4 * 5 * Copyright (C) 2016, Intel Corporation 6 * Author: Rafael J. Wysocki <rafael.j.wysocki 7 */ 8 9 DEFINE_PER_CPU(struct update_util_data __rcu * 10 11 /** 12 * cpufreq_add_update_util_hook - Populate the 13 * @cpu: The CPU to set the pointer for. 14 * @data: New pointer value. 15 * @func: Callback function to set for the CPU 16 * 17 * Set and publish the update_util_data pointe 18 * 19 * The update_util_data pointer of @cpu is set 20 * function pointer in the target struct updat 21 * That function will be called by cpufreq_upd 22 * read-side critical sections, so it must not 23 * passed to it as the first argument which al 24 * target update_util_data structure and its c 25 * 26 * The update_util_data pointer of @cpu must b 27 * called or it will WARN() and return with no 28 */ 29 void cpufreq_add_update_util_hook(int cpu, str 30 void (*func)(struct up 31 unsigned 32 { 33 if (WARN_ON(!data || !func)) 34 return; 35 36 if (WARN_ON(per_cpu(cpufreq_update_uti 37 return; 38 39 data->func = func; 40 rcu_assign_pointer(per_cpu(cpufreq_upd 41 } 42 EXPORT_SYMBOL_GPL(cpufreq_add_update_util_hook 43 44 /** 45 * cpufreq_remove_update_util_hook - Clear the 46 * @cpu: The CPU to clear the pointer for. 47 * 48 * Clear the update_util_data pointer for the 49 * 50 * Callers must use RCU callbacks to free any 51 * accessed via the old update_util_data point 52 * right after this function to avoid use-afte 53 */ 54 void cpufreq_remove_update_util_hook(int cpu) 55 { 56 rcu_assign_pointer(per_cpu(cpufreq_upd 57 } 58 EXPORT_SYMBOL_GPL(cpufreq_remove_update_util_h 59 60 /** 61 * cpufreq_this_cpu_can_update - Check if cpuf 62 * @policy: cpufreq policy to check. 63 * 64 * Return 'true' if: 65 * - the local and remote CPUs share @policy, 66 * - dvfs_possible_from_any_cpu is set in @pol 67 * offline (in which case it is not expected 68 */ 69 bool cpufreq_this_cpu_can_update(struct cpufre 70 { 71 return cpumask_test_cpu(smp_processor_ 72 (policy->dvfs_possible_from_an 73 rcu_dereference_sched(*this_c 74 } 75
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.