On 2023-04-21 13:19, Alexander Potapenko wrote:
I think the implementation of these counters is too specific to page_owner and is hard to use for any other purpose. If we decide to have them, there should be no page_owner-specific logic in the way we initialize/increment/decrement these counters.
Another solution would be to always increment the refcount in __stack_depot_save,
in this case the "page-owner" specific changes are gone, and it is more of a generic thing. e.g: Andrey Konovalov mentioned that in a future KASAN remodelation, he would be using a stack refcount as well.
The thresholds in "mm,page_owner: Filter out stacks by a threshold counter" should also belong elsewhere.
That can certainly be cleaned up I guess to not polute non-page_owner code.
Given that no other stackdepot user needs these counters, maybe it should be cleaner to store an opaque struct along with the stack, passing its size to stack_depot_save(), and letting users access it directly using the stackdepot handler. I am also wondering if a separate hashtable mapping handlers to counters would solve the problem for you?
Let us see first if with the changes from above the code gets to a more generic and clean stage, if not we can explore further options. Thanks for your feedback Alexander! -- Oscar Salvador SUSE Labs