Messages in this thread | | | Date | Thu, 30 Apr 2020 10:07:21 +0200 | From | Juri Lelli <> | Subject | Re: [RFC][PATCH 1/7] rbtree: Add generic add and find helpers |
| |
On 30/04/20 00:51, Michel Lespinasse wrote: > On Thu, Apr 30, 2020 at 12:28 AM Juri Lelli <juri.lelli@redhat.com> wrote: > > > --- a/include/linux/rbtree.h > > > +++ b/include/linux/rbtree.h > > > @@ -141,12 +141,18 @@ static inline void rb_insert_color_cache > > > rb_insert_color(node, &root->rb_root); > > > } > > > > > > -static inline void rb_erase_cached(struct rb_node *node, > > > +static inline bool rb_erase_cached(struct rb_node *node, > > > struct rb_root_cached *root) > > > { > > > - if (root->rb_leftmost == node) > > > + bool leftmost = false; > > > + > > > + if (root->rb_leftmost == node) { > > > root->rb_leftmost = rb_next(node); > > > > Think we need > > > > if (root->rb_leftmost) > > > > > + leftmost = true; > > > > DEADLINE crashes w/o that. > > I think Peter's code is correct; after removing the only node in an > rbtree rb_leftmost should be NULL.
Indeed, I've only got the idea that Peter was thinking of using rb_erase_cached return value as an indication that new rb_leftmost is not NULL (and for example perform an update in DEADLINE earliest_dl).
I also had the impression that DEADLINE is actually the only consumer of that return value and so we were able to define its semantic.
> The issue appears to be in dequeue_pushable_dl_task unconditionally > dereferencing the pointer returned by rb_first_cached(), which may be > NULL. I'm not sure what the correct behavior is though, i.e. what > dl_rq->earliest_dl.next should be set to if the rbtree ends up empty. > Current code (before Peter's changes) preserves the existing > dl_rq->earliest_dl.next value in that case, which seems very weird to > me (and worthy of a comment if it's correct).
But, yeah. Fixing things in DEADLINE code works for me as well. We could reset it to 0 (initial value), but I now actually wonder if places where that is consumed are actually OK. Different discussion, though. :-)
Thanks,
Juri
| |