Using the schedo command to modify the MAXSPIN parameter

If a thread wants to acquire a lock when another thread currently owns that lock and is running on another CPU, the thread that wants the lock will spin on the CPU until the owner thread releases the lock up to a certain value as specified by a tunable parameter called MAXSPIN.

The default value of MAXSPIN is 0x4000 (16384) for SMP systems and at 1 on UP systems. If you notice more idle or I/O wait time on a system that had not shown this previously, it could be that threads are going to sleep more often. If this is causing a performance problem, then tune MAXSPIN such that it is a higher value or set to -1 which means to spin up to 0xFFFFFFFF times.

To revise the number of times to spin before going to sleep use the maxspin option of the schedo command. To reduce CPU usage that might be caused by excessive spins, reduce the value of MAXSPIN as follows:
# schedo -o maxspin=8192

You might observe an increase in context-switching. If context-switching becomes the bottleneck, increase MAXSPIN.

To change the value, you must be the root user.