Code Monkey home page Code Monkey logo

zcfan's Introduction

zcfan | Tests

Zero-configuration fan control daemon for ThinkPads.

Features

  • Extremely small (~250 lines), simple, and easy to understand code
  • Sensible out of the box, configuration is optional (see "usage" below)
  • Strong focus on stopping the fan as soon as safe to do so, without inducing throttling
  • Automatic temperature- and time-based hysteresis: no bouncing between fan levels
  • Watchdog support
  • Minimal resource usage
  • No dependencies

Usage

zcfan has the following default fan states:

Config name thinkpad_acpi fan level Default trip temperature (C)
max_temp full-speed (or 7 if unsupported) 90
med_temp 4 80
low_temp 1 70

If no trip temperature is reached, the fan will be turned off.

The fan will also only be reduced once the temperature is now at least 10C below the trip temperature for the current fan state. This can be tuned with the config parameter temp_hysteresis.

To override these defaults, you can place a file at /etc/zcfan.conf with updated trip temperatures in degrees celsius. As an example:

max_temp 85
med_temp 70
low_temp 55
temp_hysteresis 20

Hysteresis

We will only reduce the fan level again once:

  1. The temperature is now at least temp_hysteresis Celsius (default 10C) below the trip point, and
  2. At least 3 seconds have elapsed since the initial trip.

This avoids unnecessary fluctuations in fan speed.

Comparison with thinkfan

I wrote zcfan because I found thinkfan's configuration and code complexity too much for my tastes. Use whichever suits your needs.

Compilation

Run make.

Installation

  1. Compile zcfan or install from the AUR package
  2. Load your thinkpad_acpi module with fan_control=1
    • At runtime: rmmod thinkpad_acpi && modprobe thinkpad_acpi fan_control=1
    • By default: echo options thinkpad_acpi fan_control=1 > /etc/modprobe.d/99-fancontrol.conf
  3. Run zcfan as root (or use the zcfan systemd service provided)

Disclaimer

While the author uses this on their own machine, obviously there is no warranty whatsoever.

zcfan's People

Contributors

cdown avatar errge avatar michel-slm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

zcfan's Issues

zcfan causes freeze on ThinkPad T16 Gen 1 AMD

Hi!

I know it shouldn't happen at all, not sure if it's directly related to zcfan but thinkpad_acpi.

Anyhow, it manages to crash my system when I enable zcfan.

Sometimes it just happens at the first boot, sometimes happens 4h after using it.

Not sure if laptop it's too much new and it doesn't have a good support as other ThinkPads do.

This works more as a warning for those users loosing their minds on why their systems keep freezing than a real issue.

excess journal messages: Invalid argument (did you enable fan_control=1?)

I'm getting this line about once per second:

Apr 07 10:59:10 fovo.local zcfan[14186]: /proc/acpi/ibm/fan: write: Invalid argument (did you enable fan_control=1?)

I have not done "Load your thinkpad_acpi module with fan_control=1".

Also if the thinkpad_acpi module isn't loaded at all I also get this message about once per second:

Apr 07 11:04:48 fovo.local zcfan[14186]: /proc/acpi/ibm/fan: fopen: No such file or directory

Once the user follows directions, and the module is loaded with the correct parameter, the excess messages go away. But maybe once a minute is enough? Or even once?

Using zcfan-1.1.0-1.fc36.x86_64, kernel-5.17.1-300.fc36.x86_64

Allow blacklisting sensors

I noticed my SSD temp (around 67 degs) gets picked up as the temp, and used for the rules, etc.

The SSD temp lives under /sys/class/hwmon/hwmon1/temp*_input.
temp1 is "nvme composite" temp, and "temp2 is nvme sensor 2".
Sensor 2 reads around 67 most of the time.

The SSD is not covered by the Thinkpad cooler (on the T16 at least):
https://laptopmedia.com/wp-content/uploads/2022/08/internals-1000x711.jpg

So, controlling fan temp based on this max temp, is not very useful.
TEMP_FILES_GLOB "/sys/class/hwmon/hwmon*/temp*_input" is too broad.

I think a solution could be to allow an override path for TEMP_FILES_GLOB to be specified in /etc/zcfan.conf
On my system, /sys/class/hwmon/hwmon6/ contains all the CPU and GPU temps.

(I dunno if having a single path override is going to be feasible for some hardware configuration - with dedicated graphics chips, which might be reported under a different /sys/class/hwmon/hwmon*/...)

Not able to compile...

Hi! When I try to compile it here's what happens:

(base) ThinkPad-L430:~/Documents/GitHub/zcfan$ make
cc -std=gnu99 -O2 -pedantic -Wall -Wextra -Werror zcfan.c -o zcfan

And that's it.

How do I fix it?

What are your recommended settings and tools that can be used next to this tool

@cdown I have a Thinkpad P53 and its configuration was a light at the end of the tunnel, since Thinkfan is very coupled, I do super good with this tool but I wonder if you can list or indicate what your configurations they use in your day by day.For example, I don't know if thermald should use or not or if this interfire with Zcfan.I would help me a gia.Thank you very much

zcfan is not turning off the fan

Host: Thinkpad X240
System: Fedora Workstation 38.
expected behaviour: zcfan should turn off the fan once the temperature is lower than the low_temp (in my case 50). So it should turn of the fan when the temp is 49.
Issue: zcfan is working correctly. but when the temperature is lower than the low_temp, it is not turning of the fan.
Ps: It turns off the fan after I manually restart systemd service by:
sudo systemctl restart zcfan.service

config file not used

I have placed a config file at the path specified in the manpage, but the fan does not increase/decrease at my specified intervals. If it check the systemd process, it seems to be using the default temperature trip points.

Why is the watchdog operated with 120 second timeout?

This is my first look at this project, so I might be completely in the wrong here, but I don't understand why does the code initializes the watchdog to 2 minutes (120 sec) instead of something like 10 seconds. The watchdog is pinged every 2-3 seconds, so the kernel scheduler or something has to go really wrong for the watchdog to fire at let's say 10 second.

2 minutes seems to be a long time with modern hardware, and if zcfan stops running (operator error, crash, systemd fail, whatever), then in 2 minutes a machine can get really hot if something is consuming a lot of CPU at the same time.

I know this is a constant in the code, and I can easily change it for myself, but for people who are using this from a distribution (e.g. Debian), it's not so easy to do this, as the option is not configurable without rebuild. Could we make this changeable from config/envvar, or change the builtin default constant to some drastically smaller value (e.g. 5 or 10)?

Fan cycling indifinetly

I have a ThinkPad T14s gen 3 where I installed zcfan. The fan is cycling like crazy. I am monitoring the CPU and GPU temperature and they never reached 70 or 61. I also feel that the fun runs at high speed always

Mar 13 16:21:58 XX zcfan[11590]: [FAN] Temperature now 63C, fan set to low
Mar 13 16:22:26 XX zcfan[11590]: [FAN] Temperature now 50C, fan set to off
Mar 13 16:24:52 XX zcfan[11590]: [FAN] Temperature now 76C, fan set to medium
Mar 13 16:24:56 XX zcfan[11590]: [FAN] Temperature now 47C, fan set to off
Mar 13 16:25:45 XX zcfan[11590]: [FAN] Temperature now 70C, fan set to low
Mar 13 16:25:49 XX zcfan[11590]: [FAN] Temperature now 48C, fan set to off
Mar 13 16:25:59 XX zcfan[11590]: [FAN] Temperature now 61C, fan set to low
Mar 13 16:26:02 XX zcfan[11590]: [FAN] Temperature now 48C, fan set to off
Mar 13 16:26:22 XX zcfan[11590]: [FAN] Temperature now 61C, fan set to low
Mar 13 16:26:25 XX zcfan[11590]: [FAN] Temperature now 47C, fan set to off

zcfan.conf

max_temp 85
med_temp 75
low_temp 60

systemd service doesn't find executable

after installing with sudo make install on ubuntu, the binary installs into /usr/local/bin but the service path is on /usr/bin/zcfan

fixed it changing the location of the executable to /usr/local/bin/zcfan

please tell me if you need more info

Can be used together with auto-cpufreq

I currently use auto-cpufreq to manage cpu power and frequency but I was wondering if it is possible to use it together with this awesome package, by the way I use a thinkpad p53 so I don't know if I can use this package anywhere. Thanks

can not install

Hello,
Please can somebody help? If i try to install with make, i get error

zcfan.c:1:10: fatal error: errno.h: Bestand of map bestaat niet
    1 | #include <errno.h>
      |          ^~~~~~~~~

Please can somebody help? I'm not so experienced in this kind of things. Thx!

Schermafdruk van 2024-01-18 09-15-58

Control of fan levels

Great project! I installed the RPM and it pretty much worked out of the box.

The only issue I'm running into is the low speed on my machine isn't particularly low, so I'm wondering if you can add a configuration option to set what the levels correspond to. That, or support specifying levels as integers instead of by label.

To give some context, here is what I'm observing on my system:

Level RPMS
0 0
1 2820
2 3360
3 3670
4 3670
5 3670
6 4020
7 4570

As you can see, there's no difference between levels 3 through 5 and 2 is not much slower, so on my system it would make sense to make low_temp level 1 instead of level 2. I imagine there is always going to be some variance with hardware so, while I love that zcfan works well out of the box, fine tuning is still desired.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.