linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xen: gntalloc.c:  Convert kmap() to kmap_local_page()
@ 2022-04-18  6:19 Alaa Mohamed
  2022-04-18  7:11 ` Julia Lawall
  2022-04-19  9:16 ` Juergen Gross
  0 siblings, 2 replies; 3+ messages in thread
From: Alaa Mohamed @ 2022-04-18  6:19 UTC (permalink / raw)
  To: outreachy
  Cc: boris.ostrovsky, jgross, sstabellini, xen-devel, linux-kernel,
	ira.weiny, eng.alaamohamedsoliman.am

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 <eng.alaamohamedsoliman.am@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] xen: gntalloc.c:  Convert kmap() to kmap_local_page()
  2022-04-18  6:19 [PATCH] xen: gntalloc.c: Convert kmap() to kmap_local_page() Alaa Mohamed
@ 2022-04-18  7:11 ` Julia Lawall
  2022-04-19  9:16 ` Juergen Gross
  1 sibling, 0 replies; 3+ messages in thread
From: Julia Lawall @ 2022-04-18  7:11 UTC (permalink / raw)
  To: Alaa Mohamed
  Cc: outreachy, boris.ostrovsky, jgross, sstabellini, xen-devel,
	linux-kernel, ira.weiny



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 <eng.alaamohamedsoliman.am@gmail.com>
> ---
>  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
>
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xen: gntalloc.c: Convert kmap() to kmap_local_page()
  2022-04-18  6:19 [PATCH] xen: gntalloc.c: Convert kmap() to kmap_local_page() Alaa Mohamed
  2022-04-18  7:11 ` Julia Lawall
@ 2022-04-19  9:16 ` Juergen Gross
  1 sibling, 0 replies; 3+ messages in thread
From: Juergen Gross @ 2022-04-19  9:16 UTC (permalink / raw)
  To: Alaa Mohamed, outreachy
  Cc: boris.ostrovsky, sstabellini, xen-devel, linux-kernel, ira.weiny


[-- Attachment #1.1.1: Type: text/plain, Size: 485 bytes --]

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 <eng.alaamohamedsoliman.am@gmail.com>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-19  9:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-18  6:19 [PATCH] xen: gntalloc.c: Convert kmap() to kmap_local_page() Alaa Mohamed
2022-04-18  7:11 ` Julia Lawall
2022-04-19  9:16 ` Juergen Gross

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