]> Git Repo - J-linux.git/commitdiff
ring-buffer: Use vma_pages() helper function
authorThorsten Blum <[email protected]>
Tue, 9 Jul 2024 21:56:58 +0000 (23:56 +0200)
committerSteven Rostedt (Google) <[email protected]>
Mon, 15 Jul 2024 19:09:06 +0000 (15:09 -0400)
Use the vma_pages() helper function and fix the following
Coccinelle/coccicheck warning reported by vma_pages.cocci:

  WARNING: Consider using vma_pages helper on vma

Rename the local variable vma_pages accordingly.

Signed-off-by: Thorsten Blum <[email protected]>
Link: https://lore.kernel.org/[email protected]
Signed-off-by: Steven Rostedt (Google) <[email protected]>
kernel/trace/ring_buffer.c

index f3d772461a60fbcb83f06a498ae7eba4c644a81f..d59cf0023e387df6abb76c1da796001230c1e70a 100644 (file)
@@ -6920,7 +6920,7 @@ static int __rb_inc_dec_mapped(struct ring_buffer_per_cpu *cpu_buffer,
 static int __rb_map_vma(struct ring_buffer_per_cpu *cpu_buffer,
                        struct vm_area_struct *vma)
 {
-       unsigned long nr_subbufs, nr_pages, vma_pages, pgoff = vma->vm_pgoff;
+       unsigned long nr_subbufs, nr_pages, nr_vma_pages, pgoff = vma->vm_pgoff;
        unsigned int subbuf_pages, subbuf_order;
        struct page **pages;
        int p = 0, s = 0;
@@ -6946,11 +6946,11 @@ static int __rb_map_vma(struct ring_buffer_per_cpu *cpu_buffer,
        nr_subbufs = cpu_buffer->nr_pages + 1; /* + reader-subbuf */
        nr_pages = ((nr_subbufs) << subbuf_order) - pgoff + 1; /* + meta-page */
 
-       vma_pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
-       if (!vma_pages || vma_pages > nr_pages)
+       nr_vma_pages = vma_pages(vma);
+       if (!nr_vma_pages || nr_vma_pages > nr_pages)
                return -EINVAL;
 
-       nr_pages = vma_pages;
+       nr_pages = nr_vma_pages;
 
        pages = kcalloc(nr_pages, sizeof(*pages), GFP_KERNEL);
        if (!pages)
This page took 0.059308 seconds and 4 git commands to generate.