From: Peter Zijlstra <peterz@infradead.org>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: mingo@kernel.org, tglx@linutronix.de, walken@google.com,
akpm@linux-foundation.org, x86@kernel.org,
linux-kernel@vger.kernel.org, Davidlohr Bueso <dbueso@suse.de>
Subject: Re: [PATCH 1/3] x86,mm/pat: Use generic interval trees
Date: Wed, 21 Aug 2019 18:03:47 +0200 [thread overview]
Message-ID: <20190821160347.GB2332@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20190813224620.31005-2-dave@stgolabs.net>
On Tue, Aug 13, 2019 at 03:46:18PM -0700, Davidlohr Bueso wrote:
> diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
> index fa16036fa592..1be4d1856a9b 100644
> --- a/arch/x86/mm/pat_rbtree.c
> +++ b/arch/x86/mm/pat_rbtree.c
> @@ -34,68 +34,41 @@
> * memtype_lock protects the rbtree.
> */
>
> +static struct rb_root_cached memtype_rbroot = RB_ROOT_CACHED;
> +
> +#define START(node) ((node)->start)
> +#define END(node) ((node)->end)
Afaict these could actually be inlines, but I see other interval tree
users also use macros for them, albeit with END called LAST.
> +INTERVAL_TREE_DEFINE(struct memtype, rb, u64, subtree_max_end,
> + START, END, static, memtype_interval)
>
> static int is_node_overlap(struct memtype *node, u64 start, u64 end)
> {
> + /*
> + * Unlike generic interval trees, the memtype nodes are ]a, b[
> + * therefore we need to adjust the ranges accordingly. Missing
> + * an overlap can lead to incorrectly detecting conflicts,
> + * for example.
> + */
> + if (node->start + 1 >= end || node->end - 1 <= start)
> return 0;
>
> return 1;
> }
I've not looked yet; but how horrible would it be to change that
weirdness?
> @@ -149,10 +116,8 @@ static int memtype_rb_check_conflict(struct rb_root *root,
> dprintk("Overlap at 0x%Lx-0x%Lx\n", match->start, match->end);
> found_type = match->type;
>
> + match = memtype_interval_iter_next(match, start, end);
> + while (match) {
whilespace fail
> if (match->start >= end) /* Checked all possible matches */
> goto success;
>
> @@ -176,43 +141,21 @@ static int memtype_rb_check_conflict(struct rb_root *root,
> return -EBUSY;
> }
>
> int rbt_memtype_check_insert(struct memtype *new,
> enum page_cache_mode *ret_type)
> {
> + int err;
>
> + err = memtype_rb_check_conflict(&memtype_rbroot,
> + new->start, new->end,
> + new->type, ret_type);
whitespace fail
> + if (err)
> + return err;
>
> + if (ret_type)
> + new->type = *ret_type;
>
> + memtype_interval_insert(new, &memtype_rbroot);
> return err;
> }
>
next prev parent reply other threads:[~2019-08-21 16:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-13 22:46 [PATCH -tip 0/3] x86,mm/pat: Move towards using " Davidlohr Bueso
2019-08-13 22:46 ` [PATCH 1/3] x86,mm/pat: Use " Davidlohr Bueso
2019-08-21 16:03 ` Peter Zijlstra [this message]
2019-08-21 21:57 ` Michel Lespinasse
2019-08-22 4:49 ` Davidlohr Bueso
2019-08-22 18:17 ` Davidlohr Bueso
2019-08-22 20:10 ` Michel Lespinasse
2019-09-05 0:52 ` Davidlohr Bueso
2019-09-05 2:00 ` Michel Lespinasse
2019-09-05 3:45 ` Davidlohr Bueso
2019-09-05 5:03 ` Davidlohr Bueso
2019-08-22 20:24 ` Michel Lespinasse
2019-08-13 22:46 ` [PATCH 2/3] x86,mm/pat: Cleanup some of the local memtype_rb_* calls Davidlohr Bueso
2019-08-13 22:46 ` [PATCH 3/3] x86,mm/pat: Rename pat_rbtree.c to pat_interval.c Davidlohr Bueso
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=20190821160347.GB2332@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=dave@stgolabs.net \
--cc=dbueso@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=walken@google.com \
--cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome