Re: Help: Using cpufreq from kernel level

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Dec 17, 2005 at 01:10:33PM -0500, Claudio Scordino wrote:
> Hi all,
> 
>    I'm writing a kernel module that needs to get info about the available 
> frequencies on the current processor and to periodically change the current 
> frequency.

So it seems you're writing a governor. See
Documentation/cpu-freq/governors.txt and
drivers/cpufreq/cpufreq_conservative.c
drivers/cpufreq/cpufreq_ondemand.c
drivers/cpufreq/cpufreq_performance.c
drivers/cpufreq/cpufreq_powersave.c
drivers/cpufreq/cpufreq_userspace.c

for a first reference.

> At user level it can be done through
> 
> /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
> /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
> /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
> 
> but I have no idea how to implement it at kernel level. 
> 
> I tried to declare
> 
> extern struct cpufreq_driver    *cpufreq_driver;
> extern struct cpufreq_policy    *cpufreq_cpu_data[NR_CPUS];
> extern spinlock_t cpufreq_driver_lock;
> extern ssize_t show_available_freqs (struct cpufreq_policy *policy, char 
> *buf);
> 
> and to do
> 
> char buffer [100000] = "\n";
> spin_lock_irqsave(&cpufreq_driver_lock, flags);
> show_available_freqs(cpufreq_cpu_data[0], buffer);
> spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
> 
> but it crashes the system.

of course it does, this is just the sysfs -show function and you're
passing it a null pointer as first parameter. If you look at
show_available_freqs code you'll see that cpufreq_cpu_data is
dereferenced and this happening with interrupts disabled..

hth
-- 
mattia
:wq!
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux