]> www.infradead.org Git - nvme.git/commit
mm/ksm: optimize the chain()/chain_prune() interfaces
authorChengming Zhou <chengming.zhou@linux.dev>
Fri, 21 Jun 2024 07:54:31 +0000 (15:54 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 5 Jul 2024 01:05:51 +0000 (18:05 -0700)
commita0b856b617c585b86a077aae5176c946e1462b7d
treef34a2a729e3e0c741243dd9ec4821b5fcff7a997
parentd58a361b0350128bf5a5cf47773edaedbb6ea838
mm/ksm: optimize the chain()/chain_prune() interfaces

Now the implementation of stable_node_dup() causes chain()/chain_prune()
interfaces and usages are overcomplicated.

Why?  stable_node_dup() only find and return a candidate stable_node for
sharing, so the users have to recheck using stable_node_dup_any() if any
non-candidate stable_node exist.  And try to ksm_get_folio() from it
again.

Actually, stable_node_dup() can just return a best stable_node as it can,
then the users can check if it's a candidate for sharing or not.

The code is simplified too and fewer corner cases: such as stable_node and
stable_node_dup can't be NULL if returned tree_folio is not NULL.

Link: https://lkml.kernel.org/r/20240621-b4-ksm-scan-optimize-v2-3-1c328aa9e30b@linux.dev
Signed-off-by: Chengming Zhou <chengming.zhou@linux.dev>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Stefan Roesch <shr@devkernel.io>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/ksm.c