From: Roger Pau Monne <roger.pau@citrix.com>
To: <xen-devel@lists.xen.org>, <linux-kernel@vger.kernel.org>
Cc: Roger Pau Monne <roger.pau@citrix.com>,
Matt Wilson <msw@amazon.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
David Vrabel <david.vrabel@citrix.com>
Subject: [PATCH] grant-table: don't set m2p override if kmap_ops is not set
Date: Tue, 5 Nov 2013 12:24:09 +0100 [thread overview]
Message-ID: <1383650649-13971-1-git-send-email-roger.pau@citrix.com> (raw)
IMHO there's no reason to set a m2p override if the mapping is done in
kernel space, so only set the m2p override when kmap_ops is set.
When kmap_ops is not set, just set the correct p2m translation, this
avoids touching the m2p lock, reducing contention around it.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reported-by: Matt Wilson <msw@amazon.com>
Cc: Matt Wilson <msw@amazon.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Boris Ostrovsky <david.vrabel@citrix.com>
---
drivers/xen/grant-table.c | 30 ++++++++++++++++++++++++++----
1 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 04cdeb8..ebf7126 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -909,8 +909,19 @@ int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
} else {
mfn = PFN_DOWN(map_ops[i].dev_bus_addr);
}
- ret = m2p_add_override(mfn, pages[i], kmap_ops ?
- &kmap_ops[i] : NULL);
+
+ if (kmap_ops) {
+ ret = m2p_add_override(mfn, pages[i], &kmap_ops[i]);
+ } else {
+ /* No need to set the m2p override, just set p2m */
+ WARN_ON(PagePrivate(pages[i]));
+ SetPagePrivate(pages[i]);
+ set_page_private(pages[i], mfn);
+
+ if (unlikely(!set_phys_to_machine(page_to_pfn(pages[i]), FOREIGN_FRAME(mfn))))
+ ret = -ENOMEM;
+ }
+
if (ret)
return ret;
}
@@ -942,8 +953,19 @@ int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops,
}
for (i = 0; i < count; i++) {
- ret = m2p_remove_override(pages[i], kmap_ops ?
- &kmap_ops[i] : NULL);
+ if (kmap_ops) {
+ ret = m2p_remove_override(pages[i], &kmap_ops[i]);
+ } else {
+ /* Remove p2m entry */
+ unsigned long mfn;
+
+ WARN_ON(!PagePrivate(pages[i]));
+ mfn = page_private(pages[i]);
+ ClearPagePrivate(pages[i]);
+
+ if (unlikely(!set_phys_to_machine(page_to_pfn(pages[i]), mfn)))
+ ret = -ENOMEM;
+ }
if (ret)
return ret;
}
--
1.7.7.5 (Apple Git-26)
next reply other threads:[~2013-11-05 11:24 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-05 11:24 Roger Pau Monne [this message]
2013-11-05 11:26 ` Roger Pau Monné
2013-11-05 12:36 ` David Vrabel
2013-11-05 14:47 ` Roger Pau Monné
2013-11-05 14:56 ` Konrad Rzeszutek Wilk
2013-11-05 15:01 ` Roger Pau Monné
2013-11-05 15:08 ` [Xen-devel] " Ian Campbell
2013-11-05 16:03 ` Roger Pau Monné
2013-11-05 20:06 ` Matt Wilson
2013-11-05 20:53 ` Anthony Liguori
2013-11-05 21:16 ` Konrad Rzeszutek Wilk
2013-11-05 22:09 ` Anthony Liguori
2013-11-05 22:19 ` Matt Wilson
2013-11-06 10:22 ` Ian Campbell
2013-11-06 18:46 ` Anthony Liguori
2013-11-06 11:34 ` David Vrabel
2013-11-06 17:59 ` Matt Wilson
2013-11-06 18:52 ` Konrad Rzeszutek Wilk
2013-11-07 20:15 ` Stefano Stabellini
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=1383650649-13971-1-git-send-email-roger.pau@citrix.com \
--to=roger.pau@citrix.com \
--cc=david.vrabel@citrix.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=msw@amazon.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
all inboxes | Powered by JetHome®