On Fri, Mar 4, 2022 at 8:28 PM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote: > > To ensure anon_vma_name refcount does not overflow, stop anon_vma_name > sharing when the refcount reaches REFCOUNT_MAX (2147483647), which still > leaves INT_MAX/2 (1073741823) values before the counter reaches > REFCOUNT_SATURATED. This should provide enough headroom for raising the > refcounts temporarily. This is a classic case of kref simply being the wrong type for this. We sh ould move away from that idiotic "saturate with a warning" type, and just codify that what the page refs do is the RightThing(tm) to do. I've ranted against kref for years, I hate that damn thing. It's literally broken by design with the known leaking behavior. Oh well. I'm taking this patch as a "fix up refcount problems", and I guess I need to some day just extract the page_ref code into a nice type of its own so that it's usable outside of pages. (Others have copied the page_ref code manually, but there's no "helper type with functions to use it", which is why people then use that mis-designed refcount stuff). Linus