All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xie Yongji <xieyongji@bytedance.com>
To: mst@redhat.com, jasowang@redhat.com, xiaodong.liu@intel.com,
	maxime.coquelin@redhat.com, stefanha@redhat.com
Cc: songmuchun@bytedance.com,
	virtualization@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v4 1/5] vduse: Remove unnecessary spin lock protection
Date: Thu, 28 Jul 2022 11:19:56 +0800	[thread overview]
Message-ID: <20220728032000.127-2-xieyongji@bytedance.com> (raw)
In-Reply-To: <20220728032000.127-1-xieyongji@bytedance.com>

Now we use domain->iotlb_lock to protect two different
variables: domain->bounce_maps->bounce_page and
domain->iotlb. But for domain->bounce_maps->bounce_page,
we actually don't need any synchronization between
vduse_domain_get_bounce_page() and vduse_domain_free_bounce_pages()
since vduse_domain_get_bounce_page() will only be called in
page fault handler and vduse_domain_free_bounce_pages() will
be called during file release.

So let's remove the unnecessary spin lock protection in
vduse_domain_get_bounce_page(). Then the usage of
domain->iotlb_lock could be more clear: the lock will be
only used to protect the domain->iotlb.

Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
Acked-by: Jason Wang <jasowang@redhat.com>
---
 drivers/vdpa/vdpa_user/iova_domain.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/vdpa/vdpa_user/iova_domain.c b/drivers/vdpa/vdpa_user/iova_domain.c
index 6daa3978d290..bca1f0b8850c 100644
--- a/drivers/vdpa/vdpa_user/iova_domain.c
+++ b/drivers/vdpa/vdpa_user/iova_domain.c
@@ -211,17 +211,14 @@ static struct page *
 vduse_domain_get_bounce_page(struct vduse_iova_domain *domain, u64 iova)
 {
 	struct vduse_bounce_map *map;
-	struct page *page = NULL;
+	struct page *page;
 
-	spin_lock(&domain->iotlb_lock);
 	map = &domain->bounce_maps[iova >> PAGE_SHIFT];
 	if (!map->bounce_page)
-		goto out;
+		return NULL;
 
 	page = map->bounce_page;
 	get_page(page);
-out:
-	spin_unlock(&domain->iotlb_lock);
 
 	return page;
 }
-- 
2.20.1


  reply	other threads:[~2022-07-28  3:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-28  3:19 [PATCH v4 0/5] VDUSE: Support registering userspace memory as bounce buffer Xie Yongji
2022-07-28  3:19 ` Xie Yongji [this message]
2022-07-28  3:19 ` [PATCH v4 2/5] vduse: Use memcpy_{to,from}_page() in do_bounce() Xie Yongji
2022-07-29  2:33   ` Muchun Song
2022-07-28  3:19 ` [PATCH v4 3/5] vduse: Support using userspace pages as bounce buffer Xie Yongji
2022-07-28  3:19 ` [PATCH v4 4/5] vduse: Support registering userspace memory for IOVA regions Xie Yongji
2022-07-28  3:20 ` [PATCH v4 5/5] vduse: Support querying information of " Xie Yongji
2022-07-28  5:57   ` Jason Wang
2022-07-28  5:57     ` Jason Wang
2022-07-28  6:36     ` Yongji Xie
2022-07-28  6:45       ` Jason Wang
2022-07-28  6:45         ` Jason Wang
2022-07-28  8:27         ` Yongji Xie
2022-07-28  9:02           ` Jason Wang
2022-07-28  9:02             ` Jason Wang
2022-07-29  3:17             ` Yongji Xie
2022-08-02  7:08               ` Jason Wang
2022-08-02  7:08                 ` Jason 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=20220728032000.127-2-xieyongji@bytedance.com \
    --to=xieyongji@bytedance.com \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=mst@redhat.com \
    --cc=songmuchun@bytedance.com \
    --cc=stefanha@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=xiaodong.liu@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.