aboutsummaryrefslogtreecommitdiffstats
path: root/mm/vmalloc.c
diff options
context:
space:
mode:
authorzijun_hu <zijun_hu@htc.com>2016-12-12 19:42:17 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-12-12 21:55:07 -0500
commit3f5000693f80e014fa577b67b93a0de945a4338d (patch)
tree432e554dcbed08b336c981d52a992ee24a224ace /mm/vmalloc.c
parent29fac03bef729ef6f9fba5be56f8554093813c39 (diff)
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>
Diffstat (limited to 'mm/vmalloc.c')
-rw-r--r--mm/vmalloc.c27
1 files changed, 5 insertions, 22 deletions
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index f2481cb4e6b2..e73948afac70 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2574,32 +2574,13 @@ void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms)
2574static void *s_start(struct seq_file *m, loff_t *pos) 2574static void *s_start(struct seq_file *m, loff_t *pos)
2575 __acquires(&vmap_area_lock) 2575 __acquires(&vmap_area_lock)
2576{ 2576{
2577 loff_t n = *pos;
2578 struct vmap_area *va;
2579
2580 spin_lock(&vmap_area_lock); 2577 spin_lock(&vmap_area_lock);
2581 va = list_first_entry(&vmap_area_list, typeof(*va), list); 2578 return seq_list_start(&vmap_area_list, *pos);
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
2591} 2579}
2592 2580
2593static void *s_next(struct seq_file *m, void *p, loff_t *pos) 2581static void *s_next(struct seq_file *m, void *p, loff_t *pos)
2594{ 2582{
2595 struct vmap_area *va = p, *next; 2583 return seq_list_next(p, &vmap_area_list, pos);
2596
2597 ++*pos;
2598 next = list_next_entry(va, list);
2599 if (&next->list != &vmap_area_list)
2600 return next;
2601
2602 return NULL;
2603} 2584}
2604 2585
2605static void s_stop(struct seq_file *m, void *p) 2586static 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)
2634 2615
2635static int s_show(struct seq_file *m, void *p) 2616static int s_show(struct seq_file *m, void *p)
2636{ 2617{
2637 struct vmap_area *va = p; 2618 struct vmap_area *va;
2638 struct vm_struct *v; 2619 struct vm_struct *v;
2639 2620
2621 va = list_entry(p, struct vmap_area, list);
2622
2640 /* 2623 /*
2641 * s_show can encounter race with remove_vm_area, !VM_VM_AREA on 2624 * s_show can encounter race with remove_vm_area, !VM_VM_AREA on
2642 * behalf of vmap area is being tear down or vm_map_ram allocation. 2625 * behalf of vmap area is being tear down or vm_map_ram allocation.