]> git.itanic.dy.fi Git - scan-pagemap/commitdiff
analyzer: Avoid ignoring mappings with only one reference
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Fri, 23 Jul 2010 14:13:00 +0000 (17:13 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Fri, 23 Jul 2010 14:13:00 +0000 (17:13 +0300)
The list_for_each_entry macro does not work for lists that have only
one item in it. Thus, we need a special case for lists containing only
one entry.

Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
analyze.c
pagemap.h

index 8280ff47712519a811d926c2697885a9f422652c..41299551b0b333402cd98b1bec2da31e69a72dcb 100644 (file)
--- a/analyze.c
+++ b/analyze.c
@@ -44,6 +44,11 @@ static void count_pages(struct bintree *b, struct bintree_ops *ops)
        if (af->pid) {
                if (!pf->ml)
                        return;
        if (af->pid) {
                if (!pf->ml)
                        return;
+               if (list_empty(&pf->ml->list)) {
+                       ml = list_to_maps_list(&pf->ml->list);
+                       if (ml->map->pid == af->pid)
+                               goto get_stats;
+               }
                list_for_each_entry(ml, &pf->ml->list, list) {
                        if (ml->map->pid == af->pid)
                                goto get_stats;
                list_for_each_entry(ml, &pf->ml->list, list) {
                        if (ml->map->pid == af->pid)
                                goto get_stats;
index c57f054bbfec898d250511b75a1daa728b0870c5..cd28c4100e1f05f3dfde9748444cb5e68631aaeb 100644 (file)
--- a/pagemap.h
+++ b/pagemap.h
@@ -14,6 +14,8 @@ struct maps_list {
        struct maps *map;
        struct list_head list;
 };
        struct maps *map;
        struct list_head list;
 };
+#define list_to_maps_list(list_head)                           \
+       container_of((list_head), struct maps_list, list)
 
 struct pageframe {
        struct bintree tree;
 
 struct pageframe {
        struct bintree tree;