Hand-waving about a phased sleep
Posted Jan 7, 2009 17:27 UTC (Wed) by BrucePerens
Parent article: Btrfs aims for the mainline
Pardon me for engaging in some hand-waving, and not really knowing what the kernel developers have tried to do about this issue over time.
Isn't the problem here that sleep and the following process wakeup are expensive? In the case that sleep might be necessary only for a short time, a phased sleep makes more sense in the context of multiprocessing or hyperthreads. Halt the processor, but leave the process context in place in the processor. Don't move the process context out of the processor until some time has passed. Handle wakeups during this period by restarting the processor.
First, you stop banging on the lock in a tight loop, and that's important because atomic operations make expensive use of inter-processor cache coordination, potentially keeping other processors from doing useful work for some time. Also, you get to put the CPU core to useful work if the stopped processor is actually a hyperthread.
to post comments)