You are not logged in.

#1 2011-09-25 00:17:13

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 1,001
Website

GPU temperature module for NVIDIA NV50 cards (works with nouveau)

IMPORTANT NOTE:
this module is ONLY for NV50 cards (GeForce 8xxx, GeForce 9xxx, GeForce 100, GeForce 200, GeForce 300)!

AUR package
Source tarball

v1.0 – initial release
v1.1 – fixed bug where module would not load at boot
v1.2 – uploaded falconindy’s changes – module doesn’t invade userspace anymore
v1.3 – added kobject_put to free memory on module exit
v1.4 – removed unnecessary kernel thread, removed floating point variables
v1.5 – fixed slope, more accurate

This kernel module enables you to see GPU temperature, its meant to be used with nouveau drivers (but may work on nvidia binary also). I wrote it because nouveau seems unable to display GPU temperature, even though there is a category in "sensors", its value is always 0. Also to practice C programming a bit smile

The temperature is read from /sys/kernel/nv50/nv50_temp
Code is influenced by nouveau code.

Last edited by karabaja4 (2012-06-13 19:22:44)

Offline

#2 2011-09-25 00:44:28

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 723
Website

Re: GPU temperature module for NVIDIA NV50 cards (works with nouveau)

Hello

Reading/Writing files from kernel is not a good idea. See http://kernelnewbies.org/FAQ/WhyWriting … ernelIsBad

ps: $startdir in PKGBUILD should not be used (use $srcdir and $pkgdir instead). "|| return 1" is not needed. you can use build() and package() wink

Thanks for your contribution.

Offline

#3 2011-09-25 00:57:48

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 1,001
Website

Re: GPU temperature module for NVIDIA NV50 cards (works with nouveau)

djgera wrote:

ps: $startdir in PKGBUILD should not be used (use $srcdir and $pkgdir instead). "|| return 1" is not needed.

Done. Not sure about build() and package() though wink

djgera wrote:

Reading/Writing files from kernel is not a good idea. See http://kernelnewbies.org/FAQ/WhyWriting … ernelIsBad

Yeah, I stumbled onto that, but this was the easiest way for me to fetch the GPU temperature, because in kernel-space I have easy access to hardware, unlike user-space where accessing hardware requires quite a bit of coding. This seems solid enough so far.

Last edited by karabaja4 (2011-09-25 00:59:45)

Offline

#4 2011-09-25 01:14:24

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 1,001
Website

Re: GPU temperature module for NVIDIA NV50 cards (works with nouveau)

I see your point djgera, this module refuses to load at boot-time. I'll try to fix that bug, I didn't anticipate reboots sad

EDIT: fixed in v1.1.
Please tell me if you find any more bugs.

Last edited by karabaja4 (2011-09-25 01:40:55)

Offline

#5 2011-09-25 19:41:11

Grinch
Member
Registered: 2010-11-07
Posts: 265

Re: GPU temperature module for NVIDIA NV50 cards (works with nouveau)

Sweet, I'll give this a shot later today!

Offline

#6 2011-09-25 21:20:06

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: GPU temperature module for NVIDIA NV50 cards (works with nouveau)

Very interesting. I am curious about picking /tmp, wouldn't it be better to map the value somewhere in /sys, as is done with e.g CPU temperatures?


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#7 2011-09-25 21:28:49

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 1,001
Website

Re: GPU temperature module for NVIDIA NV50 cards (works with nouveau)

.:B:. wrote:

Very interesting. I am curious about picking /tmp, wouldn't it be better to map the value somewhere in /sys, as is done with e.g CPU temperatures?

As djgera stated above, writing to file from kernel module is generally a bad idea, so I picked /tmp as a location where least can go wrong. Writing to /sys, /proc etc. could mess with system and kernel stuff.

Last edited by karabaja4 (2011-09-25 21:30:30)

Offline

#8 2011-09-25 21:42:41

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: GPU temperature module for NVIDIA NV50 cards (works with nouveau)

The problem isn't where you write, but the fact that you're invading userspace at all. Out of sheer masochism, I've installed the kernel manpages and jumped in head first...

http://sprunge.us/ciDP

This seems to work, but I need to figure out how to parent the node in a better place... /sys/devices would be nice....

The uninterruptable sleep should be refactored as well (not sure how other kthreaded modules do this), since you block for up to 10 seconds on unloading the module.

Last edited by falconindy (2011-09-25 21:44:18)

Offline

#9 2011-09-25 21:53:58

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 1,001
Website

Re: GPU temperature module for NVIDIA NV50 cards (works with nouveau)

falconindy wrote:

The uninterruptable sleep should be refactored as well (not sure how other kthreaded modules do this), since you block for up to 10 seconds on unloading the module.

It waits up to 10 seconds (expected ~5s) with msleep_interruptible() just the same, at least on my machine.

P. S. falconindy: at this moment I don't have access to machine where I wrote and tested this (it comes back to me next week), so I cannot include your changes just yet smile But thanks! In the meantime try and solve that node parenting thing.

Last edited by karabaja4 (2011-09-25 22:29:48)

Offline

#10 2011-10-01 17:53:46

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 1,001
Website

Re: GPU temperature module for NVIDIA NV50 cards (works with nouveau)

falconindy wrote:

The problem isn't where you write, but the fact that you're invading userspace at all. Out of sheer masochism, I've installed the kernel manpages and jumped in head first...

http://sprunge.us/ciDP

This seems to work, but I need to figure out how to parent the node in a better place... /sys/devices would be nice....

The uninterruptable sleep should be refactored as well (not sure how other kthreaded modules do this), since you block for up to 10 seconds on unloading the module.

Hey, I (just now, sorry for delay) tested your module, but I can't figure out where that kobject is located?

Offline

#11 2011-10-01 17:57:10

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: GPU temperature module for NVIDIA NV50 cards (works with nouveau)

Should be in /sys/kernel/nv50_temp/

I haven't had time to look into how to reparent it properly.

Offline

#12 2011-10-01 18:24:23

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 1,001
Website

Re: GPU temperature module for NVIDIA NV50 cards (works with nouveau)

falconindy wrote:

Should be in /sys/kernel/nv50_temp/

I haven't had time to look into how to reparent it properly.

Ok, I uploaded you changes - I just changed the path to /sys/kernel/nv50/nv50_temp.

So... now it doesn't invade userspace anymore - updated the first post. Thanks!

Last edited by karabaja4 (2011-10-01 18:25:42)

Offline

#13 2011-10-01 21:19:14

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: GPU temperature module for NVIDIA NV50 cards (works with nouveau)

I missed a kobject_put call to free the memory on exit. Just make sure its called after sysfs_remove_file (line 98 in thermal_exit, or thereabouts).

Offline

#14 2011-10-01 23:48:57

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 1,001
Website

Re: GPU temperature module for NVIDIA NV50 cards (works with nouveau)

falconindy wrote:

I missed a kobject_put call to free the memory on exit. Just make sure its called after sysfs_remove_file (line 98 in thermal_exit, or thereabouts).

Done.

Offline

#15 2011-10-25 21:18:41

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 1,001
Website

Re: GPU temperature module for NVIDIA NV50 cards (works with nouveau)

I've updated this a bit:

v1.4

- kernel thread is no longer used, it was completely unneccesary. Now it reads temperature only when node is actually read.
- floating point variables are no longer used

Offline

#16 2011-10-25 23:54:41

Grinch
Member
Registered: 2010-11-07
Posts: 265

Re: GPU temperature module for NVIDIA NV50 cards (works with nouveau)

Ah, totally forgot about this! Thanks for your work on this, off to try it!

Offline

Board footer

Powered by FluxBB