All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Cc: alex.bennee@linaro.org, laurent@vivier.eu
Subject: Re: [PATCH v3 1/8] util: Add interval-tree.c
Date: Fri, 9 Dec 2022 09:35:09 +0100	[thread overview]
Message-ID: <a636bdab-b092-522c-f374-de48074ee51a@linaro.org> (raw)
In-Reply-To: <20221209051914.398215-2-richard.henderson@linaro.org>

On 9/12/22 06:19, Richard Henderson wrote:
> Copy and simplify the Linux kernel's interval_tree_generic.h,
> instantiating for uint64_t.
> 
> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   include/qemu/interval-tree.h    |  99 ++++
>   tests/unit/test-interval-tree.c | 209 ++++++++
>   util/interval-tree.c            | 882 ++++++++++++++++++++++++++++++++
>   tests/unit/meson.build          |   1 +
>   util/meson.build                |   1 +
>   5 files changed, 1192 insertions(+)
>   create mode 100644 include/qemu/interval-tree.h
>   create mode 100644 tests/unit/test-interval-tree.c
>   create mode 100644 util/interval-tree.c
> 
> diff --git a/include/qemu/interval-tree.h b/include/qemu/interval-tree.h
> new file mode 100644
> index 0000000000..25006debe8
> --- /dev/null
> +++ b/include/qemu/interval-tree.h
> @@ -0,0 +1,99 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Interval trees.
> + *
> + * Derived from include/linux/interval_tree.h and its dependencies.
> + */
> +
> +#ifndef QEMU_INTERVAL_TREE_H
> +#define QEMU_INTERVAL_TREE_H

> +
> +#endif /* QEMU_INTERVAL_TREE_H */
> diff --git a/tests/unit/test-interval-tree.c b/tests/unit/test-interval-tree.c
> new file mode 100644
> index 0000000000..119817a019
> --- /dev/null
> +++ b/tests/unit/test-interval-tree.c



> +/* Occasionally useful for calling from within the debugger. */
> +#if 0
> +static void debug_interval_tree_int(IntervalTreeNode *node,
> +                                    const char *dir, int level)
> +{
> +    printf("%4d %*s %s [%" PRIu64 ",%" PRIu64 "] subtree_last:%" PRIu64 "\n",
> +           level, level + 1, dir, rb_is_red(&node->rb) ? "r" : "b",
> +           node->start, node->last, node->subtree_last);
> +
> +    if (node->rb.rb_left) {
> +        debug_interval_tree_int(rb_to_itree(node->rb.rb_left), "<", level + 1);
> +    }
> +    if (node->rb.rb_right) {
> +        debug_interval_tree_int(rb_to_itree(node->rb.rb_right), ">", level + 1);
> +    }
> +}
> +
> +void debug_interval_tree(IntervalTreeNode *node);

If you think this function is helpful, shouldn't we declare it in the
header within CONFIG_DEBUG_TCG guards?

> +void debug_interval_tree(IntervalTreeNode *node)
> +{
> +    if (node) {
> +        debug_interval_tree_int(node, "*", 0);
> +    } else {
> +        printf("null\n");
> +    }
> +}
> +#endif


  reply	other threads:[~2022-12-09  8:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-09  5:19 [PATCH v3 0/8] accel/tcg: Rewrite user-only vma tracking Richard Henderson
2022-12-09  5:19 ` [PATCH v3 1/8] util: Add interval-tree.c Richard Henderson
2022-12-09  8:35   ` Philippe Mathieu-Daudé [this message]
2022-12-09  5:19 ` [PATCH v3 2/8] accel/tcg: Rename page_flush_tb Richard Henderson
2022-12-09  7:09   ` Philippe Mathieu-Daudé
2022-12-16 11:52   ` Alex Bennée
2022-12-09  5:19 ` [PATCH v3 3/8] accel/tcg: Use interval tree for TBs in user-only mode Richard Henderson
2022-12-09  5:19 ` [PATCH v3 4/8] accel/tcg: Use interval tree for TARGET_PAGE_DATA_SIZE Richard Henderson
2022-12-16 11:59   ` Alex Bennée
2022-12-09  5:19 ` [PATCH v3 5/8] accel/tcg: Move page_{get,set}_flags to user-exec.c Richard Henderson
2022-12-09  7:13   ` Philippe Mathieu-Daudé
2022-12-09  5:19 ` [PATCH v3 6/8] accel/tcg: Use interval tree for user-only page tracking Richard Henderson
2022-12-09  7:18   ` Philippe Mathieu-Daudé
2022-12-16 12:03     ` Alex Bennée
2022-12-09  5:19 ` [PATCH v3 7/8] accel/tcg: Move PageDesc tree into tb-maint.c for system Richard Henderson
2022-12-09  7:22   ` Philippe Mathieu-Daudé
2022-12-12 15:28     ` Richard Henderson
2022-12-12 18:19       ` Philippe Mathieu-Daudé
2022-12-09  9:28   ` Philippe Mathieu-Daudé
2022-12-09  5:19 ` [PATCH v3 8/8] accel/tcg: Move remainder of page locking to tb-maint.c Richard Henderson

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=a636bdab-b092-522c-f374-de48074ee51a@linaro.org \
    --to=philmd@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.