Re: [PATCH] KVM: SVM: Replace kmap_atomic() with kmap_local_page()

From: Dave Hansen
Date: Fri Sep 02 2022 - 11:30:38 EST


On 9/2/22 02:08, Zhao Liu wrote:
> From: Zhao Liu <zhao1.liu@xxxxxxxxx>
>
> The use of kmap_atomic() is being deprecated in favor of
> kmap_local_page()[1].
>
> In arch/x86/kvm/svm/sev.c, the function sev_clflush_pages() doesn't
> need to disable pagefaults and preemption in kmap_atomic(). It can
> simply use kmap_local_page() / kunmap_local() that can instead do the
> mapping / unmapping regardless of the context.
>
> With kmap_local_page(), the mapping is per thread, CPU local and not
> globally visible. Therefore, sev_clflush_pages() is a function where
> the use of kmap_local_page() in place of kmap_atomic() is correctly
> suited.

This changelog is a little on the weak side. You could literally take
any arbitrary call-site and file for kmap_atomic() and slap that
changelog on it. For instance:

In drivers/target/target_core_sbc.c, the function
sbc_dif_copy_prot() doesn't need to disable pagefaults and
preemption in kmap_atomic(). It can simply use kmap_local_page()
/ kunmap_local() that can instead do the mapping / unmapping
regardless of the context.

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

That's all valid English and there's nothing incorrect in it. But, it
doesn't indicate that any actual analysis was performed. It's utterly
generic. It could literally have been generated by a pretty trivial script.

It would be great to add at least a small, call-site-specific human
touch to these changelogs.

In this case, saying something about how global the cache flush is would
be a great addition.