Skip to content

Add rbtree postorder iteration functions, runtime tests, and update zswap to use

Cody P Schafer linux-mm lkml 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest5 patches 0 repliesNew
  2. v15 patches 6 repliesSuperseded

Changes in v2 from the cover letter

- spacing
- s/it's/its/
- remove now unused var in zswap code.
- Reviewed-by: Seth Jennings <[email protected]>

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5rbtree: add postorder iteration functionsinclude/linux/rbtree.h lib/rbtree.c+44 -00 replies
2/5rbtree: add rbtree_postorder_for_each_entry_safe() helperinclude/linux/rbtree.h+18 -00 replies
3/5rbtree_test: add test for postorder iterationlib/rbtree_test.c+12 -00 replies
4/5rbtree: allow tests to run as builtinlib/Kconfig.debug+1 -10 replies
5/5mm/zswap: use postorder iteration when destroying rbtreemm/zswap.c+2 -140 replies

Reviews trailers per patch

All 5 patches have a Reviewed-by or Acked-by.

PatchSeth Jennings
1/5R-b
2/5R-b
3/5R-b
4/5R-b
5/5R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/5] Add rbtree postorder iteration functions, runtime tests, and update zswap to use

Postorder iteration yields all of a node's children prior to yielding the node itself, and this particular implementation also avoids examining the leaf links in a node after that node has been yielded.

In what I expect will be its most common usage, postorder iteration allows the deletion of every node in an rbtree without modifying the rbtree nodes (no _requirement_ that they be nulled) while avoiding referencing child nodes after they have been "deleted" (most commonly, freed).

I have only updated zswap to use this functionality at this point, but numerous bits of code (most notably in the filesystem drivers) use a hand rolled postorder iteration that NULLs child links as it traverses the tree. Each of those instances could be replaced with this common implementation.

1 & 2 add rbtree postorder iteration functions.
3 adds testing of the iteration to the rbtree runtime tests 4 allows building the rbtree runtime tests as builtins 5 updates zswap.

--
since v1:
- spacing
- s/it's/its/
- remove now unused var in zswap code.
- Reviewed-by: Seth Jennings <[email protected]>

Cody P Schafer (5):
rbtree: add postorder iteration functions
rbtree: add rbtree_postorder_for_each_entry_safe() helper
rbtree_test: add test for postorder iteration
rbtree: allow tests to run as builtin
mm/zswap: use postorder iteration when destroying rbtree

 include/linux/rbtree.h | 22 ++++++++++++++++++++++
 lib/Kconfig.debug      |  2 +-
 lib/rbtree.c           | 40 ++++++++++++++++++++++++++++++++++++++++
 lib/rbtree_test.c      | 12 ++++++++++++
 mm/zswap.c             | 16 ++--------------
 5 files changed, 77 insertions(+), 15 deletions(-)
Signature · 7 lines
1.8.3.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>