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

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

Version: ~ [ linux-4.18-rc1 ] ~ [ linux-4.17.2 ] ~ [ linux-4.16.16 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.50 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.109 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.138 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.113 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.57 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.27.62 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Scheduler code and data structures related to cpufreq.
  3  *
  4  * Copyright (C) 2016, Intel Corporation
  5  * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  6  *
  7  * This program is free software; you can redistribute it and/or modify
  8  * it under the terms of the GNU General Public License version 2 as
  9  * published by the Free Software Foundation.
 10  */
 11 #include "sched.h"
 12 
 13 DEFINE_PER_CPU(struct update_util_data *, cpufreq_update_util_data);
 14 
 15 /**
 16  * cpufreq_add_update_util_hook - Populate the CPU's update_util_data pointer.
 17  * @cpu: The CPU to set the pointer for.
 18  * @data: New pointer value.
 19  * @func: Callback function to set for the CPU.
 20  *
 21  * Set and publish the update_util_data pointer for the given CPU.
 22  *
 23  * The update_util_data pointer of @cpu is set to @data and the callback
 24  * function pointer in the target struct update_util_data is set to @func.
 25  * That function will be called by cpufreq_update_util() from RCU-sched
 26  * read-side critical sections, so it must not sleep.  @data will always be
 27  * passed to it as the first argument which allows the function to get to the
 28  * target update_util_data structure and its container.
 29  *
 30  * The update_util_data pointer of @cpu must be NULL when this function is
 31  * called or it will WARN() and return with no effect.
 32  */
 33 void cpufreq_add_update_util_hook(int cpu, struct update_util_data *data,
 34                         void (*func)(struct update_util_data *data, u64 time,
 35                                      unsigned int flags))
 36 {
 37         if (WARN_ON(!data || !func))
 38                 return;
 39 
 40         if (WARN_ON(per_cpu(cpufreq_update_util_data, cpu)))
 41                 return;
 42 
 43         data->func = func;
 44         rcu_assign_pointer(per_cpu(cpufreq_update_util_data, cpu), data);
 45 }
 46 EXPORT_SYMBOL_GPL(cpufreq_add_update_util_hook);
 47 
 48 /**
 49  * cpufreq_remove_update_util_hook - Clear the CPU's update_util_data pointer.
 50  * @cpu: The CPU to clear the pointer for.
 51  *
 52  * Clear the update_util_data pointer for the given CPU.
 53  *
 54  * Callers must use RCU-sched callbacks to free any memory that might be
 55  * accessed via the old update_util_data pointer or invoke synchronize_sched()
 56  * right after this function to avoid use-after-free.
 57  */
 58 void cpufreq_remove_update_util_hook(int cpu)
 59 {
 60         rcu_assign_pointer(per_cpu(cpufreq_update_util_data, cpu), NULL);
 61 }
 62 EXPORT_SYMBOL_GPL(cpufreq_remove_update_util_hook);
 63 

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

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | 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.

osdn.jp