Cody P Schafer
8de1ee7ebf
rbtree: clarify documentation of rbtree_postorder_for_each_entry_safe()
...
I noticed that commit a20135ffbc ("writeback: don't drain
bdi_writeback_congested on bdi destruction") added a usage of
rbtree_postorder_for_each_entry_safe() in mm/backing-dev.c which appears
to try to rb_erase() elements from an rbtree while iterating over it using
rbtree_postorder_for_each_entry_safe().
Doing this will cause random nodes to be missed by the iteration because
rb_erase() may rebalance the tree, changing the ordering that we're trying
to iterate over.
The previous documentation for rbtree_postorder_for_each_entry_safe()
wasn't clear that this wasn't allowed, it was taken from the docs for
list_for_each_entry_safe(), where erasing isn't a problem due to
list_del() not reordering.
Explicitly warn developers about this potential pit-fall.
Note that I haven't fixed the actual issue that (it appears) the commit
referenced above introduced (not familiar enough with that code).
In general (and in this case), the patterns to follow are:
- switch to rb_first() + rb_erase(), don't use
rbtree_postorder_for_each_entry_safe().
- keep the postorder iteration and don't rb_erase() at all. Instead
just clear the fields of rb_node & cgwb_congested_tree as required by
other users of those structures.
[akpm@linux-foundation.org: tweak comments]
Signed-off-by: Cody P Schafer <dev@codyps.com>
Cc: John de la Garza <john@jjdev.com>
Cc: Michel Lespinasse <walken@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-11-06 17:50:42 -08:00
..
2015-10-19 17:08:32 +01:00
2015-09-29 10:56:05 +03:00
2015-10-09 07:49:01 -07:00
2015-10-01 12:48:11 -07:00
2015-10-17 21:22:08 -07:00
2015-09-30 19:22:50 +09:00
2015-10-07 18:08:15 +01:00
2015-10-21 18:05:50 -05:00
2015-10-16 22:11:16 +02:00
2015-11-04 18:10:13 -08:00
2015-11-06 10:23:50 -08:00
2015-10-14 19:14:44 -07:00
2015-10-14 19:14:43 -07:00
2015-10-27 10:38:41 +01:00
2015-10-09 07:49:00 -07:00
2015-10-27 11:24:23 +01:00
2015-11-04 21:35:12 -08:00
2015-09-23 17:15:27 +02:00
2015-10-27 19:34:54 -07:00
2015-10-16 17:57:33 +01:00
2015-09-23 09:51:25 +02:00
2015-11-04 11:02:12 +00:00
2015-11-04 21:26:27 -08:00
2015-11-04 18:10:13 -08:00
2015-11-03 17:22:17 -08:00
2015-11-04 08:23:51 -05:00
2015-10-12 10:31:12 -06:00
2015-11-05 14:51:32 -08:00
2015-11-06 17:50:42 -08:00
2015-10-27 15:04:56 +09:00
2015-10-21 14:43:41 -06:00
2015-11-04 21:01:27 -08:00
2015-11-02 22:48:39 -05:00
2015-10-08 04:45:52 -07:00
2015-10-15 16:41:53 -04:00
2015-10-15 16:41:53 -04:00
2015-10-26 12:36:55 -07:00
2015-10-01 02:18:39 +02:00
2015-10-23 17:55:10 +09:00
2015-11-05 19:34:48 -08:00
2015-11-06 17:50:42 -08:00
2015-11-05 19:34:48 -08:00
2015-10-07 17:54:09 +01:00
2015-10-07 16:02:49 -07:00
2015-10-28 09:21:12 +01:00
2015-11-06 17:50:42 -08:00
2015-10-09 07:49:02 -07:00
2015-10-18 10:14:39 -07:00
2015-10-31 19:05:59 -04:00
2015-10-15 13:22:35 +01:00
2015-10-23 17:55:10 +09:00
2015-10-15 16:41:04 +02:00
2015-10-04 12:46:06 +01:00
2015-11-04 21:50:37 -08:00
2015-10-28 12:28:06 +01:00
2015-10-16 08:30:09 +09:00
2015-10-04 11:36:07 +01:00
2015-10-13 10:51:30 -07:00
2015-10-31 16:12:10 -07:00
2015-10-11 04:40:05 -07:00
2015-11-05 23:10:54 -08:00
2015-11-04 18:10:13 -08:00
2015-10-09 07:48:59 -07:00
2015-10-21 14:43:42 -06:00
2015-11-06 17:50:42 -08:00
2015-11-06 17:50:42 -08:00
2015-11-05 19:34:48 -08:00
2015-11-04 16:24:33 +01:00
2015-10-13 10:34:46 +02:00
2015-09-24 20:42:37 +02:00
2015-09-23 14:35:58 -07:00
2015-10-23 05:44:28 -07:00
2015-09-29 16:27:47 -07:00
2015-10-09 07:49:05 -07:00
2015-11-05 14:51:32 -08:00
2015-10-15 15:35:32 +01:00
2015-10-27 08:36:08 +09:00
2015-09-22 12:39:57 +02:00
2015-11-04 11:30:57 -08:00
2015-10-22 00:00:49 +02:00
2015-10-16 22:18:51 +02:00
2015-10-04 12:46:06 +01:00
2015-10-05 02:45:25 -07:00
2015-10-11 11:33:42 +02:00
2015-10-01 15:06:43 +02:00
2015-10-01 02:18:38 +02:00
2015-10-13 19:01:25 +02:00
2015-10-30 10:13:26 +01:00
2015-11-05 14:51:32 -08:00
2015-11-06 17:50:42 -08:00
2015-10-21 15:18:36 +01:00
2015-10-21 15:18:36 +01:00
2015-10-04 11:46:16 +01:00
2015-11-04 16:24:36 +01:00
2015-10-01 15:06:46 +02:00
2015-10-26 09:10:56 +01:00
2015-09-30 17:37:55 -04:00
2015-11-03 09:53:24 -07:00
2015-10-06 11:16:42 -07:00
2015-10-06 11:16:42 -07:00
2015-10-06 11:16:42 -07:00
2015-11-05 19:34:48 -08:00
2015-11-05 23:10:54 -08:00
2015-10-23 14:19:58 +01:00
2015-10-04 12:46:06 +01:00
2015-11-06 17:50:42 -08:00
2015-11-06 17:50:42 -08:00
2015-11-06 17:50:42 -08:00
2015-11-06 17:50:42 -08:00
2015-10-20 22:10:45 +08:00
2015-10-16 13:07:16 +01:00
2015-10-17 21:11:29 -07:00
2015-10-08 05:26:35 -07:00
2015-11-03 11:29:57 -05:00
2015-11-04 11:30:22 -08:00
2015-09-29 20:21:32 +02:00
2015-09-30 01:45:03 -05:00
2015-10-16 18:45:36 +02:00
2015-11-05 19:34:48 -08:00
2015-10-09 10:40:37 -06:00
2015-10-16 22:49:26 +02:00
2015-10-16 13:07:15 +01:00
2015-10-28 10:05:58 -07:00
2015-10-08 05:26:36 -07:00
2015-11-05 19:34:48 -08:00
2015-11-06 17:50:42 -08:00
2015-11-06 17:50:42 -08:00
2015-11-06 17:50:42 -08:00
2015-10-16 22:18:51 +02:00
2015-10-06 11:25:31 -07:00
2015-10-23 05:57:43 -07:00
2015-10-05 05:02:40 +01:00
2015-10-28 04:33:04 +01:00
2015-10-14 02:17:34 +02:00
2015-10-01 09:59:16 -07:00
2015-10-21 14:46:56 -06:00
2015-10-06 17:08:19 +02:00
2015-09-25 02:00:19 +02:00
2015-10-22 08:59:18 -07:00
2015-11-03 11:08:22 -05:00
2015-10-30 11:18:05 +09:00
2015-10-08 05:26:38 -07:00
2015-11-06 17:50:42 -08:00
2015-10-06 11:25:45 -07:00
2015-10-06 11:16:18 -07:00
2015-10-06 11:16:31 -07:00
2015-10-06 11:08:23 -07:00
2015-10-06 11:08:05 -07:00
2015-10-12 19:25:07 +01:00
2015-10-09 07:49:06 -07:00
2015-11-05 23:10:54 -08:00
2015-10-04 12:54:54 +01:00
2015-10-27 19:55:13 -07:00
2015-11-06 17:50:42 -08:00
2015-11-05 19:34:48 -08:00
2015-10-20 10:23:55 +02:00
2015-10-06 11:15:43 -07:00
2015-10-04 20:28:58 +01:00
2015-10-20 10:23:55 +02:00
2015-10-14 02:17:33 +02:00
2015-11-05 19:34:48 -08:00
2015-10-19 01:01:19 +02:00
2015-10-21 14:42:38 -06:00
2015-10-22 06:22:13 -07:00
2015-10-01 09:59:01 -07:00
2015-10-01 09:57:59 -07:00
2015-10-19 01:01:21 +02:00
2015-11-05 19:34:48 -08:00
2015-10-17 21:32:21 -07:00
2015-11-05 19:34:48 -08:00
2015-11-05 19:34:48 -08:00
2015-10-04 10:34:17 +01:00
2015-11-05 19:34:48 -08:00
2015-11-01 17:09:15 -08:00
2015-10-17 22:03:00 -07:00
2015-11-05 19:34:48 -08:00
2015-09-22 15:09:53 -07:00
2015-11-06 17:50:42 -08:00
2015-11-06 17:50:42 -08:00