Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does _mm_mwait work?

How does _mm_mwait from pmmintrin.h work? (I mean not the asm for it, but action and how this action is taken in NUMA systems. The store monitoring is easy to implement only on bus-based SMP systems with snooping of bus.)

What processors does implement it?

Is it used in some spinlocks?

like image 202
osgx Avatar asked Apr 02 '10 02:04

osgx


People also ask

How does MWAIT work?

MWAIT instruction provides hints to allow the processor to enter an implementation-dependent optimized state. There are two principal targeted usages: address-range monitor and advanced power management. Both usages of MWAIT require the use of the MONITOR instruction.

What is MONITOR m wait?

MONITOR is used to specify a memory range to “monitor”. MWAIT halts the processor until the address previously specified with MONITOR is accessed. With the new idle loop a processor only has to write to memory to wake up a halted processor.


1 Answers

Every time a CPU on a multicore chip tries to write a specific memory address, all other CPUs, which have this particular memory address in their caches, have to be notified of that change. This notification could be used to implement the wakeup from MWAIT on modern CPUs independent of them having a single or separate memory busses.

What processors does implement it?

MWAIT is part of SSE3.

Is it used in some spinlocks?

This is contrary to the definition of a spinlock - the CPU is not busy.

like image 91
mschneider Avatar answered Sep 18 '22 05:09

mschneider