kenvctrld causes very high cpu load
PATCH 1/1 kenvctrld causes very high cpu load
Hi!
I recently got a Sun Blade 1000.
I encountered the same problem described at
http://ubuntuforums.org/showthread.php?t=297474
The mentioned solution (removing the msleep) and switch to polling mode is imho no good option.
Problem:
kthread kenvctrld calls wait_for_pin(), attaches itself to the wait_queue and sets itself INTERRUPTIBLE (unneccesary because msleep_interruptible does the same). Then it checks if the i2c-query is already done. Usually this is not the case at first check.
Then kenvctrl calles msleep_interruptible(250). Usually 1 or 2 ms later the i2c-bus signals by interrupt that the desired operation is done. The interrupt-handler wakes up all tasks in the wq.
Know kenvctrld is reset to TASK_RUNNING and does about 248 ms sleeping at kernel priority :-(
the patch attached will switch this to wait_event_interruptible_timeout. It might be possible to change this line:
if ((val != -ERESTARTSYS) && (val > 0)) {to
if (val > 0) {but I was not sure if I can rely on errror codes <0
Please check this patch since I do not know exactly how to proceed.
Signature · 4 lines
Jörg Friedrich There are only 10 types of people: Those who understand binary and those who don't.
drivers/sbus/char/bbc_i2c.c renamed from drivers/sbus/char/bbc_i2c.c.orig +6 -7
@@ -187,19 +187,18 @@ bp->waiting =1 ;add_wait_queue (&bp->wq, &wait);while (limit-- >0 ) { -u8 val; +long val; -set_current_state (TASK_INTERRUPTIBLE ); - *status = val =readb (bp->i2c_control_regs +0 ); -if ((val &I2C_PCF_PIN ) ==0 ) { + val =wait_event_interruptible_timeout (bp->wq, + (((*status =readb (bp->i2c_control_regs +0 )) &I2C_PCF_PIN ) ==0 ), +msecs_to_jiffies (250 )); +if ((val != -ERESTARTSYS ) && (val >0 )) { ret =0 ;break ; } -msleep_interruptible (250 ); }remove_wait_queue (&bp->wq, &wait); bp->waiting =0 ; - current->state =TASK_RUNNING ;return ret; }
@@ -340,7 +339,7 @@*/ if (bp->waiting && !(readb (bp->i2c_control_regs +0x0 ) &I2C_PCF_PIN )) -wake_up (&bp->wq); +wake_up_interruptible (&bp->wq);return IRQ_HANDLED ; }
Quoted 5 lines · Joerg Friedrich
Hi!
I recently got a Sun Blade 1000.
I encountered the same problem described at
http://ubuntuforums.org/showthread.php?t)7474
This problem also affects Blade 2000 machines, as mentioned in this post on debian-sparc:
http://lists.debian.org/debian-sparc/2007/02/msg00055.html
Joerg's patch seems to be doing the right thing there.
Best regards,
Signature · 2 lines
Jurij Smakov [email protected] Key: http://www.wooyd.org/pgpkey/ KeyID: C99E03CC