why use barrier() in binder_mmap function?

32 views
Skip to first unread message

Zhao Junmin

unread,
Jan 31, 2016, 9:19:46 PM1/31/16
to Android Linux Kernel Development
Hi All:
   Now I am reading binder code, 
buffer = proc->buffer;
INIT_LIST_HEAD(&proc->buffers);
list_add(&buffer->entry, &proc->buffers);
buffer->free = 1;
binder_insert_free_buffer(proc, buffer);
proc->free_async_space = proc->buffer_size / 2;
barrier();
proc->files = get_files_struct(current);
proc->vma = vma;
proc->vma_vm_mm = vma->vm_mm;

why use barrier in here?
According the kernel/Documentation/memory-barriers.txt

barrier is an explicit compiler barrier function that prevents the
compiler from moving the memory accesses either side of it to the other side:

if no barrier here, which code will have issue in here?

Thanks
Zhaojunmin

Reply all
Reply to author
Forward
0 new messages