[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CANN689HQ9UyWTgvj-i-Xuc-trHfAuy5PuaL=C5QZh-YOQ2Z=DQ@mail.gmail.com>
Date: Mon, 1 Jul 2019 17:25:44 -0700
From: Michel Lespinasse <walken@...gle.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Davidlohr Bueso <dave@...olabs.net>,
David Howells <dhowells@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] augmented rbtree: rework the RB_DECLARE_CALLBACKS
macro definition
I don't like adding additional levels of macros to build the augmented
rbtree callbacks. OTOH, all of the existing callbacks compute the max
(within the subtree) of a per-node scalar property. So, I guess I
could do a RB_DECLARE_MAX_CALLBACKS, and one of its arguments would
tell it how to compute the per-node scalar property, and it would
generate the code that both computes the max within the subtree and
assigns it into the augmented variable for the subtree's root. I will
prepare a v2 version of this patchset that does that.
On Mon, Jul 1, 2019 at 7:40 AM Peter Zijlstra <peterz@...radead.org> wrote:
>
> On Mon, Jul 01, 2019 at 09:46:30AM +0200, Peter Zijlstra wrote:
> > On Fri, Jun 28, 2019 at 05:49:52PM -0700, Michel Lespinasse wrote:
>
> > > The motivation for this change is that I want to introduce augmented rbtree
> > > uses where the augmented data for the subtree is a struct instead of a scalar.
>
> > Can't we have a helper macro that converts an old (scalar) style compute
> > into a new style compute and avoid this unfortunate and error prone
> > copy/pasta ?
>
> Or add a RBEQUAL argument that does:
>
> - if (node->RBAUGMENTED == augmented)
> + if (RBEQUAL(&node->RBAUGMENTED, &augmented))
>
> With a bit of foo you can even provide a default implementation that
> does: *a == *b.
>
> See GEN_UNARY_RMWcc() for how to do that.
--
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.
Powered by blists - more mailing lists