From: Timo Kokkonen Date: Fri, 23 Jul 2010 14:13:00 +0000 (+0300) Subject: analyzer: Avoid ignoring mappings with only one reference X-Git-Url: http://git.itanic.dy.fi/?p=scan-pagemap;a=commitdiff_plain;h=8f09ace2a3122118e358a40c1921b6c405a49d41 analyzer: Avoid ignoring mappings with only one reference 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 --- diff --git a/analyze.c b/analyze.c index 8280ff4..4129955 100644 --- 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 (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; diff --git a/pagemap.h b/pagemap.h index c57f054..cd28c41 100644 --- a/pagemap.h +++ b/pagemap.h @@ -14,6 +14,8 @@ struct maps_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;