~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/kernel/sched/cpufreq.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /kernel/sched/cpufreq.c (Architecture sparc) and /kernel/sched/cpufreq.c (Architecture alpha)


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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php