アーキテクチャをスマートに。

株式会社ネオジニア代表。ITアーキテクトとしてのお仕事や考えていることなどをたまに綴っています。(記事の内容は個人の見解に基づくものであり、所属組織を代表するものではありません)

ThinkPad T60 でも thinkdan でファン制御

thinkfan ネタの続き。

以前から使っている ThinkPad T60 にもThinkfan を導入したので、その時のメモ。


OSは Ubuntu 10.10。

まずはカーネルオプションを変更し、ファンを制御出来るようにする。
この手順は前回の記事を参照のこと。

次に apt で thinkfan を install する。

T60 ではこれだけで thinkfan がとりあえず使えるようになる。

なるけど、どうも watch sensors していると、温度が変化しても設定した通りにファンの回転数が変わらない。

なぜか?

調査

/etc/thinkfan.conf のデフォルトは

sensor /proc/acpi/ibm/thermal (0, 10, 15, 2, 10, 5, 0, 3, 0, 3)

となっており、
thinkfan が参照している温度センサーは、/proc/acpi/ibm/thermal であることがわかる。

これを cat してみると以下のような出力となっていた。

$ cat /proc/acpi/ibm/thermal 
temperatures:	53 39 39 69 -128 -128 -128 -128 37 45 47 -128 -128 -128 -128 -128

そして、sensors の結果が以下

$ sensors
acpitz-virtual-0
Adapter: Virtual device
temp1:       +53.0°C  (crit = +127.0°C)                  
temp2:       +55.0°C  (crit = +99.0°C)                  

coretemp-isa-0000
Adapter: ISA adapter
Core 0:      +55.0°C  (crit = +100.0°C)                  

coretemp-isa-0001
Adapter: ISA adapter
Core 1:      +54.0°C  (crit = +100.0°C)                  

thinkpad-isa-0000
Adapter: ISA adapter
fan1:          0 RPM
temp1:       +53.0°C                                    
temp2:       +39.0°C                                    
temp3:       +38.0°C                                    
temp4:       +69.0°C                                    
ERROR: Can't get value of subfeature temp5_input: Can't read
temp5:        +0.0°C                                    
ERROR: Can't get value of subfeature temp6_input: Can't read
temp6:        +0.0°C                                    
ERROR: Can't get value of subfeature temp7_input: Can't read
temp7:        +0.0°C                                    
ERROR: Can't get value of subfeature temp8_input: Can't read
temp8:        +0.0°C                                    
temp9:       +36.0°C                                    
temp10:      +45.0°C                                    
temp11:      +48.0°C                                    
ERROR: Can't get value of subfeature temp12_input: Can't read
temp12:       +0.0°C                                    
ERROR: Can't get value of subfeature temp13_input: Can't read
temp13:       +0.0°C                                    
ERROR: Can't get value of subfeature temp14_input: Can't read
temp14:       +0.0°C                                    
ERROR: Can't get value of subfeature temp15_input: Can't read
temp15:       +0.0°C                                    
ERROR: Can't get value of subfeature temp16_input: Can't read
temp16:       +0.0°C

これを見比べてみると察しがつくが、
/proc/acpi/ibm/thermal で見えているのは thinkpad-isa-0000 のセンサーのようである。-128 は temp5〜temp8 などの ERROR になっているところと対応している。
(それぞれの温度がなんのセンサーなのかまでは未調査。でもたぶんtemp1がCPU)

/etc/thinkfan.conf のコメントを読んだりしていると、カッコの数字は、温度センサーの補正値であるということなので、これが原因のようである。

原因

つまり、

sensor /proc/acpi/ibm/thermal (0, 10, 15, 2, 10, 5, 0, 3, 0, 3)

$ cat /proc/acpi/ibm/thermal 
temperatures:	53 39 39 69 -128 -128 -128 -128 37 45 47 -128 -128 -128 -128 -128

なので、thinkfan が判定に用いる温度は、

53 + 0 = 53
39 + 10 = 49
39 + 15 = 54
69 + 2 = 71
...

ということになり、この中からもっとも高い温度が採用される。

4つめのtemp4 が 71 で、どう考えても高すぎる。CPU温度に従って制御したいのに、違う温度が優先して参照されていた、というわけだ。

ということで

補正値を調整し、以下のようにした。

#sensor /proc/acpi/ibm/thermal (0, 10, 15, 2, 10, 5, 0, 3, 0, 3)
sensor /proc/acpi/ibm/thermal (0,13,15,-16)

先程のセンサーの読みで計算してみると

53 + 0 = 53
39 + 13 = 52
39 + 15 = 54
69 - 16 = 53
...

となり、大体温度が同じになる。

実際にこの設定で実験してみると、たしかに計算どおりの温度でファンの回転数が変わっていた。

実際の運用設定

以下に T60 で実際に運用している設定を晒します。

/etc/thinkfan.conf

#sensor /proc/acpi/ibm/thermal (0, 10, 15, 2, 10, 5, 0, 3, 0, 3)
sensor /proc/acpi/ibm/thermal (0,13,15,-16)

(0,     0,      60)
(1,     55,     65)
(3,     61,     69)
(5,     66,     74)
(7,     70,     32767)

余談

ところで、そもそもCPUファンの制御なのだから、temp1 だけを見ればよいのかも知れない。
つまり、

sensor /proc/acpi/ibm/thermal (0)

としてしまう方が、よくわかっていない温度センサーを補正値を変更して参照させるより、よっぽど素直な方法だという考え方もありますね。。。

みなさんもいろいろ試してみて下さい。(ただし自己責任でね)