lkml.org 
[lkml]   [2022]   [Apr]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v2] xen: Convert kmap() to kmap_local_page()


On Wed, 20 Apr 2022, Alaa Mohamed wrote:

> kmap() is being deprecated and these usages are all local to the thread
> so there is no reason kmap_local_page() can't be used.
>
> Replace kmap() calls with kmap_local_page().

OK, so from a Coccinelle point of view, could we do

@@
expression e1,e2,x,f;
@@

e1 =
- kmap
+ kmap_local_page
(e2)
... when != x = e1 // not stored in any location and not passed to another function
when != f(...,e1,...)
when != x = e2
when != f(...,e2,...)
-kunmap(e2)
+kunmap_local(e1)

julia

>
> Signed-off-by: Alaa Mohamed <eng.alaamohamedsoliman.am@gmail.com>
> ---
> changes in V2:
> -edit commit subject
> -edit commit message
> ---
> 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
>
>
>

\
 
 \ /
  Last update: 2022-04-20 08:04    [W:0.082 / U:0.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site