From: Yu Zhang <yu.c.zhang@linux.intel.com>
To: Jan Beulich <JBeulich@suse.com>,
George Dunlap <george.dunlap@citrix.com>
Cc: Kevin Tian <kevin.tian@intel.com>,
George Dunlap <george.dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Tim Deegan <tim@xen.org>,
xen-devel@lists.xen.org, Paul Durrant <paul.durrant@citrix.com>,
zhiyuan.lv@intel.com, JunNakajima <jun.nakajima@intel.com>
Subject: Re: [PATCH v4 3/3] x86/ioreq server: Add HVMOP to map guest ram with p2m_ioreq_server to an ioreq server.
Date: Thu, 16 Jun 2016 17:30:55 +0800 [thread overview]
Message-ID: <576271CF.8020202@linux.intel.com> (raw)
In-Reply-To: <5761485002000078000F536B@prv-mh.provo.novell.com>
On 6/15/2016 6:21 PM, Jan Beulich wrote:
>>>> On 15.06.16 at 11:50, <george.dunlap@citrix.com> wrote:
>> On 14/06/16 14:31, Jan Beulich wrote:
>>>>>> On 14.06.16 at 15:13, <george.dunlap@citrix.com> wrote:
>>>> On 14/06/16 11:45, Jan Beulich wrote:
>>>>> Locking is somewhat strange here: You protect against the "set"
>>>>> counterpart altering state while you retrieve it, but you don't
>>>>> protect against the returned data becoming stale by the time
>>>>> the caller can consume it. Is that not a problem? (The most
>>>>> concerning case would seem to be a race of hvmop_set_mem_type()
>>>>> with de-registration of the type.)
>>>> How is that different than calling set_mem_type() first, and then
>>>> de-registering without first unmapping all the types?
>>> Didn't we all agree this is something that should be disallowed
>>> anyway (not that I've seen this implemented, i.e. just being
>>> reminded of it by your reply)?
>> I think I suggested it as a good idea, but Paul and Yang both thought it
>> wasn't necessary. Do you think it should be a requirement?
> I think things shouldn't be left in a half-adjusted state.
>
>> We could have the de-registering operation fail in those circumstances;
>> but probably a more robust thing to do would be to have Xen go change
>> all the ioreq_server entires back to ram_rw (since if the caller just
>> ignores the failure, things are in an even worse state).
> If that's reasonable to do without undue delay (e.g. by using
> the usual "recalculate everything" forced to trickle down through
> the page table levels, then that's as good.
Thanks for your advices, Jan & George.
Previously in the 2nd version, I used p2m_change_entry_type_global() to
reset the
outstanding p2m_ioreq_server entries back to p2m_ram_rw asynchronously after
the de-registration. But we realized later that this approach means we
can not support
live migration. And to recalculate the whole p2m table forcefully when
de-registration
happens means too much cost.
And further discussion with Paul was that we can leave the
responsibility to reset p2m type
to the device model side, and even a device model fails to do so, the
affected one will only
be the current VM, neither other VM nor hypervisor will get hurt.
I thought we have reached agreement in the review process of version 2,
so I removed
this part from version 3.
>
>>>>>> + uint32_t flags; /* IN - types of accesses to be forwarded to the
>>>>>> + ioreq server. flags with 0 means to unmap the
>>>>>> + ioreq server */
>>>>>> +#define _HVMOP_IOREQ_MEM_ACCESS_READ 0
>>>>>> +#define HVMOP_IOREQ_MEM_ACCESS_READ \
>>>>>> + (1u << _HVMOP_IOREQ_MEM_ACCESS_READ)
>>>>>> +
>>>>>> +#define _HVMOP_IOREQ_MEM_ACCESS_WRITE 1
>>>>>> +#define HVMOP_IOREQ_MEM_ACCESS_WRITE \
>>>>>> + (1u << _HVMOP_IOREQ_MEM_ACCESS_WRITE)
>>>>> Is there any use for these _HVMOP_* values? The more that they
>>>>> violate standard C name space rules?
>>>> I assume he's just going along with what he sees in params.h.
>>>> "Violating standard C name space rules" by having #defines which start
>>>> with a single _ seems to be a well-established policy for Xen. :-)
>>> Sadly, and I'm trying to prevent matters becoming worse.
>>> Speaking of which - there are XEN_ prefixes missing here too.
>> Right, so in that case I think I would have said, "I realize that lots
>> of other places in the Xen interface use this sort of template for
>> flags, but I think it's a bad idea and I'm trying to stop it expanding.
>> Is there any actual need to have the bit numbers defined separately?
>> If not, please just define each flag as (1u << 0), &c."
> Actually my coding style related comment wasn't for these two
> stage definitions - for those I simply questioned whether they're
> needed. My style complaint was for the <underscore><uppercase>
> name pattern (which would simply be avoided by not having the
> individual bit number #define-s).
>
>> I think you've tripped over "changing coding styles" in unfamiliar code
>> before too, so you know how frustrating it is to try to follow the
>> existing coding style only to be told that you did it wrong. :-)
> Agreed, you caught me on this one. Albeit with the slight
> difference that in the public interface we can't as easily correct
> old mistakes to aid people who simply clone surrounding code
> when adding new bits (the possibility of adding #ifdef-ery doesn't
> seem very attractive to me there, unless we got reports of actual
> name space collisions).
>
Hah, I guess these 2 #defines are just cloned from similar ones, and I
did not expected
they would receive so much comments. Anyway, I admire your preciseness
and thanks
for pointing this out. :)
Since the bit number #defines have no special meaning, I'd like to just
define the flags
directly:
#define HVMOP_IOREQ_MEM_ACCESS_READ (1u << 0)
#define HVMOP_IOREQ_MEM_ACCESS_WRITE (1u << 1)
B.R.
Yu
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-06-16 9:30 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-19 9:05 [PATCH v4 0/3] x86/ioreq server: Introduce HVMMEM_ioreq_server mem type Yu Zhang
2016-05-19 9:05 ` [PATCH v4 1/3] x86/ioreq server: Rename p2m_mmio_write_dm to p2m_ioreq_server Yu Zhang
2016-06-14 10:04 ` Jan Beulich
2016-06-14 13:14 ` George Dunlap
2016-06-15 10:51 ` Yu Zhang
2016-05-19 9:05 ` [PATCH v4 2/3] x86/ioreq server: Add new functions to get/set memory types Yu Zhang
2016-05-19 9:05 ` [PATCH v4 3/3] x86/ioreq server: Add HVMOP to map guest ram with p2m_ioreq_server to an ioreq server Yu Zhang
2016-06-14 10:45 ` Jan Beulich
2016-06-14 13:13 ` George Dunlap
2016-06-14 13:31 ` Jan Beulich
2016-06-15 9:50 ` George Dunlap
2016-06-15 10:21 ` Jan Beulich
2016-06-15 11:28 ` George Dunlap
2016-06-16 9:30 ` Yu Zhang [this message]
2016-06-16 9:55 ` Jan Beulich
2016-06-17 10:17 ` George Dunlap
2016-06-20 9:03 ` Yu Zhang
2016-06-20 10:10 ` George Dunlap
2016-06-20 10:25 ` Jan Beulich
2016-06-20 10:32 ` George Dunlap
2016-06-20 10:55 ` Jan Beulich
2016-06-20 11:28 ` Yu Zhang
2016-06-20 13:13 ` George Dunlap
2016-06-21 7:42 ` Yu Zhang
2016-06-20 10:30 ` Yu Zhang
2016-06-20 10:43 ` George Dunlap
2016-06-20 10:45 ` Jan Beulich
2016-06-20 11:06 ` Yu Zhang
2016-06-20 11:20 ` Jan Beulich
2016-06-20 12:06 ` Yu Zhang
2016-06-20 13:38 ` Jan Beulich
2016-06-21 7:45 ` Yu Zhang
2016-06-21 8:22 ` Jan Beulich
2016-06-21 9:16 ` Yu Zhang
2016-06-21 9:47 ` Jan Beulich
2016-06-21 10:00 ` Yu Zhang
2016-06-21 14:38 ` George Dunlap
2016-06-22 6:39 ` Jan Beulich
2016-06-22 8:38 ` Yu Zhang
2016-06-22 9:11 ` Jan Beulich
2016-06-22 9:16 ` George Dunlap
2016-06-22 9:29 ` Jan Beulich
2016-06-22 9:47 ` George Dunlap
2016-06-22 10:07 ` Yu Zhang
2016-06-22 11:33 ` George Dunlap
2016-06-23 7:37 ` Yu Zhang
2016-06-23 10:33 ` George Dunlap
2016-06-24 4:16 ` Yu Zhang
2016-06-24 6:12 ` Jan Beulich
2016-06-24 7:12 ` Yu Zhang
2016-06-24 8:01 ` Jan Beulich
2016-06-24 9:57 ` Yu Zhang
2016-06-24 10:27 ` Jan Beulich
2016-06-22 10:10 ` Jan Beulich
2016-06-22 10:15 ` George Dunlap
2016-06-22 11:50 ` Jan Beulich
2016-06-15 10:52 ` Yu Zhang
2016-06-15 12:26 ` Jan Beulich
2016-06-16 9:32 ` Yu Zhang
2016-06-16 10:02 ` Jan Beulich
2016-06-16 11:18 ` Yu Zhang
2016-06-16 12:43 ` Jan Beulich
2016-06-20 9:05 ` Yu Zhang
2016-06-14 13:14 ` George Dunlap
2016-05-27 7:52 ` [PATCH v4 0/3] x86/ioreq server: Introduce HVMMEM_ioreq_server mem type Zhang, Yu C
2016-05-27 10:00 ` Jan Beulich
2016-05-27 9:51 ` Zhang, Yu C
2016-05-27 10:02 ` George Dunlap
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=576271CF.8020202@linux.intel.com \
--to=yu.c.zhang@linux.intel.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=george.dunlap@eu.citrix.com \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=paul.durrant@citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.org \
--cc=zhiyuan.lv@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.