linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Question on vhost_has_feature()
@ 2014-03-03 19:44 Paul E. McKenney
  2014-03-04  7:56 ` Michael S. Tsirkin
  0 siblings, 1 reply; 4+ messages in thread
From: Paul E. McKenney @ 2014-03-03 19:44 UTC (permalink / raw)
  To: mst; +Cc: linux-kernel

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Question on vhost_has_feature()
  2014-03-03 19:44 Question on vhost_has_feature() Paul E. McKenney
@ 2014-03-04  7:56 ` Michael S. Tsirkin
  2014-03-05  1:01   ` Paul E. McKenney
  0 siblings, 1 reply; 4+ messages in thread
From: Michael S. Tsirkin @ 2014-03-04  7:56 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: linux-kernel

On Mon, Mar 03, 2014 at 11:44:23AM -0800, Paul E. McKenney wrote:
> 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

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!


-- 
MST

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Question on vhost_has_feature()
  2014-03-04  7:56 ` Michael S. Tsirkin
@ 2014-03-05  1:01   ` Paul E. McKenney
  2014-03-05 17:11     ` Michael S. Tsirkin
  0 siblings, 1 reply; 4+ messages in thread
From: Paul E. McKenney @ 2014-03-05  1:01 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: linux-kernel

On Tue, Mar 04, 2014 at 09:56:42AM +0200, Michael S. Tsirkin wrote:
> On Mon, Mar 03, 2014 at 11:44:23AM -0800, Paul E. McKenney wrote:
> > 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
> 
> 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.

I am not yet sure whether or not it is a problem, it just looked a bit
strange.  ;-)

							Thanx, Paul

> Thanks a lot for paying attention!
> 
> 
> -- 
> MST
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Question on vhost_has_feature()
  2014-03-05  1:01   ` Paul E. McKenney
@ 2014-03-05 17:11     ` Michael S. Tsirkin
  0 siblings, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2014-03-05 17:11 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: linux-kernel

On Tue, Mar 04, 2014 at 05:01:51PM -0800, Paul E. McKenney wrote:
> On Tue, Mar 04, 2014 at 09:56:42AM +0200, Michael S. Tsirkin wrote:
> > On Mon, Mar 03, 2014 at 11:44:23AM -0800, Paul E. McKenney wrote:
> > > 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
> > 
> > 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.
> 
> I am not yet sure whether or not it is a problem, it just looked a bit
> strange.  ;-)
> 
> 							Thanx, Paul
> 
> > Thanks a lot for paying attention!
> > 
> > 
> > -- 
> > 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.



-- 
MST

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-03-05 17:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-03 19:44 Question on vhost_has_feature() Paul E. McKenney
2014-03-04  7:56 ` Michael S. Tsirkin
2014-03-05  1:01   ` Paul E. McKenney
2014-03-05 17:11     ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).