[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACGkMEsx1QAkK0UHSmzj0=sm_RwY0PiG02gZa-Mff_Wsf022yQ@mail.gmail.com>
Date: Wed, 20 Jul 2022 14:02:40 +0800
From: Jason Wang <jasowang@...hat.com>
To: Xie Yongji <xieyongji@...edance.com>
Cc: mst <mst@...hat.com>, Liu Xiaodong <xiaodong.liu@...el.com>,
Maxime Coquelin <maxime.coquelin@...hat.com>,
Stefan Hajnoczi <stefanha@...hat.com>,
songmuchun@...edance.com,
virtualization <virtualization@...ts.linux-foundation.org>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3 1/5] vduse: Remove unnecessary spin lock protection
On Wed, Jul 20, 2022 at 12:42 PM Xie Yongji <xieyongji@...edance.com> wrote:
>
> 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@...edance.com>
Acked-by: Jason Wang <jasowang@...hat.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
>
Powered by blists - more mailing lists