From: "Jan Beulich" <JBeulich@suse.com>
To: Quan Xu <quan.xu@intel.com>
Cc: Kevin Tian <kevin.tian@intel.com>, Keir Fraser <keir@xen.org>,
George Dunlap <george.dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
"dario.faggioli@citrix.com" <dario.faggioli@citrix.com>,
"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>,
Jun Nakajima <jun.nakajima@intel.com>
Subject: Re: [PATCH v2 03/11] IOMMU/MMU: enhance the call trees of IOMMU unmapping and mapping
Date: Wed, 27 Apr 2016 03:36:44 -0600 [thread overview]
Message-ID: <5720A44C02000078000E63E2@prv-mh.provo.novell.com> (raw)
In-Reply-To: <945CA011AD5F084CBEA3E851C0AB28894B895077@SHSMSX101.ccr.corp.intel.com>
>>> On 27.04.16 at 10:49, <quan.xu@intel.com> wrote:
> On April 25, 2016 5:51 PM, Jan Beulich <JBeulich@suse.com> wrote:
>> >>> On 18.04.16 at 16:00, <quan.xu@intel.com> wrote:
>> > --- a/xen/arch/x86/mm.c
>> > +++ b/xen/arch/x86/mm.c
>> > @@ -2467,7 +2467,7 @@ static int __get_page_type(struct page_info
>> *page, unsigned long type,
>> > int preemptible) {
>> > unsigned long nx, x, y = page->u.inuse.type_info;
>> > - int rc = 0;
>> > + int rc = 0, ret = 0;
>> >
>> > ASSERT(!(type & ~(PGT_type_mask | PGT_pae_xen_l2)));
>> >
>> > @@ -2578,11 +2578,11 @@ static int __get_page_type(struct page_info
>> *page, unsigned long type,
>> > if ( d && is_pv_domain(d) && unlikely(need_iommu(d)) )
>> > {
>> > if ( (x & PGT_type_mask) == PGT_writable_page )
>> > - iommu_unmap_page(d, mfn_to_gmfn(d, page_to_mfn(page)));
>> > + ret = iommu_unmap_page(d, mfn_to_gmfn(d,
>> > + page_to_mfn(page)));
>> > else if ( type == PGT_writable_page )
>> > - iommu_map_page(d, mfn_to_gmfn(d, page_to_mfn(page)),
>> > - page_to_mfn(page),
>> > - IOMMUF_readable|IOMMUF_writable);
>> > + ret = iommu_map_page(d, mfn_to_gmfn(d, page_to_mfn(page)),
>> > + page_to_mfn(page),
>> > +
>> > + IOMMUF_readable|IOMMUF_writable);
>> > }
>> > }
>> >
>> > @@ -2599,6 +2599,9 @@ static int __get_page_type(struct page_info
>> *page, unsigned long type,
>> > if ( (x & PGT_partial) && !(nx & PGT_partial) )
>> > put_page(page);
>> >
>> > + if ( unlikely(ret) )
>> > + rc = ret;
>>
>> Please don't overwrite the more relevant "rc" value in situations like this
> in
>> case that is already non-zero. In this specific case you can actually get
> away
>> without introducing a second error code variable, since the only place rc
> gets
>> altered is between the two hunks above, and overwriting the rc value from
>> map/unmap is then exactly what we want (but I'd much appreciate if you
>> added a comment to this effect).
>>
>
>
> Make sense.
> I hope I have got your point.. then, I will modify it as below:
But I screwed it up. Looking at it as you have it:
> --- a/xen/arch/x86/mm.c
> +++ b/xen/arch/x86/mm.c
> @@ -2578,11 +2578,11 @@ static int __get_page_type(struct page_info *page,
> unsigned long type,
> if ( d && is_pv_domain(d) && unlikely(need_iommu(d)) )
> {
> if ( (x & PGT_type_mask) == PGT_writable_page )
> - iommu_unmap_page(d, mfn_to_gmfn(d, page_to_mfn(page)));
> + rc = iommu_unmap_page(d, mfn_to_gmfn(d, page_to_mfn(page)));
> else if ( type == PGT_writable_page )
> - iommu_map_page(d, mfn_to_gmfn(d, page_to_mfn(page)),
> - page_to_mfn(page),
> - IOMMUF_readable|IOMMUF_writable);
> + rc = iommu_map_page(d, mfn_to_gmfn(d, page_to_mfn(page)),
> + page_to_mfn(page),
> + IOMMUF_readable|IOMMUF_writable);
> }
> }
>
> @@ -2593,6 +2593,8 @@ static int __get_page_type(struct page_info *page, unsigned long type,
> page->nr_validated_ptes = 0;
> page->partial_pte = 0;
> }
> +
> + /* Overwrite the rc value from IOMMU map and unmap. */
> rc = alloc_page_type(page, type, preemptible);
> }
... it is clear that this is wrong: You'd now also discard an error from
the map/unmap with possible success coming back here. I.e. you
want to overwrite the earlier rc only when you get a non-zero value
back here.
> btw, I am clumsy at comment, I'd be pleased if you could help me enhance it.
With the above, the comment is not needed anymore.
> What about:
>
> + if ( rc )
> + printk(XENLOG_WARNING
> + "iommu_hwdom_init: IOMMU mapping failed for dom%d.",
> + d->domain_id);
>
> If this is still not what you want, could you help me enhance it and I can
> follow it as a pattern. Sorry to bother you with such a case.
Looks okay.
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-04-27 9:36 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-18 14:00 [PATCH v2 00/11] Check VT-d Device-TLB flush error Quan Xu
2016-04-18 14:00 ` [PATCH v2 01/11] vt-d: fix the IOMMU flush issue Quan Xu
2016-04-19 6:33 ` Tian, Kevin
2016-04-19 8:33 ` Xu, Quan
2016-04-25 9:22 ` Jan Beulich
2016-04-26 1:17 ` Xu, Quan
2016-04-26 2:18 ` Xu, Quan
2016-04-26 9:10 ` Jan Beulich
2016-04-26 10:15 ` Xu, Quan
2016-04-26 10:52 ` Jan Beulich
2016-04-26 10:58 ` Xu, Quan
2016-04-18 14:00 ` [PATCH v2 02/11] IOMMU: handle IOMMU mapping and unmapping failures Quan Xu
2016-04-19 6:36 ` Tian, Kevin
2016-04-19 6:40 ` Xu, Quan
2016-04-25 9:26 ` Jan Beulich
2016-04-27 14:26 ` Xu, Quan
2016-04-27 15:02 ` Jan Beulich
2016-04-28 1:23 ` Xu, Quan
2016-04-18 14:00 ` [PATCH v2 03/11] IOMMU/MMU: enhance the call trees of IOMMU unmapping and mapping Quan Xu
2016-04-19 6:44 ` Tian, Kevin
2016-04-20 5:27 ` Xu, Quan
2016-04-20 5:44 ` Tian, Kevin
2016-04-20 6:11 ` Jan Beulich
2016-04-20 6:26 ` Xu, Quan
2016-04-25 9:50 ` Jan Beulich
2016-04-27 8:49 ` Xu, Quan
2016-04-27 9:36 ` Jan Beulich [this message]
2016-04-27 13:10 ` Xu, Quan
2016-04-27 14:06 ` Jan Beulich
2016-04-27 15:48 ` George Dunlap
2016-04-28 1:18 ` Xu, Quan
2016-04-18 14:00 ` [PATCH v2 04/11] grant_table: avoid unnecessary work during grant table unmapping Quan Xu
2016-04-19 6:46 ` Tian, Kevin
2016-04-19 13:27 ` Xu, Quan
2016-04-20 5:35 ` Tian, Kevin
2016-04-25 9:55 ` Jan Beulich
2016-04-26 6:48 ` Xu, Quan
2016-04-18 14:00 ` [PATCH v2 05/11] vt-d: propagate IOMMU Device-TLB flush error up to IOMMU unmapping Quan Xu
2016-04-19 6:51 ` Tian, Kevin
2016-04-19 7:01 ` Xu, Quan
2016-04-25 10:06 ` Jan Beulich
2016-04-26 6:49 ` Xu, Quan
2016-04-18 14:00 ` [PATCH v2 06/11] vt-d: propagate IOMMU Device-TLB flush error up to IOMMU mapping Quan Xu
2016-04-19 6:53 ` Tian, Kevin
2016-04-18 14:00 ` [PATCH v2 07/11] IOMMU/MMU: propagate IOMMU Device-TLB flush error up to iommu_iotlb_flush{, _all} (top level ones) Quan Xu
2016-04-25 10:19 ` Jan Beulich
2016-04-26 12:23 ` Xu, Quan
2016-04-26 12:48 ` Jan Beulich
2016-04-27 6:21 ` Xu, Quan
2016-04-27 6:31 ` Jan Beulich
2016-04-27 9:08 ` Xu, Quan
2016-04-27 9:38 ` Jan Beulich
2016-04-18 14:00 ` [PATCH v2 08/11] IOMMU: propagate IOMMU Device-TLB flush error up to iommu_iotlb_flush{, _all} (leaf ones) Quan Xu
2016-04-19 6:58 ` Tian, Kevin
2016-04-19 8:58 ` Xu, Quan
2016-04-25 11:39 ` Jan Beulich
2016-04-26 11:50 ` Xu, Quan
2016-04-26 12:51 ` Jan Beulich
2016-04-26 13:20 ` Xu, Quan
2016-04-18 14:00 ` [PATCH v2 09/11] IOMMU: propagate IOMMU Device-TLB flush error up to IOMMU suspending Quan Xu
2016-04-25 11:52 ` Jan Beulich
2016-04-25 13:58 ` Julien Grall
2016-04-25 14:50 ` Xu, Quan
2016-04-26 9:40 ` Julien Grall
2016-04-26 11:28 ` Xu, Quan
2016-04-28 14:14 ` Xu, Quan
2016-04-28 14:36 ` Jan Beulich
2016-04-28 15:03 ` Xu, Quan
2016-04-28 15:12 ` Jan Beulich
2016-04-28 16:08 ` Xu, Quan
2016-04-29 2:20 ` Tian, Kevin
2016-04-29 2:41 ` Xu, Quan
2016-04-29 7:13 ` Jan Beulich
2016-04-29 8:23 ` Xu, Quan
2016-04-18 14:00 ` [PATCH v2 10/11] vt-d: propagate IOMMU Device-TLB flush error up to vt-d hardware initialization Quan Xu
2016-04-18 14:00 ` [PATCH v2 11/11] vt-d: propagate error up to ME phantom function mapping and unmapping Quan Xu
2016-04-25 12:00 ` Jan Beulich
2016-04-26 10:48 ` Xu, Quan
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=5720A44C02000078000E63E2@prv-mh.provo.novell.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=dario.faggioli@citrix.com \
--cc=george.dunlap@eu.citrix.com \
--cc=jun.nakajima@intel.com \
--cc=keir@xen.org \
--cc=kevin.tian@intel.com \
--cc=quan.xu@intel.com \
--cc=xen-devel@lists.xen.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).