蘋果小豬研究室
  • 首頁
  • 中譯資料
  • 網路觀念
    • OSGi 平台
    • SCTP 通訊協定簡介
      • 1 多重串流 (Multi-streaming)
      • 2 路徑多宿 (Multi-homing)
      • 3 SACK 機制
      • 4 Path MTU Discovery
      • 5 Ordered/Unordered 傳送機制
      • 6. SCTP API
      • 7. TCP 與 SCTP 通訊協定比較
      • 8. 參考文獻
    • TCP over SCTP tunnel
    • TCP 與 SCTP 協定轉換機制
    • UPnP 與 UPnP AV
  • Linux 程式設計
    • [C] 產生亂數
    • [C] Pointer and array
    • [Script] strncmp
    • [C] Linux 取得 HD 序號
    • [C] 程式範例-切割 subnet
    • C struct 的使用
    • C 目錄相關
    • const 修飾詞
    • Dangling pointer(懸置指標)
    • dnsmole
    • dos2unix 程式碼
    • Function pointer in C
    • GCC header limits.h
    • GDB 參數
    • glibc detected (double free)
    • IEEE 754 and float 範例程式
    • kernel 中的網路卡名稱與命名順序關係
    • Linux 序列埠程式設計
    • loop device 的數目
    • Perl & LWP
    • Remote Control over CGI
    • 偵測 NAT 內部主機連線狀況
    • 利用 libpcap 取得所有的網路裝置名稱
    • 取得時間
    • strncpy
    • 從應用層程式取得傳輸層 TCP 資訊
    • 於 Linux 上撰寫 daemon server 要注意的
    • 為什麼需要 & 0377
    • 研究 setsid()
    • 與 HTTP 協定有關的 RFC
    • 製作 patch 檔
    • 設計在背景執行的 Linux 程式
    • 讀取 STDIN (Standard INPUT) 範例程式
    • 關於 Linux CPU smp_affinity
    • 陣列名稱與指標
  • 網路服務推薦
    • 專案管理工具 - clickup
    • 文件大師 - gitbook
  • glibc 中文手冊
    • GNU C 函式庫常見問題(FAQ)
  • Linux 系統操作
    • /proc/sys/net/ipv4/conf/eth* 目錄中的參數
    • Linux 伺服器效能調校
    • Linux 設定網卡速度
    • Proxy ARP
    • sysrq
    • Turn off beep in Linux system
    • umask()
    • 以 ethtool 查看網路卡狀態及設定
    • 使用 nameif 修改 Linux 網路卡名稱
    • 使用 xhost
    • 利用 sed 取出檔案中某行
    • 在 bash 中設定 Proxy server
    • 在 Linux 系統呈現 dd 的進度
    • 字串取代,使用 awk & sed
    • 尋找多種副檔名
    • 常用 VIM 選項
    • 自動 CPU 調頻節能控制
    • 自動執行程式
    • 設定 Debian 預設啟動服務
    • 設定 DHCPd server
    • 透過 RS-232 操作 Linux console
    • Linux connect to serial port
  • 資訊安全
    • ARP spoofing 技術管控區網流量實例
    • dsniff
    • Linux Socket Filtering
    • Linux 系統安全管理
    • Security 資訊
    • sniffer 相關工具 - IPgrad, tcpick
    • 以 Linux 實務 ARP Spoofing
    • 將文字隱藏於 JPEG 圖檔
    • 資安工具
    • 資安相關網站
    • 限制 localhost 的 P2P 上傳流量
  • 實用工具
    • 實驗基本數據製圖指令 gnuplot
  • 交換連結
  • 網頁設定
  • 網路應用
    • 網路時光機
  • Foldng@Home
  • 文獻推薦
    • 電子書
    • 提問的智慧
    • 好書
  • 隱私政策
Powered by GitBook
On this page
Edit on GitHub
  1. Linux 系統操作

自動 CPU 調頻節能控制

Ubuntu 10.04 以後的系統可以安裝 powernowd,(開機會自動執行 deamon)

週期的監控 CPU 使用率,可以設定上限值與下限,依據設定的 policy 自動調降/調升 CPU 頻率。

Ubuntu Linux 10.04 設定檔 ( /etc/default/powernowd )

man powernowd for details.

手動CPU 調頻控制

測試:

Lenovo Notebook X200, CPU (Pentium M) 支援四種頻率 ( 2401, 2400, 1600, 800 MHz)

CPU: Intel(R) Core(TM)2 Duo CPU P8600 @ 2.40GHz

OS: Ubuntu 10.04 TLS (Linux kernel: 2.6.32-26-generic SMP)

Script code:

#!/bin/bash

# Lenovo x200 support: 800 MHz, 1600 MHz, 2400 MHz and 2401 MHz
# 可參考 /sys/devices/system/cpu/cpu$cpu/cpufreq/scaling_available_frequencies

num=$#
if [ $num -lt 2 ]; then
        echo "$0 cpu_id cpu_freq"
        exit 1;
fi

cpu="$1"
cpufreq="$2""000"

echo "Set CPU$cpu with $2 MHz"

# 可參考 /sys/devices/system/cpu/cpu$cpu/cpufreq/scaling_available_governors

echo "userspace" > /sys/devices/system/cpu/cpu$cpu/cpufreq/scaling_governor

# 設定 CPU 頻率下限
echo "800000" > /sys/devices/system/cpu/cpu$cpu/cpufreq/scaling_min_freq

# 設定 CPU 頻率上限
echo "2401000" > /sys/devices/system/cpu/cpu$cpu/cpufreq/scaling_max_freq

# 設定 CPU 頻率
echo "$cpufreq" > /sys/devices/system/cpu/cpu$cpu/cpufreq/scaling_setspeed

# 確認設定
echo "cat /sys/devices/system/cpu/cpu$cpu/cpufreq/scaling_setspeed"
out=`cat /sys/devices/system/cpu/cpu$cpu/cpufreq/scaling_setspeed`
echo $out

cat /proc/cpuinfo |grep "cpu MHz"

exit 0;
使用方式:
1. 將上述 script 存為 set_cpu.sh 
2. 變更權限:chmod +x set_cpu.sh
3. ./set_cpu.sh cpu_id cpu_freq   ( 將 cpu_id 改成 /proc/cpuinfo 對應的 processor id, cpufreq 改成要設定的頻率, ex. ./set_cpu.sh 0 800 )

註:如果要手動調整頻率,需要移除下列自動調頻的工具
$ sudo apt-get remove powernowd cpudyn cpufreqd powersaved speedfreqd

 
一些資訊:
driver: acpi-cpufreq

/sys/devices/system/cpu/cpu0/cpufreq
/sys/devices/system/cpu/cpufreq/ondemand (decides the speed to use)

cpufreq-info 可以獲得 cpufreq stats (有統計每個頻率使用的百分比)

/proc/acpi 可以調整亮度, 查詢 battery 資訊

set ex. echo "70" > /proc/acpi/video/VID/LCD0/brightness

/proc/acpi/ac_adapter/AC  (可查詢是否插電)

/proc/acpi/ibm 可控制 ibm devices

2.6.26 (mp)

/sys/devices/system/cpu/cpu? 中,

設定開啟、關閉 CPU: online { 1, 0 }

/sys/devices/system/cpu/sched_smt_power_savings

   0 - No power saving load balance (default value)
   1 - Fill one thread/core/package first for long running threads
   2 - Also bias task wakeups to semi-idle cpu package for power savings

/sys/devices/system/cpu/kernel_max

   kernel_max: the maximum cpu index allowed by the kernel configuration.

   offline: cpus that are not online because they have been  HOTPLUGGED off
   or exceed the limit of cpus allowed by the kernel configuration
   (kernel_max above).


   online: cpus that are online and being scheduled.

   possible: cpus that have been allocated resources and can be
             brought online if they are present.

   present: cpus that have been identified as being present in the system.

需要更多資訊可直接查看 Reference 所列資料。

 
 
Reference: (我所查看的程式碼版本是 Linux kernel source 2.6.32, 2.6.36)

Documentation/cputopology.txt for more information.
Documentation/cpuidle/.
Documentation/ABI/testing/sysfs-devices-system-cpu.
http://www.pantz.org/software/cpufreq/usingcpufreqonlinux.html 

Previous常用 VIM 選項Next自動執行程式

Last updated 2 years ago