Commit b44f71e3 authored by ZhangPeng's avatar ZhangPeng Committed by Andrew Morton

mm/vmalloc.c: use helper function va_size()

Use helper function va_size() to improve code readability. No functional
modification involved.

Link: https://lkml.kernel.org/r/20240906102539.3537207-1-zhangpeng362@huawei.comSigned-off-by: default avatarZhangPeng <zhangpeng362@huawei.com>
Reviewed-by: default avatarUladzislau Rezki (Sony) <urezki@gmail.com>
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 354a595a
...@@ -1940,7 +1940,7 @@ static inline void setup_vmalloc_vm(struct vm_struct *vm, ...@@ -1940,7 +1940,7 @@ static inline void setup_vmalloc_vm(struct vm_struct *vm,
{ {
vm->flags = flags; vm->flags = flags;
vm->addr = (void *)va->va_start; vm->addr = (void *)va->va_start;
vm->size = va->va_end - va->va_start; vm->size = va_size(va);
vm->caller = caller; vm->caller = caller;
va->vm = vm; va->vm = vm;
} }
...@@ -2018,7 +2018,7 @@ static struct vmap_area *alloc_vmap_area(unsigned long size, ...@@ -2018,7 +2018,7 @@ static struct vmap_area *alloc_vmap_area(unsigned long size,
if (vm) { if (vm) {
vm->addr = (void *)va->va_start; vm->addr = (void *)va->va_start;
vm->size = va->va_end - va->va_start; vm->size = va_size(va);
va->vm = vm; va->vm = vm;
} }
...@@ -2192,7 +2192,7 @@ static void purge_vmap_node(struct work_struct *work) ...@@ -2192,7 +2192,7 @@ static void purge_vmap_node(struct work_struct *work)
vn->nr_purged = 0; vn->nr_purged = 0;
list_for_each_entry_safe(va, n_va, &vn->purge_list, list) { list_for_each_entry_safe(va, n_va, &vn->purge_list, list) {
unsigned long nr = (va->va_end - va->va_start) >> PAGE_SHIFT; unsigned long nr = va_size(va) >> PAGE_SHIFT;
unsigned long orig_start = va->va_start; unsigned long orig_start = va->va_start;
unsigned long orig_end = va->va_end; unsigned long orig_end = va->va_end;
unsigned int vn_id = decode_vn_id(va->flags); unsigned int vn_id = decode_vn_id(va->flags);
...@@ -2336,8 +2336,8 @@ static void free_vmap_area_noflush(struct vmap_area *va) ...@@ -2336,8 +2336,8 @@ static void free_vmap_area_noflush(struct vmap_area *va)
if (WARN_ON_ONCE(!list_empty(&va->list))) if (WARN_ON_ONCE(!list_empty(&va->list)))
return; return;
nr_lazy = atomic_long_add_return((va->va_end - va->va_start) >> nr_lazy = atomic_long_add_return(va_size(va) >> PAGE_SHIFT,
PAGE_SHIFT, &vmap_lazy_nr); &vmap_lazy_nr);
/* /*
* If it was request by a certain node we would like to * If it was request by a certain node we would like to
...@@ -2933,8 +2933,7 @@ void vm_unmap_ram(const void *mem, unsigned int count) ...@@ -2933,8 +2933,7 @@ void vm_unmap_ram(const void *mem, unsigned int count)
if (WARN_ON_ONCE(!va)) if (WARN_ON_ONCE(!va))
return; return;
debug_check_no_locks_freed((void *)va->va_start, debug_check_no_locks_freed((void *)va->va_start, va_size(va));
(va->va_end - va->va_start));
free_unmap_vmap_area(va); free_unmap_vmap_area(va);
} }
EXPORT_SYMBOL(vm_unmap_ram); EXPORT_SYMBOL(vm_unmap_ram);
...@@ -4932,7 +4931,7 @@ static void show_purge_info(struct seq_file *m) ...@@ -4932,7 +4931,7 @@ static void show_purge_info(struct seq_file *m)
list_for_each_entry(va, &vn->lazy.head, list) { list_for_each_entry(va, &vn->lazy.head, list) {
seq_printf(m, "0x%pK-0x%pK %7ld unpurged vm_area\n", seq_printf(m, "0x%pK-0x%pK %7ld unpurged vm_area\n",
(void *)va->va_start, (void *)va->va_end, (void *)va->va_start, (void *)va->va_end,
va->va_end - va->va_start); va_size(va));
} }
spin_unlock(&vn->lazy.lock); spin_unlock(&vn->lazy.lock);
} }
...@@ -4954,7 +4953,7 @@ static int vmalloc_info_show(struct seq_file *m, void *p) ...@@ -4954,7 +4953,7 @@ static int vmalloc_info_show(struct seq_file *m, void *p)
if (va->flags & VMAP_RAM) if (va->flags & VMAP_RAM)
seq_printf(m, "0x%pK-0x%pK %7ld vm_map_ram\n", seq_printf(m, "0x%pK-0x%pK %7ld vm_map_ram\n",
(void *)va->va_start, (void *)va->va_end, (void *)va->va_start, (void *)va->va_end,
va->va_end - va->va_start); va_size(va));
continue; continue;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment