mm/hmm: use reference counting for HMM struct

Every time I read the code to check that the HMM structure does not vanish
before it should thanks to the many lock protecting its removal i get a
headache.  Switch to reference counting instead it is much easier to
follow and harder to break.  This also remove some code that is no longer
needed with refcounting.

Signed-off-by: Jérôme Glisse <>
Reviewed-by: Ralph Campbell <>
Cc: John Hubbard <>
Cc: Dan Williams <>
Cc: Arnd Bergmann <>
Cc: Balbir Singh <>
Cc: Dan Carpenter <>
Cc: Ira Weiny <>
Cc: Matthew Wilcox <>
Cc: Souptick Joarder <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
2 files changed