Question on vhost_has_feature()
Hello, Michael,
Just curious about the purpose of the rcu_dereference_index_check() in vhost_has_feature(). I don't see how it fits in. The closest thing I see if the use in handle_rx(), where it selects vq->log or NULL. But in that case, I would expect the usual RCU usage pattern to wrap an rcu_dereference() around the vq->log.
Enlightenment?
Thanx, Paul
Quoted 11 lines · Paul E. McKenney
Hello, Michael,
Just curious about the purpose of the
rcu_dereference_index_check()invhost_has_feature(). I don't see how it fits in. The closest thing I see if the use inhandle_rx(), where it selectsvq->logor NULL. But in that case, I would expect the usual RCU usage pattern to wrap anrcu_dereference()around thevq->log.Enlightenment?
Thanx, Paul
Hi Paul,
Yes, it's weird. As you say the use is in handle_rx. The way it's supposed to work is that readers take vq mutex, and writers change the value and then take and release
vq mutex.
We did it like this because there are thinkably multiple vqs.
I tried to document it in vhost.h :
/* Readers use RCU to access memory table pointer
* log base pointer and features.
* Writers use mutex below.*/
If this is a problem, it's possible to restructure the code to avoid this pattern for vhost_has_feature, pls let me know.
Thanks a lot for paying attention!
Signature · 1 line
MST
Quoted 21 lines · Michael S. Tsirkin
Quoted 11 lines · Paul E. McKenney
Hello, Michael,
Just curious about the purpose of the
rcu_dereference_index_check()invhost_has_feature(). I don't see how it fits in. The closest thing I see if the use inhandle_rx(), where it selectsvq->logor NULL. But in that case, I would expect the usual RCU usage pattern to wrap anrcu_dereference()around thevq->log.Enlightenment?
Thanx, Paul
Hi Paul,
Yes, it's weird. As you say the use is in
handle_rx. The way it's supposed to work is that readers take vq mutex, and writers change the value and then take and release
vq mutex.
We did it like this because there are thinkably multiple vqs.
Quoted 7 lines
I tried to document it in
vhost.h:
/* Readers use RCU to access memory table pointer
* log base pointer and features.
* Writers use mutex below.*/If this is a problem, it's possible to restructure the code to avoid this pattern for
vhost_has_feature, pls let me know.
I am not yet sure whether or not it is a problem, it just looked a bit strange. ;-)
Thanx, Paul
Quoted 6 lines
Thanks a lot for paying attention!
Signature · 1 line
MST
Quoted 27 lines · Paul E. McKenney
Quoted 26 lines · Michael S. Tsirkin
Quoted 11 lines · Paul E. McKenney
Hello, Michael,
Just curious about the purpose of the
rcu_dereference_index_check()invhost_has_feature(). I don't see how it fits in. The closest thing I see if the use inhandle_rx(), where it selectsvq->logor NULL. But in that case, I would expect the usual RCU usage pattern to wrap anrcu_dereference()around thevq->log.Enlightenment?
Thanx, Paul
Hi Paul,
Yes, it's weird. As you say the use is in
handle_rx. The way it's supposed to work is that readers take vq mutex, and writers change the value and then take and release
vq mutex.
We did it like this because there are thinkably multiple vqs.I tried to document it in
vhost.h:
/* Readers use RCU to access memory table pointer
* log base pointer and features.
* Writers use mutex below.*/
Quoted 14 lines
Quoted 2 lines
If this is a problem, it's possible to restructure the code to avoid this pattern for
vhost_has_feature, pls let me know.I am not yet sure whether or not it is a problem, it just looked a bit strange. ;-)
Thanx, Paul
Quoted 6 lines
Thanks a lot for paying attention!
Signature · 1 line
MST
Or if you see a better way to document the use of rcu here than the comment above, I'll gladly do it too.
Signature · 1 line
MST