From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4CC2C433B4 for ; Fri, 14 May 2021 13:42:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6C8206145A for ; Fri, 14 May 2021 13:42:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6C8206145A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C6CB56B0036; Fri, 14 May 2021 09:42:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF5D16B006E; Fri, 14 May 2021 09:42:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A21B56B0070; Fri, 14 May 2021 09:42:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0076.hostedemail.com [216.40.44.76]) by kanga.kvack.org (Postfix) with ESMTP id 6B6D86B0036 for ; Fri, 14 May 2021 09:42:19 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id EDD22A765 for ; Fri, 14 May 2021 13:42:18 +0000 (UTC) X-FDA: 78139950756.04.66742ED Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf05.hostedemail.com (Postfix) with ESMTP id 0EE4DE000101 for ; Fri, 14 May 2021 13:42:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=WeqnDueLL3Y7hUYBnonhmaWEvwFWa7jko0cCO3KQkUI=; b=LtjvynKQHt3b+rUBpH5xd2fmAy B3S2sTGMSlz5ZFgm1kHxSU3VRX4cEhXKagcJpqZ+qWobpAeD+QkfULdzsdN80oLKnwOPk5OuQShUr 6jSTOEBk0hwY1FyJfVnVxMUnh7u3MBAkKiFlJRmjqFA0B/KbU2CEFbsQ4+rOn6tkaAntCjBlQX2IX cStWdyzwyjBeGMiXP3nqu1iloA2mUReXvQXF3QsZAeZ7uxG/lHCcgZ+IlHDOTsZTnKOq3oycj8ahn 1CFs/XlApHhXvigg5NogZQLOslr8nga1MlN03JHZowYWEQBe7BXqoUbPutqChwKL+XCLf7IuKfxcJ B82pLEOg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lhY4s-008ABK-QI; Fri, 14 May 2021 13:42:06 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 0DF3830022A; Fri, 14 May 2021 15:42:05 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id EA5C82BE0F873; Fri, 14 May 2021 15:42:04 +0200 (CEST) Date: Fri, 14 May 2021 15:42:04 +0200 From: Peter Zijlstra To: Liam Howlett Cc: "maple-tree@lists.infradead.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Andrew Morton , Song Liu , Davidlohr Bueso , "Paul E . McKenney" , Matthew Wilcox , Laurent Dufour , David Rientjes , Axel Rasmussen , Suren Baghdasaryan , Vlastimil Babka , Rik van Riel , Michel Lespinasse Subject: Re: [PATCH 26/94] Maple Tree: Add new data structure Message-ID: References: <20210428153542.2814175-1-Liam.Howlett@Oracle.com> <20210428153542.2814175-27-Liam.Howlett@Oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210428153542.2814175-27-Liam.Howlett@Oracle.com> Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=LtjvynKQ; dmarc=none; spf=none (imf05.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 0EE4DE000101 X-Stat-Signature: 9hwb7f9p54utm5dru47aha4fu5z6gqww X-HE-Tag: 1620999736-19721 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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); > +}