Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1504162 > unrolled thread

[PATCH 3/5] lib: radix-tree: native accounting and tracking of special entries

Started byJohannes Weiner <hannes@cmpxchg.org>
First post2016-10-19 19:30 +0200
Last post2016-10-24 18:10 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 3/5] lib: radix-tree: native accounting and tracking of special entries Johannes Weiner <hannes@cmpxchg.org> - 2016-10-19 19:30 +0200
    Re: [PATCH 3/5] lib: radix-tree: native accounting and tracking of  special entries Dave Chinner <david@fromorbit.com> - 2016-10-21 00:40 +0200
      Re: [PATCH 3/5] lib: radix-tree: native accounting and tracking of  special entries Johannes Weiner <hannes@cmpxchg.org> - 2016-10-24 18:10 +0200

#1504162 — [PATCH 3/5] lib: radix-tree: native accounting and tracking of special entries

FromJohannes Weiner <hannes@cmpxchg.org>
Date2016-10-19 19:30 +0200
Subject[PATCH 3/5] lib: radix-tree: native accounting and tracking of special entries
Message-ID<su2QF-4lW-25@gated-at.bofh.it>
Add an internal tag to identify special entries that are accounted in
node->special in addition to node->count.

With this in place, the next patch can restore refault detection in
single-page files. It will also move the shadow count from the upper
bits of count to the new special counter, and then shrink count to a
char as well; the growth of struct radix_tree_node is temporary.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 include/linux/radix-tree.h | 10 ++++++----
 lib/radix-tree.c           | 14 ++++++++++----
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index 756b2909467e..2e1c9added23 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -68,7 +68,8 @@ enum radix_tree_tags {
 	/* Freely allocatable radix tree user tags */
 	RADIX_TREE_NR_USER_TAGS = 3,
 	/* Radix tree internal tags */
-	RADIX_TREE_NR_TAGS = RADIX_TREE_NR_USER_TAGS,
+	RADIX_TREE_TAG_SPECIAL = RADIX_TREE_NR_USER_TAGS,
+	RADIX_TREE_NR_TAGS,
 };
 
 #ifndef RADIX_TREE_MAP_SHIFT
@@ -90,9 +91,10 @@ enum radix_tree_tags {
 #define RADIX_TREE_COUNT_MASK	((1UL << RADIX_TREE_COUNT_SHIFT) - 1)
 
 struct radix_tree_node {
-	unsigned char	shift;	/* Bits remaining in each slot */
-	unsigned char	offset;	/* Slot offset in parent */
-	unsigned int	count;
+	unsigned char	shift;		/* Bits remaining in each slot */
+	unsigned char	offset;		/* Slot offset in parent */
+	unsigned int	count;		/* Total entry count */
+	unsigned char	special;	/* Special entry count */
 	union {
 		struct {
 			/* Used when ascending tree */
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index bb6ddfb60557..e58cff1d97ed 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -220,10 +220,10 @@ static void dump_node(struct radix_tree_node *node, unsigned long index)
 {
 	unsigned long i;
 
-	pr_debug("radix node: %p offset %d tags %lx %lx %lx shift %d count %d parent %p\n",
+	pr_debug("radix node: %p offset %d tags %lx %lx %lx shift %d count %d special %d parent %p\n",
 		node, node->offset,
 		node->tags[0][0], node->tags[1][0], node->tags[2][0],
-		node->shift, node->count, node->parent);
+		node->shift, node->count, node->special, node->parent);
 
 	for (i = 0; i < RADIX_TREE_MAP_SIZE; i++) {
 		unsigned long first = index | (i << node->shift);
@@ -522,9 +522,15 @@ static int radix_tree_extend(struct radix_tree_root *root,
 		node->offset = 0;
 		node->count = 1;
 		node->parent = NULL;
-		if (radix_tree_is_internal_node(slot))
-			entry_to_node(slot)->parent = node;
 		node->slots[0] = slot;
+		/* Extending an existing node or root->rnode? */
+		if (radix_tree_is_internal_node(slot)) {
+			entry_to_node(slot)->parent = node;
+		} else {
+			/* Moving a special root->rnode to a node */
+			if (root_tag_get(root, RADIX_TREE_TAG_SPECIAL))
+				node->special = 1;
+		}
 		slot = node_to_entry(node);
 		rcu_assign_pointer(root->rnode, slot);
 		shift += RADIX_TREE_MAP_SHIFT;
-- 
2.10.0

[toc] | [next] | [standalone]


#1505305 — Re: [PATCH 3/5] lib: radix-tree: native accounting and tracking of special entries

FromDave Chinner <david@fromorbit.com>
Date2016-10-21 00:40 +0200
SubjectRe: [PATCH 3/5] lib: radix-tree: native accounting and tracking of special entries
Message-ID<suuae-5fM-7@gated-at.bofh.it>
In reply to#1504162
On Wed, Oct 19, 2016 at 01:24:26PM -0400, Johannes Weiner wrote:
> Add an internal tag to identify special entries that are accounted in
> node->special in addition to node->count.
> 
> With this in place, the next patch can restore refault detection in
> single-page files. It will also move the shadow count from the upper
> bits of count to the new special counter, and then shrink count to a
> char as well; the growth of struct radix_tree_node is temporary.
> 
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
> ---
>  include/linux/radix-tree.h | 10 ++++++----
>  lib/radix-tree.c           | 14 ++++++++++----
>  2 files changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
> index 756b2909467e..2e1c9added23 100644
> --- a/include/linux/radix-tree.h
> +++ b/include/linux/radix-tree.h
> @@ -68,7 +68,8 @@ enum radix_tree_tags {
>  	/* Freely allocatable radix tree user tags */
>  	RADIX_TREE_NR_USER_TAGS = 3,
>  	/* Radix tree internal tags */
> -	RADIX_TREE_NR_TAGS = RADIX_TREE_NR_USER_TAGS,
> +	RADIX_TREE_TAG_SPECIAL = RADIX_TREE_NR_USER_TAGS,
> +	RADIX_TREE_NR_TAGS,
>  };
>  
>  #ifndef RADIX_TREE_MAP_SHIFT
> @@ -90,9 +91,10 @@ enum radix_tree_tags {
>  #define RADIX_TREE_COUNT_MASK	((1UL << RADIX_TREE_COUNT_SHIFT) - 1)
>  
>  struct radix_tree_node {
> -	unsigned char	shift;	/* Bits remaining in each slot */
> -	unsigned char	offset;	/* Slot offset in parent */
> -	unsigned int	count;
> +	unsigned char	shift;		/* Bits remaining in each slot */
> +	unsigned char	offset;		/* Slot offset in parent */
> +	unsigned int	count;		/* Total entry count */
> +	unsigned char	special;	/* Special entry count */

How about putting the new char field into the implicit hole between
offset and count? pahole is your friend here:

struct radix_tree_node {
        unsigned char              shift;                /*     0     1 */
        unsigned char              offset;               /*     1     1 */

        /* XXX 2 bytes hole, try to pack */

        unsigned int               count;                /*     4     4 */
.....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

[toc] | [prev] | [next] | [standalone]


#1507350 — Re: [PATCH 3/5] lib: radix-tree: native accounting and tracking of special entries

FromJohannes Weiner <hannes@cmpxchg.org>
Date2016-10-24 18:10 +0200
SubjectRe: [PATCH 3/5] lib: radix-tree: native accounting and tracking of special entries
Message-ID<svPYZ-1uD-17@gated-at.bofh.it>
In reply to#1505305
Hi Dave,

On Fri, Oct 21, 2016 at 09:33:08AM +1100, Dave Chinner wrote:
> On Wed, Oct 19, 2016 at 01:24:26PM -0400, Johannes Weiner wrote:
> > With this in place, the next patch can restore refault detection in
> > single-page files. It will also move the shadow count from the upper
> > bits of count to the new special counter, and then shrink count to a
> > char as well; the growth of struct radix_tree_node is temporary.

[...]

> > @@ -90,9 +91,10 @@ enum radix_tree_tags {
> >  #define RADIX_TREE_COUNT_MASK	((1UL << RADIX_TREE_COUNT_SHIFT) - 1)
> >  
> >  struct radix_tree_node {
> > -	unsigned char	shift;	/* Bits remaining in each slot */
> > -	unsigned char	offset;	/* Slot offset in parent */
> > -	unsigned int	count;
> > +	unsigned char	shift;		/* Bits remaining in each slot */
> > +	unsigned char	offset;		/* Slot offset in parent */
> > +	unsigned int	count;		/* Total entry count */
> > +	unsigned char	special;	/* Special entry count */
> 
> How about putting the new char field into the implicit hole between
> offset and count? pahole is your friend here:
> 
> struct radix_tree_node {
>         unsigned char              shift;                /*     0     1 */
>         unsigned char              offset;               /*     1     1 */
> 
>         /* XXX 2 bytes hole, try to pack */
> 
>         unsigned int               count;                /*     4     4 */
> .....

The next patch turns `count' into an unsigned char again, so the hole
is only temporary.

Thanks

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web