Skip to content

Commit 3f50006

Browse files
zijun_hutorvalds
authored andcommitted
mm/vmalloc.c: simplify /proc/vmallocinfo implementation
Many seq_file helpers exist for simplifying implementation of virtual files especially, for /proc nodes. however, the helpers for iteration over list_head are available but aren't adopted to implement /proc/vmallocinfo currently. Simplify /proc/vmallocinfo implementation by using existing seq_file helpers. Link: http://lkml.kernel.org/r/57FDF2E5.1000201@zoho.com Signed-off-by: zijun_hu <zijun_hu@htc.com> Acked-by: Michal Hocko <mhocko@suse.com> Cc: David Rientjes <rientjes@google.com> Cc: Tejun Heo <tj@kernel.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 29fac03 commit 3f50006

1 file changed

Lines changed: 5 additions & 22 deletions

File tree

‎mm/vmalloc.c‎

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2574,32 +2574,13 @@ void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms)
25742574
static void *s_start(struct seq_file *m, loff_t *pos)
25752575
__acquires(&vmap_area_lock)
25762576
{
2577-
loff_t n = *pos;
2578-
struct vmap_area *va;
2579-
25802577
spin_lock(&vmap_area_lock);
2581-
va = list_first_entry(&vmap_area_list, typeof(*va), list);
2582-
while (n > 0 && &va->list != &vmap_area_list) {
2583-
n--;
2584-
va = list_next_entry(va, list);
2585-
}
2586-
if (!n && &va->list != &vmap_area_list)
2587-
return va;
2588-
2589-
return NULL;
2590-
2578+
return seq_list_start(&vmap_area_list, *pos);
25912579
}
25922580

25932581
static void *s_next(struct seq_file *m, void *p, loff_t *pos)
25942582
{
2595-
struct vmap_area *va = p, *next;
2596-
2597-
++*pos;
2598-
next = list_next_entry(va, list);
2599-
if (&next->list != &vmap_area_list)
2600-
return next;
2601-
2602-
return NULL;
2583+
return seq_list_next(p, &vmap_area_list, pos);
26032584
}
26042585

26052586
static void s_stop(struct seq_file *m, void *p)
@@ -2634,9 +2615,11 @@ static void show_numa_info(struct seq_file *m, struct vm_struct *v)
26342615

26352616
static int s_show(struct seq_file *m, void *p)
26362617
{
2637-
struct vmap_area *va = p;
2618+
struct vmap_area *va;
26382619
struct vm_struct *v;
26392620

2621+
va = list_entry(p, struct vmap_area, list);
2622+
26402623
/*
26412624
* s_show can encounter race with remove_vm_area, !VM_VM_AREA on
26422625
* behalf of vmap area is being tear down or vm_map_ram allocation.

0 commit comments

Comments
 (0)