diff mbox series

[-next] KVM: use vma_pages() helper

Message ID 1632900526-119643-1-git-send-email-yang.lee@linux.alibaba.com (mailing list archive)
State New, archived
Headers show
Series [-next] KVM: use vma_pages() helper | expand

Commit Message

Yang Li Sept. 29, 2021, 7:28 a.m. UTC
Use vma_pages function on vma object instead of explicit computation.

Fix the following coccicheck warning:
./virt/kvm/kvm_main.c:3526:29-35: WARNING: Consider using vma_pages
helper on vma

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
---
 virt/kvm/kvm_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paolo Bonzini Sept. 29, 2021, 12:56 p.m. UTC | #1
On 29/09/21 09:28, Yang Li wrote:
> Use vma_pages function on vma object instead of explicit computation.
> 
> Fix the following coccicheck warning:
> ./virt/kvm/kvm_main.c:3526:29-35: WARNING: Consider using vma_pages
> helper on vma
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
> ---
>   virt/kvm/kvm_main.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 7851f3a..8f0e9ea 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -3523,7 +3523,7 @@ static vm_fault_t kvm_vcpu_fault(struct vm_fault *vmf)
>   static int kvm_vcpu_mmap(struct file *file, struct vm_area_struct *vma)
>   {
>   	struct kvm_vcpu *vcpu = file->private_data;
> -	unsigned long pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
> +	unsigned long pages = vma_pages(vma);
>   
>   	if ((kvm_page_in_dirty_ring(vcpu->kvm, vma->vm_pgoff) ||
>   	     kvm_page_in_dirty_ring(vcpu->kvm, vma->vm_pgoff + pages - 1)) &&
> 

Queued, thanks.

Paolo
diff mbox series

Patch

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 7851f3a..8f0e9ea 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -3523,7 +3523,7 @@  static vm_fault_t kvm_vcpu_fault(struct vm_fault *vmf)
 static int kvm_vcpu_mmap(struct file *file, struct vm_area_struct *vma)
 {
 	struct kvm_vcpu *vcpu = file->private_data;
-	unsigned long pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
+	unsigned long pages = vma_pages(vma);
 
 	if ((kvm_page_in_dirty_ring(vcpu->kvm, vma->vm_pgoff) ||
 	     kvm_page_in_dirty_ring(vcpu->kvm, vma->vm_pgoff + pages - 1)) &&