From: Peter Zijlstra <peterz@infradead.org>
To: Michel Lespinasse <walken@google.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>,
David Howells <dhowells@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] augmented rbtree: rework the RB_DECLARE_CALLBACKS macro definition
Date: Mon, 1 Jul 2019 09:31:37 +0200 [thread overview]
Message-ID: <20190701073137.GL3402@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20190629004952.6611-3-walken@google.com>
On Fri, Jun 28, 2019 at 05:49:52PM -0700, Michel Lespinasse wrote:
> --- a/tools/include/linux/rbtree_augmented.h
> +++ b/tools/include/linux/rbtree_augmented.h
> @@ -74,39 +74,48 @@ rb_insert_augmented_cached(struct rb_node *node,
> newleft, &root->rb_leftmost, augment->rotate);
> }
>
> -#define RB_DECLARE_CALLBACKS(rbstatic, rbname, rbstruct, rbfield, \
> - rbtype, rbaugmented, rbcompute) \
> +/*
> + * Template for declaring augmented rbtree callbacks
> + *
> + * RBSTRUCT: struct type of the tree nodes
> + * RBFIELD: name of struct rb_node field within RBSTRUCT
> + * RBAUGMENTED: name of field within RBSTRUCT holding data for subtree
> + * RBCOMPUTE: name of function that recomputes the RBAUGMENTED data
> + * RBSTATIC: 'static' or empty
> + * RBNAME: name of the rb_augment_callbacks structure
> + */
> +
> +#define RB_DECLARE_CALLBACKS(RBSTRUCT, RBFIELD, RBAUGMENTED, RBCOMPUTE, \
> + RBSTATIC, RBNAME) \
> static inline void \
> -rbname ## _propagate(struct rb_node *rb, struct rb_node *stop) \
> +RBNAME ## _propagate(struct rb_node *rb, struct rb_node *stop) \
> { \
> while (rb != stop) { \
> - rbstruct *node = rb_entry(rb, rbstruct, rbfield); \
> - rbtype augmented = rbcompute(node); \
> - if (node->rbaugmented == augmented) \
> + RBSTRUCT *node = rb_entry(rb, RBSTRUCT, RBFIELD); \
> + if (RBCOMPUTE(node, true)) \
> break; \
> - node->rbaugmented = augmented; \
> - rb = rb_parent(&node->rbfield); \
> + rb = rb_parent(&node->RBFIELD); \
> } \
> } \
> static inline void \
> -rbname ## _copy(struct rb_node *rb_old, struct rb_node *rb_new) \
> +RBNAME ## _copy(struct rb_node *rb_old, struct rb_node *rb_new) \
> { \
> - rbstruct *old = rb_entry(rb_old, rbstruct, rbfield); \
> - rbstruct *new = rb_entry(rb_new, rbstruct, rbfield); \
> - new->rbaugmented = old->rbaugmented; \
> + RBSTRUCT *old = rb_entry(rb_old, RBSTRUCT, RBFIELD); \
> + RBSTRUCT *new = rb_entry(rb_new, RBSTRUCT, RBFIELD); \
> + new->RBAUGMENTED = old->RBAUGMENTED; \
> } \
> static void \
> -rbname ## _rotate(struct rb_node *rb_old, struct rb_node *rb_new) \
> +RBNAME ## _rotate(struct rb_node *rb_old, struct rb_node *rb_new) \
> { \
> - rbstruct *old = rb_entry(rb_old, rbstruct, rbfield); \
> - rbstruct *new = rb_entry(rb_new, rbstruct, rbfield); \
> - new->rbaugmented = old->rbaugmented; \
> - old->rbaugmented = rbcompute(old); \
> + RBSTRUCT *old = rb_entry(rb_old, RBSTRUCT, RBFIELD); \
> + RBSTRUCT *new = rb_entry(rb_new, RBSTRUCT, RBFIELD); \
> + new->RBAUGMENTED = old->RBAUGMENTED; \
> + RBCOMPUTE(old, false); \
> } \
> -rbstatic const struct rb_augment_callbacks rbname = { \
> - .propagate = rbname ## _propagate, \
> - .copy = rbname ## _copy, \
> - .rotate = rbname ## _rotate \
> +RBSTATIC const struct rb_augment_callbacks RBNAME = { \
> + .propagate = RBNAME ## _propagate, \
> + .copy = RBNAME ## _copy, \
> + .rotate = RBNAME ## _rotate \
> };
I'm thinking that should've been in the previous patch.
next prev parent reply other threads:[~2019-07-01 7:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-29 0:49 [PATCH 0/2] make RB_DECLARE_CALLBACKS more generic Michel Lespinasse
2019-06-29 0:49 ` [PATCH 1/2] augmented rbtree: add comments for RB_DECLARE_CALLBACKS macro Michel Lespinasse
2019-06-29 0:49 ` [PATCH 2/2] augmented rbtree: rework the RB_DECLARE_CALLBACKS macro definition Michel Lespinasse
2019-07-01 7:31 ` Peter Zijlstra [this message]
2019-07-01 7:46 ` Peter Zijlstra
2019-07-01 14:40 ` Peter Zijlstra
2019-07-02 0:25 ` Michel Lespinasse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190701073137.GL3402@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=dave@stgolabs.net \
--cc=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=walken@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®