On Thu, Nov 09, 2023 at 11:25:18AM +0800, Jeff Xie wrote: > adding a callback function in the struct page_owner to let the slab layer or the > anon/file handler layer or any other memory-allocated layers to implement what > they would like to tell. There's no need to add a callback. We can tell what a folio is. > + if (page_owner->folio_alloc_post_page_owner) { > + rcu_read_lock(); > + tsk = find_task_by_pid_ns(page_owner->pid, &init_pid_ns); > + rcu_read_unlock(); > + ret += page_owner->folio_alloc_post_page_owner(page_folio(page), tsk, page_owner->data, > + kbuf + ret, count - ret); > + } else > + ret += scnprintf(kbuf + ret, count - ret, "OTHER_PAGE\n"); if (folio_test_slab(folio)) ret += slab_page_owner_info(folio, kbuf + ret, count - ret); else if (folio_test_anon(folio)) ret += anon_page_owner_info(folio, kbuf + ret, count - ret); else if (folio_test_movable(folio)) ret += null_page_owner_info(folio, kbuf + ret, count - ret); else if (folio->mapping) ret += file_page_owner_info(folio, kbuf + ret, count - ret); else ret += null_page_owner_info(folio, kbuf + ret, count - ret); In this scenario, I have the anon handling ksm pages, but if that's not desirable, we can add else if (folio_test_ksm(folio)) ret += ksm_page_owner_info(folio, kbuf + ret, count - ret); right before the folio_test_anon() clause