I'm debugging NUMACTL on MIPS machine. In numa_police_memory() API, we have:

void numa_police_memory(void *mem, size_t size)
{
        int pagesize = numa_pagesize_int();
        unsigned long i;
        for (i = 0; i < size; i += pagesize)
                asm volatile("" :: "r" (((volatile unsigned char *)mem)[i]));
}

It seems "asm volatile("" :: "r" (((volatile unsigned char *)mem)[i]));" is used for reading a VM so that all the memory applied by previous mmap will be allocated onto some specific physical memory. But how does this asm code work? I can't read assembly language! Why is the first double quote empty???

Thanks

有帮助吗?

解决方案

Interestingly, there is no assembly code in this snippet at all, though the asm statement is used. It contains a blank assembly "program", an empty list of outputs, and a list of inputs. The input specification forces ((volatile unsigned char *)mem)[i] to be in a register. So all this bit of magic will do is generate a load of the first byte of each page (pre-fault the pages).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top