All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Xie Yongji <xieyongji@bytedance.com>
Cc: xiaodong.liu@intel.com, linux-kernel@vger.kernel.org,
	virtualization@lists.linux-foundation.org,
	maxime.coquelin@redhat.com, stefanha@redhat.com,
	songmuchun@bytedance.com
Subject: Re: [PATCH v2 1/5] vduse: Remove unnecessary spin lock protection
Date: Wed, 13 Jul 2022 01:57:23 -0400	[thread overview]
Message-ID: <20220713015352-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20220706050503.171-2-xieyongji@bytedance.com>

On Wed, Jul 06, 2022 at 01:04:59PM +0800, Xie Yongji wrote:
> Taking iotlb lock to access bounce page in page fault
> handler is meaningless since vduse_domain_free_bounce_pages()
> would only be called during file release.
> 
> Signed-off-by: Xie Yongji <xieyongji@bytedance.com>

vduse_domain_free_bounce_pages is not the
only one taking this lock. This commit log needs more
analysis documenting all points of access to bounce_maps
and why vduse_domain_get_bounce_page and file
release are the only two.

> ---
>  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

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Xie Yongji <xieyongji@bytedance.com>
Cc: jasowang@redhat.com, xiaodong.liu@intel.com,
	maxime.coquelin@redhat.com, stefanha@redhat.com,
	songmuchun@bytedance.com,
	virtualization@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/5] vduse: Remove unnecessary spin lock protection
Date: Wed, 13 Jul 2022 01:57:23 -0400	[thread overview]
Message-ID: <20220713015352-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20220706050503.171-2-xieyongji@bytedance.com>

On Wed, Jul 06, 2022 at 01:04:59PM +0800, Xie Yongji wrote:
> Taking iotlb lock to access bounce page in page fault
> handler is meaningless since vduse_domain_free_bounce_pages()
> would only be called during file release.
> 
> Signed-off-by: Xie Yongji <xieyongji@bytedance.com>

vduse_domain_free_bounce_pages is not the
only one taking this lock. This commit log needs more
analysis documenting all points of access to bounce_maps
and why vduse_domain_get_bounce_page and file
release are the only two.

> ---
>  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


  parent reply	other threads:[~2022-07-13  5:57 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-06  5:04 [PATCH v2 0/5] VDUSE: Support registering userspace memory as bounce buffer Xie Yongji
2022-07-06  5:04 ` [PATCH v2 1/5] vduse: Remove unnecessary spin lock protection Xie Yongji
2022-07-13  5:43   ` Jason Wang
2022-07-13  5:43     ` Jason Wang
2022-07-13 11:08     ` Yongji Xie
2022-07-14  2:27       ` Jason Wang
2022-07-14  2:27         ` Jason Wang
2022-07-14  6:06         ` Yongji Xie
2022-07-13  5:57   ` Michael S. Tsirkin [this message]
2022-07-13  5:57     ` Michael S. Tsirkin
2022-07-13 10:39     ` Yongji Xie
2022-07-06  5:05 ` [PATCH v2 2/5] vduse: Use memcpy_{to,from}_page() in do_bounce() Xie Yongji
2022-07-13  5:59   ` Jason Wang
2022-07-13  5:59     ` Jason Wang
2022-07-06  5:05 ` [PATCH v2 3/5] vduse: Support using userspace pages as bounce buffer Xie Yongji
2022-07-06  5:05 ` [PATCH v2 4/5] vduse: Support querying IOLTB information Xie Yongji
2022-07-14  2:51   ` Jason Wang
2022-07-14  2:51     ` Jason Wang
2022-07-14  5:58     ` Yongji Xie
2022-07-06  5:05 ` [PATCH v2 5/5] vduse: Support registering userspace memory for IOTLB Xie Yongji
2022-07-06  6:08   ` kernel test robot
2022-07-06  6:08     ` kernel test robot
2022-07-07 23:01   ` kernel test robot
2022-07-07 23:01     ` kernel test robot
2022-07-08  1:14   ` kernel test robot
2022-07-08  1:14     ` kernel test robot
2022-07-06  9:30 ` [PATCH v2 0/5] VDUSE: Support registering userspace memory as bounce buffer Jason Wang
2022-07-06  9:30   ` Jason Wang
2022-07-06 10:15   ` Yongji Xie
2022-07-08  8:38     ` Jason Wang
2022-07-08  8:38       ` Jason Wang
2022-07-08  9:53       ` Yongji Xie
2022-07-11  6:02         ` Jason Wang
2022-07-11  6:02           ` Jason Wang
2022-07-11  7:24           ` Yongji Xie
2022-07-14  2:59             ` Jason Wang
2022-07-14  2:59               ` 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=20220713015352-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.coquelin@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 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.