Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty module_summary and module_top report when using pageowner as backend #15

Open
liutgnu opened this issue Jul 19, 2022 · 2 comments

Comments

@liutgnu
Copy link
Contributor

liutgnu commented Jul 19, 2022

Hi kasong,

For memstrack cmdline:

$ ./memstrack --notui --backend pageowner --report module_summary,module_top,proc_slab_static
or
$ ./memstrack --notui --backend ftrace --report module_summary,module_top,proc_slab_static

and rmmod/modprobe ext4 in another terminal at the same time, I will get empty module_summary and format module_top as:

======== Report format module_summary: ========
======== Report format module_summary END ========

======== Report format module_top: ========
======== Report format module_top END ========

======== Report format proc_slab_static: ========
Top Slab Usage:
inode_cache: 15.1 MB
dentry: 6.4 MB
xfs_inode: 5.9 MB
.....
======== Report format proc_slab_static END ========

However if I use perf as backend, I can see the stacktrace and module in module_summary and module_top as:

======== Report format module_summary: ========
Module kvm using 0.0MB (4 pages), peak allocation 0.0MB (4 pages)
Module ext4 using 0.0MB (2 pages), peak allocation 0.0MB (2 pages)
======== Report format module_summary END ========

======== Report format module_top: ========
Top stack usage of module kvm:
(null) Pages: 4 (peak: 4)
entry_SYSCALL_64_after_hwframe (0xffffffffaee0007c) Pages: 4 (peak: 4)
do_syscall_64 (0xffffffffaec99ce9) Pages: 4 (peak: 4)
....
======== Report format module_top END ========

Then I made some debug, I found when pageowner and ftrace as backend, src/tracing.c:store_symbol_instead() will be called during init, which will set key_type = KEY_SYMBOL. Then in src/tracing:get_tracenode_module(), NULL will be return, so src/tracing:get_or_new_module() will not be called, neither did src/tracing:insert_hash_node(), and src/report.c:report_module_top() src/report.c:report_module_summary will report nothing because module_map.size=0.

char* get_tracenode_module(struct Tracenode *node) {
	if (!node->key)
		return NULL;

	if (key_type == KEY_SYMBOL)
		// TODO   <<----- 
		return NULL;
	else
		return kaddr_to_module(node->addr);
}

My question is, for pageowner as backend, why set key_type = KEY_SYMBOL during init, since there is //TODO commented, seems the function is not fully implemented though... In this case, are empty module_summary and module_top working as expected?

Thanks!

@ryncsn
Copy link
Owner

ryncsn commented Jul 20, 2022

Hi Tao,

Thanks for reaching out about the problem.

When using perf as backend, memstrack can get the exact callsite address of each layer of stack trace, so by looking at the symbol addresses in /proc/kallsyms, memstrack can tell the symbol name of a callsite and which module a callsite come from.

When using ftrace/page_owner, currently memtrack directly record the resolved symbol name of each callsite, as ftrace/page_owner prints the symbols instead of the address. I tried to implement symbol name based look up here:
a17589b

But it didn't work as expected, I haven't got time to look into it further yet, but it seems if two symbols in two different modules have the same name, we can't get the right module then... Maybe a better solution is to make ftrace/page_owner print the address/module name.

I'll try again to fix this later...

@liutgnu
Copy link
Contributor Author

liutgnu commented Jul 21, 2022

Hi kasong,

Thanks a lot for the info, now I understood the code better. I will give it a try as well when I have time.

Thanks,
Tao Liu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants