Skip to contentSkip to conversation

xen: gntalloc.c: Convert kmap() to kmap_local_page()

PATCH Superseded Alaa Mohamed 3 participants 3 messages Apr 18, 2022 – Apr 19, 2022 Xen hypervisor interface

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/xen/gntalloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/gntalloc.c +2 -2
index 4849f94372a4..55acb32842a3 100644
@@ -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);
Signature · 1 line
2.35.2
#1 lore raw
Quoted 7 lines · Alaa Mohamed

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

Quoted 27 lines
---
 drivers/xen/gntalloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/gntalloc.c +2 -3
index 4849f94372a4..55acb32842a3 100644
@@ -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

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Alaa Mohamed
Quoted 9 lines · Alaa Mohamed

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.

Juergen