From patchwork Thu Jul 28 14:20:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 72967 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp880787qga; Thu, 28 Jul 2016 07:25:08 -0700 (PDT) X-Received: by 10.107.175.132 with SMTP id p4mr38287456ioo.23.1469715908930; Thu, 28 Jul 2016 07:25:08 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id g72si33517979itg.53.2016.07.28.07.25.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jul 2016 07:25:08 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSmAw-0007DW-Gj; Thu, 28 Jul 2016 14:20:38 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSmAv-0007C5-KC for xen-devel@lists.xen.org; Thu, 28 Jul 2016 14:20:37 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id D2/B3-09160-4B41A975; Thu, 28 Jul 2016 14:20:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrBLMWRWlGSWpSXmKPExsVysyfVTXeLyKx wg3kfxS2WfFzM4sDocXT3b6YAxijWzLyk/IoE1own/efYCn4JV8ye/Iq9gXGdQBcjF4eQwCZG iRV33jBBOKcZJXof/WHuYuTkYBPQlLjz+RMTiC0iIC1x7fNlRpAiZoF2Rom1/b1gRcICwRJtr 4+ygdgsAqoSc750sYDYvALOEgv/f2UHsSUE5CROHpvMCmJzCrhI3Gv7DmYLAdWcvrudfQIj9w JGhlWMGsWpRWWpRbqGpnpJRZnpGSW5iZk5uoYGxnq5qcXFiempOYlJxXrJ+bmbGIE+ZgCCHYx rtnseYpTkYFIS5Q0LnRkuxJeUn1KZkVicEV9UmpNafIhRhoNDSYLXTXhWuJBgUWp6akVaZg4w 2GDSEhw8SiK8kSBp3uKCxNzizHSI1ClGRSlx3lyQhABIIqM0D64NFuCXGGWlhHkZgQ4R4ilIL crNLEGVf8UozsGoJMy7EWQKT2ZeCdz0V0CLmYAWF8fOAFlckoiQkmpg3HPa57x+xfONVyJnbJ hQUXVh14ml8udqfVWexPpJ1Xe1bmNgXH5nQZD4Vk2uItP9eVvurTBZIV0UeTfl/jf5vbVhaWs f1HXrmbUuO/m85XhT/JMTHLx6y5TMpDiz74esEdW06ivvz41w9MjZv/dBUYTb7oBHXUFipz/q NM6vNP6/Kftv65PtSizFGYmGWsxFxYkAPjLxtWsCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-11.tower-31.messagelabs.com!1469715635!26646407!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 44328 invoked from network); 28 Jul 2016 14:20:36 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-11.tower-31.messagelabs.com with SMTP; 28 Jul 2016 14:20:36 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BB235BB0; Thu, 28 Jul 2016 07:21:52 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.218.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 89DB63F21A; Thu, 28 Jul 2016 07:20:34 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 28 Jul 2016 15:20:12 +0100 Message-Id: <1469715620-4670-8-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1469715620-4670-1-git-send-email-julien.grall@arm.com> References: <1469715620-4670-1-git-send-email-julien.grall@arm.com> Cc: proskurin@sec.in.tum.de, Julien Grall , sstabellini@kernel.org, steve.capper@arm.com, wei.chen@linaro.org Subject: [Xen-devel] [PATCH v2 07/15] xen/arm: p2m: Switch the p2m lock from spinlock to rwlock X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" P2M reads do not require to be serialized. This will add contention when PV drivers are using multi-queue because parallel grant map/unmaps/copies will happen on DomU's p2m. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- I have not done benchark to verify the performance, however a rwlock is always an improvement compare to a spinlock when most of the access only read data. It might be possible to convert the rwlock to a per-cpu rwlock which show some improvement on x86. Changes in v2: - Add Stefano's reviewed-by --- xen/arch/arm/p2m.c | 12 ++++++------ xen/include/asm-arm/p2m.h | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 5c67090..9ba8904 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -49,27 +49,27 @@ static bool_t p2m_mapping(lpae_t pte) static inline void p2m_write_lock(struct p2m_domain *p2m) { - spin_lock(&p2m->lock); + write_lock(&p2m->lock); } static inline void p2m_write_unlock(struct p2m_domain *p2m) { - spin_unlock(&p2m->lock); + write_unlock(&p2m->lock); } static inline void p2m_read_lock(struct p2m_domain *p2m) { - spin_lock(&p2m->lock); + read_lock(&p2m->lock); } static inline void p2m_read_unlock(struct p2m_domain *p2m) { - spin_unlock(&p2m->lock); + read_unlock(&p2m->lock); } static inline int p2m_is_locked(struct p2m_domain *p2m) { - return spin_is_locked(&p2m->lock); + return rw_is_locked(&p2m->lock); } void p2m_dump_info(struct domain *d) @@ -1388,7 +1388,7 @@ int p2m_init(struct domain *d) struct p2m_domain *p2m = &d->arch.p2m; int rc = 0; - spin_lock_init(&p2m->lock); + rwlock_init(&p2m->lock); INIT_PAGE_LIST_HEAD(&p2m->pages); p2m->vmid = INVALID_VMID; diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index 20a220ea..abda70c 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -3,6 +3,7 @@ #include #include +#include #include /* for vm_event_response_t */ #include #include @@ -20,7 +21,7 @@ extern void memory_type_changed(struct domain *); /* Per-p2m-table state */ struct p2m_domain { /* Lock that protects updates to the p2m */ - spinlock_t lock; + rwlock_t lock; /* Pages used to construct the p2m */ struct page_list_head pages;