[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YJ5+LN7FlNjAXQi0@hirez.programming.kicks-ass.net>
Date: Fri, 14 May 2021 15:42:04 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Liam Howlett <liam.howlett@...cle.com>
Cc: "maple-tree@...ts.infradead.org" <maple-tree@...ts.infradead.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Song Liu <songliubraving@...com>,
Davidlohr Bueso <dave@...olabs.net>,
"Paul E . McKenney" <paulmck@...nel.org>,
Matthew Wilcox <willy@...radead.org>,
Laurent Dufour <ldufour@...ux.ibm.com>,
David Rientjes <rientjes@...gle.com>,
Axel Rasmussen <axelrasmussen@...gle.com>,
Suren Baghdasaryan <surenb@...gle.com>,
Vlastimil Babka <vbabka@...e.cz>,
Rik van Riel <riel@...riel.com>,
Michel Lespinasse <walken.cr@...il.com>
Subject: Re: [PATCH 26/94] Maple Tree: Add new data structure
On Wed, Apr 28, 2021 at 03:36:02PM +0000, Liam Howlett wrote:
> +/*
> + * mte_set_parent() - Set the parent node and encode the slot.
> + * @enode: The encoded maple node.
> + * @parent: The encoded maple node that is the parent of @enode.
> + * @slot: The slot that @enode resides in @parent.
> + *
> + * Type is encoded in the enode->parent
> + * bit 0: 1 = root, 0 otherwise
> + * bit 1: Reserved.
> + * bit 2: 0 = range 32, 1 = [a]range 64
> + *
> + * Slot number is encoded in the enode->parent
> + * range_32, slot number is encoded in bits 3-6
> + * [a]range_64, slot number is encoded in bits 3-6
> + */
> +static inline void mte_set_parent(struct maple_enode *enode,
> + const struct maple_enode *parent,
> + unsigned char slot)
> +{
> + unsigned long bitmask = 0x78;
> + unsigned long val = (unsigned long) parent;
> + unsigned long type = 0;
> +
> + switch (mte_node_type(parent)) {
> + case maple_range_64:
> + case maple_arange_64:
> + type = 6;
6 = 4 + 2, which has bit1 set, but the above sayeth bit1 is reserved.
It is also mighty confusing to have two different type fields, is there
no way we can merge the types into a single (shared) space?
> + break;
> + default:
> + break;
> + }
> +
> + val &= ~bitmask; // Remove any old slot number.
> + val |= (slot << MAPLE_PARENT_SHIFT); // Set the slot.
> + val |= type;
> + mte_to_node(enode)->parent = ma_parent_ptr(val);
> +}
Powered by blists - more mailing lists