From: Cong Wang <xiyou.wangcong@gmail.com>
To: iommu@lists.linux-foundation.org
Cc: robin.murphy@arm.com, linux-kernel@vger.kernel.org,
joro@8bytes.org, Cong Wang <xiyou.wangcong@gmail.com>,
John Garry <john.garry@huawei.com>
Subject: [Patch v3 2/3] iommu: optimize iova_magazine_free_pfns()
Date: Tue, 17 Dec 2019 20:39:50 -0800 [thread overview]
Message-ID: <20191218043951.10534-3-xiyou.wangcong@gmail.com> (raw)
In-Reply-To: <20191218043951.10534-1-xiyou.wangcong@gmail.com>
If the magazine is empty, iova_magazine_free_pfns() should
be a nop, however it misses the case of mag->size==0. So we
should just call iova_magazine_empty().
This should reduce the contention on iovad->iova_rbtree_lock
a little bit, not much at all.
Cc: Joerg Roedel <joro@8bytes.org>
Cc: John Garry <john.garry@huawei.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
drivers/iommu/iova.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
index cb473ddce4cf..184d4c0e20b5 100644
--- a/drivers/iommu/iova.c
+++ b/drivers/iommu/iova.c
@@ -797,13 +797,23 @@ static void iova_magazine_free(struct iova_magazine *mag)
kfree(mag);
}
+static bool iova_magazine_full(struct iova_magazine *mag)
+{
+ return (mag && mag->size == IOVA_MAG_SIZE);
+}
+
+static bool iova_magazine_empty(struct iova_magazine *mag)
+{
+ return (!mag || mag->size == 0);
+}
+
static void
iova_magazine_free_pfns(struct iova_magazine *mag, struct iova_domain *iovad)
{
unsigned long flags;
int i;
- if (!mag)
+ if (iova_magazine_empty(mag))
return;
spin_lock_irqsave(&iovad->iova_rbtree_lock, flags);
@@ -820,16 +830,6 @@ iova_magazine_free_pfns(struct iova_magazine *mag, struct iova_domain *iovad)
mag->size = 0;
}
-static bool iova_magazine_full(struct iova_magazine *mag)
-{
- return (mag && mag->size == IOVA_MAG_SIZE);
-}
-
-static bool iova_magazine_empty(struct iova_magazine *mag)
-{
- return (!mag || mag->size == 0);
-}
-
static unsigned long iova_magazine_pop(struct iova_magazine *mag,
unsigned long limit_pfn)
{
--
2.21.0
next prev parent reply other threads:[~2019-12-18 4:40 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-18 4:39 [Patch v3 0/3] iommu: reduce spinlock contention on fast path Cong Wang
2019-12-18 4:39 ` [Patch v3 1/3] iommu: avoid unnecessary magazine allocations Cong Wang
2020-01-21 11:11 ` Robin Murphy
2020-01-21 17:21 ` Cong Wang
2020-01-22 17:07 ` Robin Murphy
2020-01-22 17:54 ` Cong Wang
2019-12-18 4:39 ` Cong Wang [this message]
2020-01-21 9:52 ` [Patch v3 2/3] iommu: optimize iova_magazine_free_pfns() Robin Murphy
2020-01-21 17:29 ` Cong Wang
2020-01-22 17:34 ` Robin Murphy
2020-01-22 17:45 ` Cong Wang
2019-12-18 4:39 ` [Patch v3 3/3] iommu: avoid taking iova_rbtree_lock twice Cong Wang
2019-12-19 9:51 ` John Garry
2020-01-21 9:56 ` Robin Murphy
2020-03-03 11:33 ` John Garry
2020-01-20 23:10 ` [Patch v3 0/3] iommu: reduce spinlock contention on fast path Cong Wang
-- strict thread matches above, loose matches on Subject: below --
2019-12-06 21:38 Cong Wang
2019-12-06 21:38 ` [Patch v3 2/3] iommu: optimize iova_magazine_free_pfns() Cong Wang
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=20191218043951.10534-3-xiyou.wangcong@gmail.com \
--to=xiyou.wangcong@gmail.com \
--cc=iommu@lists.linux-foundation.org \
--cc=john.garry@huawei.com \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.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 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).