struct maps_list *ml;
if (af->pid) {
- if (!pf->ml)
+ if (list_empty(&pf->ml.list)) {
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) {
+ list_for_each_entry(ml, &pf->ml.list, list) {
if (ml->map->pid == af->pid)
goto get_stats;
}
int main(int argc, char *argv[])
{
struct pageframe pf;
- struct process *process_list = NULL;
+ struct process process_list;
struct parse_opts opts;
if (getuid()) {
}
memset(&pf, 0, sizeof(pf));
+ INIT_LIST_HEAD(&pf.ml.list);
+
+ memset(&process_list, 0, sizeof(process_list));
+ INIT_LIST_HEAD(&process_list.list);
if (scan_all_pids(&pf, &process_list, &opts))
return 1;
if (opts.parse_mask & PARSE_DUMP)
- dump_process_maps(process_list);
+ dump_process_maps(&process_list);
else
- print_pid_stats(&pf, process_list, &opts);
+ print_pid_stats(&pf, &process_list, &opts);
print_page_stats(&pf);
struct pageframe {
struct bintree tree;
- struct maps_list *ml; /* List to mappings which point to this pfn */
+ struct maps_list ml; /* List to mappings which point to this pfn */
unsigned long pfn; /* page frame number */
int swap_type;
int swap_offset;
goto err;
clear_pageframe(pageframe);
+ INIT_LIST_HEAD(&pageframe->ml.list);
err:
return pageframe;
}
* Add a link from the physical page to this
* process's page map
*/
- if (!match->ml) {
- match->ml = alloc_maplist();
- match->ml->map = map;
- } else {
- tmp = alloc_maplist();
- tmp->map = map;
- list_add(&tmp->list, &match->ml->list);
- }
+ tmp = alloc_maplist();
+ tmp->map = map;
+ list_add(&tmp->list, &match->ml.list);
if (match->page_present)
map->pages_present++;
}
static int read_pageframe(int pid, int tid, struct pageframe *pageframe,
- struct process **process_list, struct parse_opts *opts)
+ struct process *process_list, struct parse_opts *opts)
{
struct maps *maps;
struct process *process;
memset(process, 0, sizeof(*process));
INIT_LIST_HEAD(&process->list);
- if (*process_list == NULL)
- *process_list = process;
-
process->pid = pid;
process->tid = tid;
}
}
- list_add_tail(&process->list, &(*process_list)->list);
+ list_add_tail(&process->list, &process_list->list);
return 1;
free:
static int read_pageframe_with_threads(int pid,
struct pageframe *pageframe,
- struct process **process_list,
+ struct process *process_list,
struct parse_opts *opts)
{
DIR *dir = NULL;
return count;
}
-int scan_all_pids(struct pageframe *pf, struct process **process_list,
+int scan_all_pids(struct pageframe *pf, struct process *process_list,
struct parse_opts *opts)
{
DIR *dir = NULL;
#include "pagemap.h"
-int scan_all_pids(struct pageframe *pf, struct process **process_list,
+int scan_all_pids(struct pageframe *pf, struct process *process_list,
struct parse_opts *opts);
#endif