linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Xie Yongji <xieyongji@bytedance.com>
Cc: mst <mst@redhat.com>, Liu Xiaodong <xiaodong.liu@intel.com>,
	Maxime Coquelin <maxime.coquelin@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	songmuchun@bytedance.com,
	virtualization <virtualization@lists.linux-foundation.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 1/5] vduse: Remove unnecessary spin lock protection
Date: Wed, 20 Jul 2022 14:02:40 +0800	[thread overview]
Message-ID: <CACGkMEsx1QAkK0UHSmzj0=sm_RwY0PiG02gZa-Mff_Wsf022yQ@mail.gmail.com> (raw)
In-Reply-To: <20220720044144.90-2-xieyongji@bytedance.com>

On Wed, Jul 20, 2022 at 12:42 PM Xie Yongji <xieyongji@bytedance.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@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-20  6:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-20  4:41 [PATCH v3 0/5] VDUSE: Support registering userspace memory as bounce buffer Xie Yongji
2022-07-20  4:41 ` [PATCH v3 1/5] vduse: Remove unnecessary spin lock protection Xie Yongji
2022-07-20  6:02   ` Jason Wang [this message]
2022-07-20  4:41 ` [PATCH v3 2/5] vduse: Use memcpy_{to,from}_page() in do_bounce() Xie Yongji
2022-07-20  4:41 ` [PATCH v3 3/5] vduse: Support using userspace pages as bounce buffer Xie Yongji
2022-07-20  6:03   ` Jason Wang
2022-07-20  4:41 ` [PATCH v3 4/5] vduse: Support registering userspace memory for IOVA regions Xie Yongji
2022-07-20  9:08   ` Jason Wang
2022-07-20  4:41 ` [PATCH v3 5/5] vduse: Support querying information of " Xie Yongji
2022-07-20  9:15   ` Jason Wang
2022-07-21  5:37     ` Yongji Xie

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='CACGkMEsx1QAkK0UHSmzj0=sm_RwY0PiG02gZa-Mff_Wsf022yQ@mail.gmail.com' \
    --to=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 \
    --cc=xieyongji@bytedance.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).