kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
To: virtualization@lists.linux-foundation.org,
	Stefano Garzarella <sgarzare@redhat.com>
Cc: stefanha@redhat.com, "Michael S. Tsirkin" <mst@redhat.com>,
	Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>,
	eperezma@redhat.com, netdev@vger.kernel.org,
	Jason Wang <jasowang@redhat.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Stefano Garzarella <sgarzare@redhat.com>,
	ira.weiny@intel.com
Subject: Re: [PATCH v3 3/8] vringh: replace kmap_atomic() with kmap_local_page()
Date: Wed, 22 Mar 2023 11:37:27 +0100	[thread overview]
Message-ID: <4499457.LvFx2qVVIh@suse> (raw)
In-Reply-To: <20230321154228.182769-4-sgarzare@redhat.com>

On martedì 21 marzo 2023 16:42:23 CET Stefano Garzarella wrote:
> kmap_atomic() is deprecated in favor of kmap_local_page() since commit
> f3ba3c710ac5 ("mm/highmem: Provide kmap_local*").
> 
> With kmap_local_page() the mappings are per thread, CPU local, can take
> page-faults, and can be called from any context (including interrupts).
> Furthermore, the tasks can be preempted and, when they are scheduled to
> run again, the kernel virtual addresses are restored and still valid.
> 
> kmap_atomic() is implemented like a kmap_local_page() which also disables
> page-faults and preemption (the latter only for !PREEMPT_RT kernels,
> otherwise it only disables migration).
> 
> The code within the mappings/un-mappings in getu16_iotlb() and
> putu16_iotlb() don't depend on the above-mentioned side effects of
> kmap_atomic(), so that mere replacements of the old API with the new one
> is all that is required (i.e., there is no need to explicitly add calls
> to pagefault_disable() and/or preempt_disable()).
> 
> This commit reuses a "boiler plate" commit message from Fabio, who has
> already did this change in several places.
> 

FWIW, I can confirm that the conversions here are safe...

Reviewed-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>

Thanks,

Fabio

P.S.: I had to send this message again because my former contained HTML parts 
and so it was rejected by the mailing lists. I don't yet know how HTML crept 
into my text.

> Cc: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> ---
> 
> Notes:
>     v3:
>     - credited Fabio for the commit message
>     - added reference to the commit that deprecated kmap_atomic() [Jason]
>     v2:
>     - added this patch since checkpatch.pl complained about deprecation
>       of kmap_atomic() touched by next patch
> 
>  drivers/vhost/vringh.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
> index a1e27da54481..0ba3ef809e48 100644
> --- a/drivers/vhost/vringh.c
> +++ b/drivers/vhost/vringh.c
> @@ -1220,10 +1220,10 @@ static inline int getu16_iotlb(const struct vringh
> *vrh, if (ret < 0)
>  		return ret;
> 
> -	kaddr = kmap_atomic(iov.bv_page);
> +	kaddr = kmap_local_page(iov.bv_page);
>  	from = kaddr + iov.bv_offset;
>  	*val = vringh16_to_cpu(vrh, READ_ONCE(*(__virtio16 *)from));
> -	kunmap_atomic(kaddr);
> +	kunmap_local(kaddr);
> 
>  	return 0;
>  }
> @@ -1241,10 +1241,10 @@ static inline int putu16_iotlb(const struct vringh
> *vrh, if (ret < 0)
>  		return ret;
> 
> -	kaddr = kmap_atomic(iov.bv_page);
> +	kaddr = kmap_local_page(iov.bv_page);
>  	to = kaddr + iov.bv_offset;
>  	WRITE_ONCE(*(__virtio16 *)to, cpu_to_vringh16(vrh, val));
> -	kunmap_atomic(kaddr);
> +	kunmap_local(kaddr);
> 
>  	return 0;
>  }
> --
> 2.39.2





  reply	other threads:[~2023-03-22 10:37 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-21 15:42 [PATCH v3 0/8] vdpa_sim: add support for user VA Stefano Garzarella
2023-03-21 15:42 ` [PATCH v3 1/8] vdpa: add bind_mm/unbind_mm callbacks Stefano Garzarella
2023-03-23  2:58   ` Jason Wang
2023-03-21 15:42 ` [PATCH v3 2/8] vhost-vdpa: use bind_mm/unbind_mm device callbacks Stefano Garzarella
2023-03-23  3:01   ` Jason Wang
2023-03-23  9:38     ` Stefano Garzarella
2023-03-21 15:42 ` [PATCH v3 3/8] vringh: replace kmap_atomic() with kmap_local_page() Stefano Garzarella
2023-03-22 10:37   ` Fabio M. De Francesco [this message]
2023-03-23  3:02   ` Jason Wang
2023-03-21 15:42 ` [PATCH v3 4/8] vringh: support VA with iotlb Stefano Garzarella
2023-03-23  3:36   ` Jason Wang
2023-03-23 10:37     ` Stefano Garzarella
2023-03-23  8:09   ` Eugenio Perez Martin
2023-03-23 10:46     ` Stefano Garzarella
2023-03-23 14:43       ` Eugenio Perez Martin
2023-03-24 14:39         ` Stefano Garzarella
2023-03-21 15:48 ` [PATCH v3 5/8] vdpa_sim: make devices agnostic for work management Stefano Garzarella
2023-03-21 15:48   ` [PATCH v3 6/8] vdpa_sim: use kthread worker Stefano Garzarella
2023-03-21 15:48   ` [PATCH v3 7/8] vdpa_sim: replace the spinlock with a mutex to protect the state Stefano Garzarella
2023-03-21 15:48   ` [PATCH v3 8/8] vdpa_sim: add support for user VA Stefano Garzarella
2023-03-23  3:42     ` Jason Wang
2023-03-23  9:50       ` Stefano Garzarella
2023-03-23 11:44         ` Michael S. Tsirkin
2023-03-24  2:54         ` Jason Wang
2023-03-24 14:43           ` Stefano Garzarella
2023-03-27  3:12             ` Jason Wang
2023-03-24  3:49     ` Jason Wang
2023-03-24 14:46       ` Stefano Garzarella

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=4499457.LvFx2qVVIh@suse \
    --to=fmdefrancesco@gmail.com \
    --cc=andrey.zhadchenko@virtuozzo.com \
    --cc=eperezma@redhat.com \
    --cc=ira.weiny@intel.com \
    --cc=jasowang@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /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).