Received: by 10.223.164.202 with SMTP id h10csp669466wrb; Wed, 22 Nov 2017 13:24:38 -0800 (PST) X-Google-Smtp-Source: AGs4zMYPyrvTtjaFUgm6Wh6WX6zx3ZdALJYgu9SkKh4vs7KQYoysgrx/8szM8Zw8KAPw6mjw//kX X-Received: by 10.99.0.86 with SMTP id 83mr22076342pga.326.1511385878045; Wed, 22 Nov 2017 13:24:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511385878; cv=none; d=google.com; s=arc-20160816; b=O6isDZrOqGTXmAqZqydKhlajn5VdACyfDp+I+7o8uq3Uc4CAKrHjfK0C2rxs1j9lWa 96ElMwgIpJlMCmYH0as2yDrQCPBT9PX2kzVt8hhR+ZvwwnWDxt2khjTWKZjZvE20Snuh lGPdH6b2wiwrY7xTBhSI+D/mh4xwxkpYgSdF+ASX14Y8ngG5lvXsNykt49mzsGS+dcNI br2eyU0sni8sayS6xZXCEtyq6BqWe1jwH/kd+rofKcKK/QJ9CL7OEwIDE/VuO5LmS1O4 hwUKQg4lE9Vf3AV/xAxrvOFPD+g0etmqR6n4PlWJfVWzKjacwk9aBEokeCceROmYj+TS UEHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=FHEmUEWW794MwpIbCz1WovibfFsAKunVV6SCY5ewLPE=; b=R3SI3nDhBbLvjYis4V7PqIMGjUD29YXyCCTWNfK0X/08FJ22UqK7WeDE90Gc0yeEIB rAYks+kvbW8V4Yh3T/lry1pxrmW9ThIBc2akzEQZIGZD1k43Ar298B/rMXI+/oArGYwv aJj1wzzqqAWPgA8JSHLanISiKhWE9nHn4x+onQ9MewLk+ZEeXB6RWjvg8+1pCn0G3Sb3 cx1L+uBR88pKqXnlgXxavhC3N59wq4urI2qq3cNKt9Vvicxw801szb66bb0fcTSRbC+/ U9f5RteKuHox34USP2OXRe++KIJgifMUf/2SbF8gBvfoNuxMDvD9qwqYqVX18Lta0bt1 BmyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=FJewljfp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q17si15555110pfj.31.2017.11.22.13.24.26; Wed, 22 Nov 2017 13:24:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=FJewljfp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752359AbdKVVW0 (ORCPT + 77 others); Wed, 22 Nov 2017 16:22:26 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:38736 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751748AbdKVVIR (ORCPT ); Wed, 22 Nov 2017 16:08:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FHEmUEWW794MwpIbCz1WovibfFsAKunVV6SCY5ewLPE=; b=FJewljfperD+bsZtl7BRcVxcr sr1+WUYV2qKgO6VnaHU1mqdZIh4RfsMBqSoZeutpTnOhrNRHndPD/lnnZLFxx/sIVPZwVuMe602Ja YuQhNsly8UzEc3Zrv4OVViz4FeTC6R5wfBOSzAaH2L6Z4coO5XuU1ZbwSlaRs9+AuSQlF7XAq3aqU sAUilxypqaXehvwr/5Pnw1F6cRL2YGV5bn6r2thzjqFtlJswPI7coci8xut+Lg/4wwnzt3+tqIuZv kF0/BFPxe9CpJoXiWItsny6W9DHm7XSwIzCi/N/PEu0rcR9yRr1cknm93GA0JXlYOHbY4+ZWE7Nl+ Ym4RzaBQQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.87 #1 (Red Hat Linux)) id 1eHcFl-0007tT-5N; Wed, 22 Nov 2017 21:08:17 +0000 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox Subject: [PATCH 19/62] xarray: Define struct xa_node Date: Wed, 22 Nov 2017 13:06:56 -0800 Message-Id: <20171122210739.29916-20-willy@infradead.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171122210739.29916-1-willy@infradead.org> References: <20171122210739.29916-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Wilcox This is a direct replacement for struct radix_tree_node. Use a #define so that radix tree users continue to work without change. Signed-off-by: Matthew Wilcox --- include/linux/radix-tree.h | 29 +++-------------------------- include/linux/xarray.h | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h index 015bc1bdc3d2..1da1fb01e993 100644 --- a/include/linux/radix-tree.h +++ b/include/linux/radix-tree.h @@ -32,6 +32,7 @@ /* Keep unconverted code working */ #define radix_tree_root xarray +#define radix_tree_node xa_node /* * The bottom two bits of the slot determine how the remaining bits in the @@ -60,41 +61,17 @@ static inline bool radix_tree_is_internal_node(void *ptr) /*** radix-tree API starts here ***/ -#define RADIX_TREE_MAX_TAGS 3 - #define RADIX_TREE_MAP_SHIFT XA_CHUNK_SHIFT #define RADIX_TREE_MAP_SIZE (1UL << RADIX_TREE_MAP_SHIFT) #define RADIX_TREE_MAP_MASK (RADIX_TREE_MAP_SIZE-1) -#define RADIX_TREE_TAG_LONGS \ - ((RADIX_TREE_MAP_SIZE + BITS_PER_LONG - 1) / BITS_PER_LONG) +#define RADIX_TREE_MAX_TAGS XA_MAX_TAGS +#define RADIX_TREE_TAG_LONGS XA_TAG_LONGS #define RADIX_TREE_INDEX_BITS (8 /* CHAR_BIT */ * sizeof(unsigned long)) #define RADIX_TREE_MAX_PATH (DIV_ROUND_UP(RADIX_TREE_INDEX_BITS, \ RADIX_TREE_MAP_SHIFT)) -/* - * @count is the count of every non-NULL element in the ->slots array - * whether that is a data entry, a retry entry, a user pointer, - * a sibling entry or a pointer to the next level of the tree. - * @exceptional is the count of every element in ->slots which is - * either a data entry or a sibling entry for data. - */ -struct radix_tree_node { - unsigned char shift; /* Bits remaining in each slot */ - unsigned char offset; /* Slot offset in parent */ - unsigned char count; /* Total entry count */ - unsigned char exceptional; /* Exceptional entry count */ - struct radix_tree_node *parent; /* Used when ascending tree */ - struct radix_tree_root *root; /* The tree we belong to */ - union { - struct list_head private_list; /* For tree user */ - struct rcu_head rcu_head; /* Used when freeing node */ - }; - void __rcu *slots[RADIX_TREE_MAP_SIZE]; - unsigned long tags[RADIX_TREE_MAX_TAGS][RADIX_TREE_TAG_LONGS]; -}; - /* The top bits of xa_flags are used to store the root tags and the IDR flag */ #define ROOT_IS_IDR ((__force gfp_t)(1 << __GFP_BITS_SHIFT)) #define ROOT_TAG_SHIFT (__GFP_BITS_SHIFT + 1) diff --git a/include/linux/xarray.h b/include/linux/xarray.h index 03d430ec3bce..1513a9e85580 100644 --- a/include/linux/xarray.h +++ b/include/linux/xarray.h @@ -143,6 +143,30 @@ static inline bool xa_is_value(void *entry) #endif #define XA_CHUNK_SIZE (1UL << XA_CHUNK_SHIFT) #define XA_CHUNK_MASK (XA_CHUNK_SIZE - 1) +#define XA_MAX_TAGS 3 +#define XA_TAG_LONGS DIV_ROUND_UP(XA_CHUNK_SIZE, BITS_PER_LONG) + +/* + * @count is the count of every non-NULL element in the ->slots array + * whether that is a data entry, a retry entry, a user pointer, + * a sibling entry or a pointer to the next level of the tree. + * @exceptional is the count of every element in ->slots which is + * either a data entry or a sibling entry for data. + */ +struct xa_node { + unsigned char shift; /* Bits remaining in each slot */ + unsigned char offset; /* Slot offset in parent */ + unsigned char count; /* Total entry count */ + unsigned char exceptional; /* Exceptional entry count */ + struct xa_node *parent; /* Used when ascending tree */ + struct xarray * root; /* The tree we belong to */ + union { + struct list_head private_list; /* For tree user */ + struct rcu_head rcu_head; /* Used when freeing node */ + }; + void __rcu *slots[XA_CHUNK_SIZE]; + unsigned long tags[XA_MAX_TAGS][XA_TAG_LONGS]; +}; /* * Internal entries have the bottom two bits set to the value 10b. Most -- 2.15.0 From 1584868397684992671@xxx Thu Nov 23 14:44:45 +0000 2017 X-GM-THRID: 1584868397684992671 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread