Update: After running the patched thinkpad-keys for >24 hours, CPU time
is a meagre 1 sec, just a tad better than the >25 minutes it used to
spend a day...

This just seemed to good to be true. So, to verify the correctness of
the patch, here's some background:

The tpb source (from which thinkpad-keys is inspired) says the following:
  /* Read only the interesting bytes from nvram to reduce the CPU consupmtion 
of tpb */
  /* The kernel nvram driver reads byte-by-byte from nvram,
      so just reading interesting bytes reduces the amount of inb() calls */

...So I went to the kernel and checked drivers/char/nvram.c, and found:
* Each lseek() calls lock/unlock_kernel()
* Each read() calls spin_lock/unlock_irq (which is expensive)
* Each read() calls nvram_check_checksum (!).

To check the nvram checksum on a PC platform means to inb 30+2 times...
So, instead of saving 6 inb operations as intended, the current grok_nvram 
function does (32+1)*4=132 instead of (32+10)=42, spending 90 more than it 
should (in addition to any other overhead in calling lseek+read 6 times too 
many).

-- 
thinkpad-keys on ThinkPad X60* uses a large amount of CPU
https://bugs.launchpad.net/bugs/45404
You received this bug notification because you are a member of Ubuntu
Bugs, which is a direct subscriber.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to