linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Gregory Haskins <gregory.haskins@gmail.com>
Cc: Gregory Haskins <ghaskins@novell.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	"alacrityvm-devel@lists.sourceforge.net" 
	<alacrityvm-devel@lists.sourceforge.net>,
	David Howells <dhowells@redhat.com>
Subject: Re: [PATCH v2 2/4] KVM: introduce "xinterface" API for external	interaction with guests
Date: Tue, 06 Oct 2009 18:23:42 +0200	[thread overview]
Message-ID: <4ACB6F0E.4000407@redhat.com> (raw)
In-Reply-To: <4ACB528D.6030408@gmail.com>

On 10/06/2009 04:22 PM, Gregory Haskins wrote:
>>>>>> +
>>>>>> +static inline void
>>>>>> +_kvm_xinterface_release(struct kref *kref)
>>>>>> +{
>>>>>> +    struct kvm_xinterface *intf;
>>>>>> +    struct module *owner;
>>>>>> +
>>>>>> +    intf = container_of(kref, struct kvm_xinterface, kref);
>>>>>> +
>>>>>> +    owner = intf->owner;
>>>>>> +    rmb();
>>>>>>
>>>>>>
>>>>>>              
>>>>> Why rmb?
>>>>>
>>>>>            
>>>> the intf->ops->release() line may invalidate the intf pointer, so we
>>>> want to ensure that the read completes before the release() is called.
>>>>
>>>> TBH: I'm not 100% its needed, but I was being conservative.
>>>>
>>>>          
>>> rmb()s are only needed if an external agent can issue writes, otherwise
>>> you'd need one after every statement.
>>>        
>> I was following lessons learned here:
>>
>> http://lkml.org/lkml/2009/7/7/175
>>
>> Perhaps mb() or barrier() are more appropriate than rmb()?  I'm CC'ing
>> David Howells in case he has more insight.
>>      
> BTW: In case it is not clear, the rationale as I understand it is we
> worry about the case where one cpu reorders the read to be after the
> ->release(), and another cpu might grab the memory that was kfree()'d
> within the ->release() and scribble something else on it before the read
> completes.
>
> I know rmb() typically needs to be paired with wmb() to be correct, so
> you are probably right to say that the rmb() itself is not appropriate.
>   This problem in general makes my head hurt, which is why I said I am
> not 100% sure of what is required.  As David mentions, perhaps
> "smp_mb()" is more appropriate for this application.  I also speculate
> barrier() may be all that we need.
>    

barrier() is the operation for a compiler barrier.  But it's unneeded 
here - unless the compiler can prove that ->release(intf) will not 
modify intf->owner it is not allowed to move the access afterwards.  An 
indirect function call is generally a barrier() since the compiler can't 
assume memory has not been modified.

-- 
error compiling committee.c: too many arguments to function


  reply	other threads:[~2009-10-06 16:24 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-02 20:19 [PATCH v2 0/4] KVM: xinterface Gregory Haskins
2009-10-02 20:19 ` [PATCH v2 1/4] mm: export use_mm() and unuse_mm() to modules Gregory Haskins
2009-10-02 20:19 ` [PATCH v2 2/4] KVM: introduce "xinterface" API for external interaction with guests Gregory Haskins
2009-10-03 20:05   ` Marcelo Tosatti
2009-10-05 23:33     ` Gregory Haskins
2009-10-04 10:25   ` Avi Kivity
2009-10-05 23:57     ` Gregory Haskins
2009-10-06  9:34       ` Avi Kivity
2009-10-06 13:31         ` Gregory Haskins
2009-10-06 14:22           ` Gregory Haskins
2009-10-06 16:23             ` Avi Kivity [this message]
2009-10-06 17:00               ` Gregory Haskins
2009-10-06 17:00                 ` Gregory Haskins
2009-10-06 19:40                   ` Gregory Haskins
2009-10-07  8:11                     ` Avi Kivity
2009-10-07 12:48                       ` Gregory Haskins
2009-10-08 14:45                         ` Avi Kivity
2009-10-06 16:19           ` Avi Kivity
2009-10-06 16:58             ` Gregory Haskins
2009-10-06 18:18               ` [Alacrityvm-devel] " Ira W. Snyder
2009-10-07  5:10                 ` Amit Shah
2009-10-07  7:43                 ` Avi Kivity
2009-10-02 20:19 ` [PATCH v2 3/4] KVM: add io services to xinterface Gregory Haskins
2009-10-04 10:26   ` Avi Kivity
2009-10-02 20:19 ` [PATCH v2 4/4] KVM: add scatterlist support " Gregory Haskins
2009-10-04 10:28   ` Avi Kivity
2009-10-05 23:57     ` Gregory Haskins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ACB6F0E.4000407@redhat.com \
    --to=avi@redhat.com \
    --cc=alacrityvm-devel@lists.sourceforge.net \
    --cc=dhowells@redhat.com \
    --cc=ghaskins@novell.com \
    --cc=gregory.haskins@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).