diff mbox series

[v2,6/8] lib: move rbtree code

Message ID e16975d3-c34b-1b3f-743f-1abe13aa06f7@suse.com (mailing list archive)
State Superseded
Headers show
Series xen: beginnings of moving library-like code into an archive | expand

Commit Message

Jan Beulich Oct. 23, 2020, 10:18 a.m. UTC
Build this code into an archive, which results in not linking it into
x86 final binaries. This saves about 1.5k of dead code.

While moving the source file, take the opportunity and drop the
pointless EXPORT_SYMBOL().

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
 xen/common/Makefile          | 1 -
 xen/lib/Makefile             | 1 +
 xen/{common => lib}/rbtree.c | 9 +--------
 3 files changed, 2 insertions(+), 9 deletions(-)
 rename xen/{common => lib}/rbtree.c (98%)

Comments

Julien Grall Nov. 18, 2020, 5:46 p.m. UTC | #1
Hi Jan,

On 23/10/2020 11:18, Jan Beulich wrote:
> Build this code into an archive, which results in not linking it into
> x86 final binaries. This saves about 1.5k of dead code.
> 
> While moving the source file, take the opportunity and drop the
> pointless EXPORT_SYMBOL().

Given this code is borrowed from Linux, I don't think we want to remove 
them. This is to make easier to re-sync.

> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
>   xen/common/Makefile          | 1 -
>   xen/lib/Makefile             | 1 +
>   xen/{common => lib}/rbtree.c | 9 +--------
>   3 files changed, 2 insertions(+), 9 deletions(-)
>   rename xen/{common => lib}/rbtree.c (98%)
> 
> diff --git a/xen/common/Makefile b/xen/common/Makefile
> index 52d3c2aa9384..7bb779f780a1 100644
> --- a/xen/common/Makefile
> +++ b/xen/common/Makefile
> @@ -33,7 +33,6 @@ obj-y += preempt.o
>   obj-y += random.o
>   obj-y += rangeset.o
>   obj-y += radix-tree.o
> -obj-y += rbtree.o
>   obj-y += rcupdate.o
>   obj-y += rwlock.o
>   obj-y += shutdown.o
> diff --git a/xen/lib/Makefile b/xen/lib/Makefile
> index ba1fb7bcdee2..b469d2dff7b8 100644
> --- a/xen/lib/Makefile
> +++ b/xen/lib/Makefile
> @@ -4,3 +4,4 @@ obj-$(CONFIG_X86) += x86/
>   lib-y += ctype.o
>   lib-y += list-sort.o
>   lib-y += parse-size.o
> +lib-y += rbtree.o
> diff --git a/xen/common/rbtree.c b/xen/lib/rbtree.c
> similarity index 98%
> rename from xen/common/rbtree.c
> rename to xen/lib/rbtree.c
> index 9f5498a89d4e..95e045d52461 100644
> --- a/xen/common/rbtree.c
> +++ b/xen/lib/rbtree.c
> @@ -25,7 +25,7 @@
>   #include <xen/rbtree.h>
>   
>   /*
> - * red-black trees properties:  http://en.wikipedia.org/wiki/Rbtree
> + * red-black trees properties:  http://en.wikipedia.org/wiki/Rbtree

This looks like a spurious change.

>    *
>    *  1) A node is either red or black
>    *  2) The root is black
> @@ -223,7 +223,6 @@ void rb_insert_color(struct rb_node *node, struct rb_root *root)
>   		}
>   	}
>   }
> -EXPORT_SYMBOL(rb_insert_color);
>   
>   static void __rb_erase_color(struct rb_node *parent, struct rb_root *root)
>   {
> @@ -467,7 +466,6 @@ void rb_erase(struct rb_node *node, struct rb_root *root)
>   	if (rebalance)
>   		__rb_erase_color(rebalance, root);
>   }
> -EXPORT_SYMBOL(rb_erase);
>   
>   /*
>    * This function returns the first node (in sort order) of the tree.
> @@ -483,7 +481,6 @@ struct rb_node *rb_first(const struct rb_root *root)
>   		n = n->rb_left;
>   	return n;
>   }
> -EXPORT_SYMBOL(rb_first);
>   
>   struct rb_node *rb_last(const struct rb_root *root)
>   {
> @@ -496,7 +493,6 @@ struct rb_node *rb_last(const struct rb_root *root)
>   		n = n->rb_right;
>   	return n;
>   }
> -EXPORT_SYMBOL(rb_last);
>   
>   struct rb_node *rb_next(const struct rb_node *node)
>   {
> @@ -528,7 +524,6 @@ struct rb_node *rb_next(const struct rb_node *node)
>   
>   	return parent;
>   }
> -EXPORT_SYMBOL(rb_next);
>   
>   struct rb_node *rb_prev(const struct rb_node *node)
>   {
> @@ -557,7 +552,6 @@ struct rb_node *rb_prev(const struct rb_node *node)
>   
>   	return parent;
>   }
> -EXPORT_SYMBOL(rb_prev);
>   
>   void rb_replace_node(struct rb_node *victim, struct rb_node *new,
>   		     struct rb_root *root)
> @@ -574,4 +568,3 @@ void rb_replace_node(struct rb_node *victim, struct rb_node *new,
>   	/* Copy the pointers/colour from the victim to the replacement */
>   	*new = *victim;
>   }
> -EXPORT_SYMBOL(rb_replace_node);
> 

Cheers,
Jan Beulich Nov. 19, 2020, 10:23 a.m. UTC | #2
On 18.11.2020 18:46, Julien Grall wrote:
> On 23/10/2020 11:18, Jan Beulich wrote:
>> Build this code into an archive, which results in not linking it into
>> x86 final binaries. This saves about 1.5k of dead code.
>>
>> While moving the source file, take the opportunity and drop the
>> pointless EXPORT_SYMBOL().
> 
> Given this code is borrowed from Linux, I don't think we want to remove 
> them. This is to make easier to re-sync.

That's one view on it. My view is that we should get rid of
EXPORT_SYMBOL altogether (and it is a good opportunity to do so
here). Not the least because otherwise for future cloning of Linux
code we may then need to introduce further variants of this
construct for no real purpose.

>> --- a/xen/common/rbtree.c
>> +++ b/xen/lib/rbtree.c
>> @@ -25,7 +25,7 @@
>>   #include <xen/rbtree.h>
>>   
>>   /*
>> - * red-black trees properties:  http://en.wikipedia.org/wiki/Rbtree
>> + * red-black trees properties:  http://en.wikipedia.org/wiki/Rbtree
> 
> This looks like a spurious change.

Not really, no - while not visible here anymore, it's correcting an
instance of trailing whitespace. Following your request on an
earlier patch, I've also added half a sentence to the description
here to mention this entirely benign change.

Jan
diff mbox series

Patch

diff --git a/xen/common/Makefile b/xen/common/Makefile
index 52d3c2aa9384..7bb779f780a1 100644
--- a/xen/common/Makefile
+++ b/xen/common/Makefile
@@ -33,7 +33,6 @@  obj-y += preempt.o
 obj-y += random.o
 obj-y += rangeset.o
 obj-y += radix-tree.o
-obj-y += rbtree.o
 obj-y += rcupdate.o
 obj-y += rwlock.o
 obj-y += shutdown.o
diff --git a/xen/lib/Makefile b/xen/lib/Makefile
index ba1fb7bcdee2..b469d2dff7b8 100644
--- a/xen/lib/Makefile
+++ b/xen/lib/Makefile
@@ -4,3 +4,4 @@  obj-$(CONFIG_X86) += x86/
 lib-y += ctype.o
 lib-y += list-sort.o
 lib-y += parse-size.o
+lib-y += rbtree.o
diff --git a/xen/common/rbtree.c b/xen/lib/rbtree.c
similarity index 98%
rename from xen/common/rbtree.c
rename to xen/lib/rbtree.c
index 9f5498a89d4e..95e045d52461 100644
--- a/xen/common/rbtree.c
+++ b/xen/lib/rbtree.c
@@ -25,7 +25,7 @@ 
 #include <xen/rbtree.h>
 
 /*
- * red-black trees properties:  http://en.wikipedia.org/wiki/Rbtree 
+ * red-black trees properties:  http://en.wikipedia.org/wiki/Rbtree
  *
  *  1) A node is either red or black
  *  2) The root is black
@@ -223,7 +223,6 @@  void rb_insert_color(struct rb_node *node, struct rb_root *root)
 		}
 	}
 }
-EXPORT_SYMBOL(rb_insert_color);
 
 static void __rb_erase_color(struct rb_node *parent, struct rb_root *root)
 {
@@ -467,7 +466,6 @@  void rb_erase(struct rb_node *node, struct rb_root *root)
 	if (rebalance)
 		__rb_erase_color(rebalance, root);
 }
-EXPORT_SYMBOL(rb_erase);
 
 /*
  * This function returns the first node (in sort order) of the tree.
@@ -483,7 +481,6 @@  struct rb_node *rb_first(const struct rb_root *root)
 		n = n->rb_left;
 	return n;
 }
-EXPORT_SYMBOL(rb_first);
 
 struct rb_node *rb_last(const struct rb_root *root)
 {
@@ -496,7 +493,6 @@  struct rb_node *rb_last(const struct rb_root *root)
 		n = n->rb_right;
 	return n;
 }
-EXPORT_SYMBOL(rb_last);
 
 struct rb_node *rb_next(const struct rb_node *node)
 {
@@ -528,7 +524,6 @@  struct rb_node *rb_next(const struct rb_node *node)
 
 	return parent;
 }
-EXPORT_SYMBOL(rb_next);
 
 struct rb_node *rb_prev(const struct rb_node *node)
 {
@@ -557,7 +552,6 @@  struct rb_node *rb_prev(const struct rb_node *node)
 
 	return parent;
 }
-EXPORT_SYMBOL(rb_prev);
 
 void rb_replace_node(struct rb_node *victim, struct rb_node *new,
 		     struct rb_root *root)
@@ -574,4 +568,3 @@  void rb_replace_node(struct rb_node *victim, struct rb_node *new,
 	/* Copy the pointers/colour from the victim to the replacement */
 	*new = *victim;
 }
-EXPORT_SYMBOL(rb_replace_node);