page_owner is a debug tool to record who allocated/freed each page. However, it fails to record which module allocated/freed the pages. Generally, most memory leak bugs are caused by modules, especially third-party modules. If page_owner supports recording and filtering pages allocated by modules, it will help us much to find such bugs. In this patch, we identify the module that allocate each page by traversing the stacktrace. The module name will be dumped by page_owner interface. We also enhance the tool/mm/page_owner_sort tool to filter the pages allocated by modules. Besides, when oom occurrs, we fail to know pages are allocated by which modules. It is too late to dump page_owner after oom occurrs. Therefore, we records the number of pages allocated by each module, and dump the modules when oom occurrs. It will help us to find the buggy module. Jinjiang Tu (6): mm/page_owner: support identifying pages allocated by modules mm/page_owner: show modules allocating pages when oom occurred tools/vm/page_owner_sort: support for selecting by module name tools/vm/page_owner_sort: support for culling by module name tools/vm/page_owner_sort: support sorting by module name Documentation: update document for page_owner Documentation/mm/page_owner.rst | 13 +++- include/linux/module.h | 4 ++ kernel/module/Makefile | 1 + kernel/module/main.c | 4 ++ kernel/module/page_owner.c | 38 ++++++++++++ mm/page_owner.c | 96 +++++++++++++++++++++++++++++ tools/mm/page_owner_sort.c | 106 ++++++++++++++++++++++++++++---- 7 files changed, 248 insertions(+), 14 deletions(-) create mode 100644 kernel/module/page_owner.c -- 2.25.1