From: Yu Zhang <yu.c.zhang@linux.intel.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Kevin Tian <kevin.tian@intel.com>,
George Dunlap <george.dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
xen-devel@lists.xen.org, Paul Durrant <paul.durrant@citrix.com>,
zhiyuan.lv@intel.com, Jun Nakajima <jun.nakajima@intel.com>
Subject: Re: [PATCH v5 4/4] x86/ioreq server: Reset outstanding p2m_ioreq_server entries when an ioreq server unmaps.
Date: Tue, 9 Aug 2016 15:39:47 +0800 [thread overview]
Message-ID: <57A988C3.6010302@linux.intel.com> (raw)
In-Reply-To: <57A8CF860200007800103EFF@prv-mh.provo.novell.com>
On 8/9/2016 12:29 AM, Jan Beulich wrote:
>>>> On 12.07.16 at 11:02, <yu.c.zhang@linux.intel.com> wrote:
>> @@ -5512,6 +5513,12 @@ static int hvmop_set_mem_type(
>> if ( rc )
>> goto out;
>>
>> + if ( t == p2m_ram_rw && memtype[a.hvmmem_type] == p2m_ioreq_server )
>> + p2m->ioreq.entry_count++;
>> +
>> + if ( t == p2m_ioreq_server && memtype[a.hvmmem_type] == p2m_ram_rw )
>> + p2m->ioreq.entry_count--;
>> +
> These (and others below) happen, afaict, outside of any lock, which
> can't be right.
How about we make this entry_count as atomic_t and use atomic_inc/dec
instead?
>
>> @@ -5530,11 +5537,13 @@ static int hvmop_set_mem_type(
>> }
>>
>> static int hvmop_map_mem_type_to_ioreq_server(
>> - XEN_GUEST_HANDLE_PARAM(xen_hvm_map_mem_type_to_ioreq_server_t) uop)
>> + XEN_GUEST_HANDLE_PARAM(xen_hvm_map_mem_type_to_ioreq_server_t) uop,
>> + unsigned long *iter)
>> {
>> xen_hvm_map_mem_type_to_ioreq_server_t op;
>> struct domain *d;
>> int rc;
>> + unsigned long gfn = *iter;
>>
>> if ( copy_from_guest(&op, uop, 1) )
>> return -EFAULT;
>> @@ -5559,7 +5568,42 @@ static int hvmop_map_mem_type_to_ioreq_server(
>> if ( rc != 0 )
>> goto out;
>>
>> - rc = hvm_map_mem_type_to_ioreq_server(d, op.id, op.type, op.flags);
>> + if ( gfn == 0 || op.flags != 0 )
>> + rc = hvm_map_mem_type_to_ioreq_server(d, op.id, op.type, op.flags);
> Couldn't you omit the right side of the || in the if()?
Oh right, it is redundant. Thanks! :-)
>
>> + /*
>> + * Iterate p2m table when an ioreq server unmaps from p2m_ioreq_server,
>> + * and reset the remaining p2m_ioreq_server entries back to p2m_ram_rw.
>> + */
>> + if ( op.flags == 0 && rc == 0 )
>> + {
>> + struct p2m_domain *p2m = p2m_get_hostp2m(d);
>> +
>> + while ( gfn <= p2m->max_mapped_pfn )
>> + {
>> + p2m_type_t t;
>> +
>> + if ( p2m->ioreq.entry_count == 0 )
>> + break;
> Perhaps better to be moved up into the while() expression?
OK. Another thing is maybe we can use _atomic_read() to get value of
entry_count if
the counter is defined as atomic_t?
>> + get_gfn_unshare(d, gfn, &t);
>> +
>> + if ( (t == p2m_ioreq_server) &&
>> + !(p2m_change_type_one(d, gfn, t, p2m_ram_rw)) )
> Stray parentheses.
Got it. Thanks!
>> + p2m->ioreq.entry_count--;
>> +
>> + put_gfn(d, gfn);
>> +
>> + /* Check for continuation if it's not the last iteration. */
>> + if ( ++gfn <= p2m->max_mapped_pfn &&
>> + !(gfn & HVMOP_op_mask) &&
>> + hypercall_preempt_check() )
>> + {
>> + rc = -ERESTART;
>> + goto out;
> I think you need to write gfn back to *iter.
Yes, thanks for pointing out.
Yu
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-08-09 7:39 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-12 9:02 [PATCH v5 0/4] x86/ioreq server: Introduce HVMMEM_ioreq_server mem type Yu Zhang
2016-07-12 9:02 ` [PATCH v5 1/4] x86/ioreq server: Rename p2m_mmio_write_dm to p2m_ioreq_server Yu Zhang
2016-07-12 9:02 ` [PATCH v5 2/4] x86/ioreq server: Add new functions to get/set memory types Yu Zhang
2016-07-12 9:02 ` [PATCH v5 3/4] x86/ioreq server: Add HVMOP to map guest ram with p2m_ioreq_server to an ioreq server Yu Zhang
2016-08-08 15:40 ` Jan Beulich
2016-08-09 7:39 ` Yu Zhang
2016-08-09 8:11 ` Jan Beulich
2016-08-09 8:20 ` Paul Durrant
2016-08-09 8:51 ` Yu Zhang
2016-08-09 9:07 ` Paul Durrant
2016-08-10 8:09 ` Yu Zhang
2016-08-10 10:33 ` Jan Beulich
2016-08-10 10:43 ` Paul Durrant
2016-08-10 12:32 ` Yu Zhang
2016-08-10 10:43 ` Yu Zhang
2016-08-11 8:47 ` Yu Zhang
2016-08-11 8:58 ` Jan Beulich
2016-08-11 9:19 ` Yu Zhang
2016-07-12 9:02 ` [PATCH v5 4/4] x86/ioreq server: Reset outstanding p2m_ioreq_server entries when an ioreq server unmaps Yu Zhang
2016-08-08 16:29 ` Jan Beulich
2016-08-09 7:39 ` Yu Zhang [this message]
2016-08-09 8:13 ` Jan Beulich
2016-08-09 9:25 ` Yu Zhang
2016-08-09 9:45 ` Jan Beulich
2016-08-09 10:21 ` Yu Zhang
2016-08-16 13:35 ` George Dunlap
2016-08-16 13:54 ` Jan Beulich
2016-08-30 12:17 ` Yu Zhang
2016-09-02 11:00 ` Yu Zhang
2016-08-05 2:44 ` [PATCH v5 0/4] x86/ioreq server: Introduce HVMMEM_ioreq_server mem type Yu Zhang
2016-08-05 6:16 ` Jan Beulich
2016-08-05 12:46 ` 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=57A988C3.6010302@linux.intel.com \
--to=yu.c.zhang@linux.intel.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@eu.citrix.com \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=paul.durrant@citrix.com \
--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.