2022-04-18 09:07:53

by Alaa Mohamed

[permalink] [raw]
Subject: [PATCH] xen: gntalloc.c: Convert kmap() to kmap_local_page()

The use of kmap() is being deprecated in favor of kmap_local_page()
where it is feasible.

With kmap_local_page(), the mapping is per thread, CPU local and not
globally visible. Therefore __del_gref() is a function
where the use of kmap_local_page() in place of kmap() is correctly
suited.

Signed-off-by: Alaa Mohamed <[email protected]>
---
drivers/xen/gntalloc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/xen/gntalloc.c b/drivers/xen/gntalloc.c
index 4849f94372a4..55acb32842a3 100644
--- a/drivers/xen/gntalloc.c
+++ b/drivers/xen/gntalloc.c
@@ -178,9 +178,9 @@ static void __del_gref(struct gntalloc_gref *gref)
unsigned long addr;

if (gref->notify.flags & UNMAP_NOTIFY_CLEAR_BYTE) {
- uint8_t *tmp = kmap(gref->page);
+ uint8_t *tmp = kmap_local_page(gref->page);
tmp[gref->notify.pgoff] = 0;
- kunmap(gref->page);
+ kunmap_local(tmp);
}
if (gref->notify.flags & UNMAP_NOTIFY_SEND_EVENT) {
notify_remote_via_evtchn(gref->notify.event);
--
2.35.2


2022-04-19 11:00:51

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH] xen: gntalloc.c: Convert kmap() to kmap_local_page()



On Mon, 18 Apr 2022, Alaa Mohamed wrote:

> The use of kmap() is being deprecated in favor of kmap_local_page()
> where it is feasible.
>
> With kmap_local_page(), the mapping is per thread, CPU local and not
> globally visible. Therefore __del_gref() is a function
> where the use of kmap_local_page() in place of kmap() is correctly
> suited.

What is it about __del_gref() that makes this change the right choice?

julia

>
> Signed-off-by: Alaa Mohamed <[email protected]>
> ---
> drivers/xen/gntalloc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/xen/gntalloc.c b/drivers/xen/gntalloc.c
> index 4849f94372a4..55acb32842a3 100644
> --- a/drivers/xen/gntalloc.c
> +++ b/drivers/xen/gntalloc.c
> @@ -178,9 +178,9 @@ static void __del_gref(struct gntalloc_gref *gref)
> unsigned long addr;
>
> if (gref->notify.flags & UNMAP_NOTIFY_CLEAR_BYTE) {
> - uint8_t *tmp = kmap(gref->page);
> + uint8_t *tmp = kmap_local_page(gref->page);
> tmp[gref->notify.pgoff] = 0;
> - kunmap(gref->page);
> + kunmap_local(tmp);
> }
> if (gref->notify.flags & UNMAP_NOTIFY_SEND_EVENT) {
> notify_remote_via_evtchn(gref->notify.event);
> --
> 2.35.2
>
>
>

2022-04-20 03:04:37

by Juergen Gross

[permalink] [raw]
Subject: Re: [PATCH] xen: gntalloc.c: Convert kmap() to kmap_local_page()

On 18.04.22 08:19, Alaa Mohamed wrote:
> The use of kmap() is being deprecated in favor of kmap_local_page()
> where it is feasible.
>
> With kmap_local_page(), the mapping is per thread, CPU local and not
> globally visible. Therefore __del_gref() is a function
> where the use of kmap_local_page() in place of kmap() is correctly
> suited.
>
> Signed-off-by: Alaa Mohamed <[email protected]>

Reviewed-by: Juergen Gross <[email protected]>


Juergen


Attachments:
OpenPGP_0xB0DE9DD628BF132F.asc (3.08 kB)
OpenPGP public key
OpenPGP_signature (505.00 B)
OpenPGP digital signature
Download all attachments