Почему smp_rmb не выполняет операцию загрузки? ⇐ Linux
-
Гость
Почему smp_rmb не выполняет операцию загрузки?
there is a code as below in the version 2.6.24 of kernel:
unsigned int __kfifo_put(struct kfifo *fifo, unsigned char *buffer, unsigned int len) { unsigned int l; len = min(len, fifo->size - fifo->in + fifo->out); /* * Ensure that we sample the fifo->out index -before- we * start putting bytes into the kfifo. */ smp_mb(); /* first put the data starting from fifo->in to buffer end */ l = min(len, fifo->size - (fifo->in & (fifo->size - 1))); memcpy(fifo->buffer + (fifo->in & (fifo->size - 1)), buffer, l); /* then put the rest (if any) at the beginning of the buffer */ memcpy(fifo->buffer, buffer + l, len - l); /* * Ensure that we add the bytes to the kfifo -before- * we update the fifo->in index. */ smp_wmb(); fifo->in += len; return len; }
my question is why smp_mb() is not preceding getting fifo->out value (namely, len = min(len, fifo->size - fifo->in + fifo->out), but behind it?
Источник: https://stackoverflow.com/questions/781 ... -operation
there is a code as below in the version 2.6.24 of kernel:
unsigned int __kfifo_put(struct kfifo *fifo, unsigned char *buffer, unsigned int len) { unsigned int l; len = min(len, fifo->size - fifo->in + fifo->out); /* * Ensure that we sample the fifo->out index -before- we * start putting bytes into the kfifo. */ smp_mb(); /* first put the data starting from fifo->in to buffer end */ l = min(len, fifo->size - (fifo->in & (fifo->size - 1))); memcpy(fifo->buffer + (fifo->in & (fifo->size - 1)), buffer, l); /* then put the rest (if any) at the beginning of the buffer */ memcpy(fifo->buffer, buffer + l, len - l); /* * Ensure that we add the bytes to the kfifo -before- * we update the fifo->in index. */ smp_wmb(); fifo->in += len; return len; }
my question is why smp_mb() is not preceding getting fifo->out value (namely, len = min(len, fifo->size - fifo->in + fifo->out), but behind it?
Источник: https://stackoverflow.com/questions/781 ... -operation
Мобильная версия