문제

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