All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] net: dst: add and use dst_flags_t
@ 2017-12-06 21:35 Alexey Dobriyan
  2017-12-06 21:35 ` [PATCH 2/3] net: dst: switch to 8-bit dst->flags Alexey Dobriyan
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alexey Dobriyan @ 2017-12-06 21:35 UTC (permalink / raw)
  To: davem; +Cc: netdev, Alexey Dobriyan

Typedef dst->flags for checking with sparse.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 drivers/net/vrf.c       |  2 +-
 include/net/dst.h       | 23 ++++++++++++-----------
 include/net/ip6_route.h |  2 +-
 net/core/dst.c          |  4 ++--
 net/ipv6/route.c        |  4 ++--
 5 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index feb1b2e15c2e..f6a5df216fec 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -493,7 +493,7 @@ static void vrf_rt6_release(struct net_device *dev, struct net_vrf *vrf)
 
 static int vrf_rt6_create(struct net_device *dev)
 {
-	int flags = DST_HOST | DST_NOPOLICY | DST_NOXFRM;
+	dst_flags_t flags = DST_HOST | DST_NOPOLICY | DST_NOXFRM;
 	struct net_vrf *vrf = netdev_priv(dev);
 	struct net *net = dev_net(dev);
 	struct fib6_table *rt6i_table;
diff --git a/include/net/dst.h b/include/net/dst.h
index 33d2a5433924..0f0905bda423 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -31,6 +31,7 @@
  */
 
 struct sk_buff;
+typedef unsigned short __bitwise dst_flags_t;
 
 struct dst_entry {
 	struct net_device       *dev;
@@ -45,15 +46,15 @@ struct dst_entry {
 	int			(*input)(struct sk_buff *);
 	int			(*output)(struct net *net, struct sock *sk, struct sk_buff *skb);
 
-	unsigned short		flags;
-#define DST_HOST		0x0001
-#define DST_NOXFRM		0x0002
-#define DST_NOPOLICY		0x0004
-#define DST_NOCOUNT		0x0008
-#define DST_FAKE_RTABLE		0x0010
-#define DST_XFRM_TUNNEL		0x0020
-#define DST_XFRM_QUEUE		0x0040
-#define DST_METADATA		0x0080
+	dst_flags_t		flags;
+#define DST_HOST		((dst_flags_t __force)0x0001)
+#define DST_NOXFRM		((dst_flags_t __force)0x0002)
+#define DST_NOPOLICY		((dst_flags_t __force)0x0004)
+#define DST_NOCOUNT		((dst_flags_t __force)0x0008)
+#define DST_FAKE_RTABLE		((dst_flags_t __force)0x0010)
+#define DST_XFRM_TUNNEL		((dst_flags_t __force)0x0020)
+#define DST_XFRM_QUEUE		((dst_flags_t __force)0x0040)
+#define DST_METADATA		((dst_flags_t __force)0x0080)
 
 	/* A non-zero value of dst->obsolete forces by-hand validation
 	 * of the route entry.  Positive values are set by the generic
@@ -388,10 +389,10 @@ static inline int dst_discard(struct sk_buff *skb)
 	return dst_discard_out(&init_net, skb->sk, skb);
 }
 void *dst_alloc(struct dst_ops *ops, struct net_device *dev, int initial_ref,
-		int initial_obsolete, unsigned short flags);
+		int initial_obsolete, dst_flags_t flags);
 void dst_init(struct dst_entry *dst, struct dst_ops *ops,
 	      struct net_device *dev, int initial_ref, int initial_obsolete,
-	      unsigned short flags);
+	      dst_flags_t flags);
 struct dst_entry *dst_destroy(struct dst_entry *dst);
 void dst_dev_put(struct dst_entry *dst);
 
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 18e442ea93d8..eec7e7ac564b 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -131,7 +131,7 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
 				    const struct in6_addr *addr, bool anycast);
 
 struct rt6_info *ip6_dst_alloc(struct net *net, struct net_device *dev,
-			       int flags);
+			       dst_flags_t flags);
 
 /*
  *	support functions for ND
diff --git a/net/core/dst.c b/net/core/dst.c
index 007aa0b08291..d7cce39c3552 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -61,7 +61,7 @@ const struct dst_metrics dst_default_metrics = {
 
 void dst_init(struct dst_entry *dst, struct dst_ops *ops,
 	      struct net_device *dev, int initial_ref, int initial_obsolete,
-	      unsigned short flags)
+	      dst_flags_t flags)
 {
 	dst->dev = dev;
 	if (dev)
@@ -92,7 +92,7 @@ void dst_init(struct dst_entry *dst, struct dst_ops *ops,
 EXPORT_SYMBOL(dst_init);
 
 void *dst_alloc(struct dst_ops *ops, struct net_device *dev,
-		int initial_ref, int initial_obsolete, unsigned short flags)
+		int initial_ref, int initial_obsolete, dst_flags_t flags)
 {
 	struct dst_entry *dst;
 
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index b3f4d19b3ca5..1d6d53a5d951 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -356,7 +356,7 @@ static void rt6_info_init(struct rt6_info *rt)
 /* allocate dst with ip6_dst_ops */
 static struct rt6_info *__ip6_dst_alloc(struct net *net,
 					struct net_device *dev,
-					int flags)
+					dst_flags_t flags)
 {
 	struct rt6_info *rt = dst_alloc(&net->ipv6.ip6_dst_ops, dev,
 					1, DST_OBSOLETE_FORCE_CHK, flags);
@@ -371,7 +371,7 @@ static struct rt6_info *__ip6_dst_alloc(struct net *net,
 
 struct rt6_info *ip6_dst_alloc(struct net *net,
 			       struct net_device *dev,
-			       int flags)
+			       dst_flags_t flags)
 {
 	struct rt6_info *rt = __ip6_dst_alloc(net, dev, flags);
 
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] net: dst: switch to 8-bit dst->flags
  2017-12-06 21:35 [PATCH 1/3] net: dst: add and use dst_flags_t Alexey Dobriyan
@ 2017-12-06 21:35 ` Alexey Dobriyan
  2017-12-06 21:35 ` [PATCH 3/3] net: dst: make dst->obsolete 8-bit Alexey Dobriyan
  2017-12-06 21:39 ` [PATCH 1/3] net: dst: add and use dst_flags_t David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Alexey Dobriyan @ 2017-12-06 21:35 UTC (permalink / raw)
  To: davem; +Cc: netdev, Alexey Dobriyan

None of the flags is 16-bit currently.

Space savings on x86_64:

	add/remove: 0/0 grow/shrink: 2/16 up/down: 7/-29 (-22)
	Function                                     old     new   delta
	netdev_frame_hook                            464     470      +6
	gre_fill_metadata_dst                        257     258      +1
	xfrm_resolve_and_create_bundle              2817    2816      -1
	ipv6_add_addr                               1724    1723      -1
	ip6_rt_cache_alloc                           472     471      -1
	ip6_route_info_create                       2955    2954      -1
	icmp6_dst_alloc                              569     568      -1
	dst_init                                     166     165      -1
	dev_fill_metadata_dst                        395     394      -1
	bnxt_start_xmit                             3119    3118      -1
	arp_process                                 2524    2523      -1
	addrconf_dst_alloc                           442     441      -1
	xfrm_lookup                                 2029    2027      -2
	ip6_tnl_xmit                                2965    2963      -2
	rt_dst_alloc                                 200     197      -3
	do_execute_actions                          2799    2796      -3
	addrconf_disable_policy_idev                 449     445      -4
	br_netfilter_rtable_init                      66      61      -5

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 include/net/dst.h | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/include/net/dst.h b/include/net/dst.h
index 0f0905bda423..25decfa4e14a 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -31,7 +31,7 @@
  */
 
 struct sk_buff;
-typedef unsigned short __bitwise dst_flags_t;
+typedef u8 __bitwise dst_flags_t;
 
 struct dst_entry {
 	struct net_device       *dev;
@@ -47,14 +47,15 @@ struct dst_entry {
 	int			(*output)(struct net *net, struct sock *sk, struct sk_buff *skb);
 
 	dst_flags_t		flags;
-#define DST_HOST		((dst_flags_t __force)0x0001)
-#define DST_NOXFRM		((dst_flags_t __force)0x0002)
-#define DST_NOPOLICY		((dst_flags_t __force)0x0004)
-#define DST_NOCOUNT		((dst_flags_t __force)0x0008)
-#define DST_FAKE_RTABLE		((dst_flags_t __force)0x0010)
-#define DST_XFRM_TUNNEL		((dst_flags_t __force)0x0020)
-#define DST_XFRM_QUEUE		((dst_flags_t __force)0x0040)
-#define DST_METADATA		((dst_flags_t __force)0x0080)
+#define DST_HOST		((dst_flags_t __force)0x01)
+#define DST_NOXFRM		((dst_flags_t __force)0x02)
+#define DST_NOPOLICY		((dst_flags_t __force)0x04)
+#define DST_NOCOUNT		((dst_flags_t __force)0x08)
+#define DST_FAKE_RTABLE		((dst_flags_t __force)0x10)
+#define DST_XFRM_TUNNEL		((dst_flags_t __force)0x20)
+#define DST_XFRM_QUEUE		((dst_flags_t __force)0x40)
+#define DST_METADATA		((dst_flags_t __force)0x80)
+	u8			__pad2;
 
 	/* A non-zero value of dst->obsolete forces by-hand validation
 	 * of the route entry.  Positive values are set by the generic
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] net: dst: make dst->obsolete 8-bit
  2017-12-06 21:35 [PATCH 1/3] net: dst: add and use dst_flags_t Alexey Dobriyan
  2017-12-06 21:35 ` [PATCH 2/3] net: dst: switch to 8-bit dst->flags Alexey Dobriyan
@ 2017-12-06 21:35 ` Alexey Dobriyan
  2017-12-06 21:39 ` [PATCH 1/3] net: dst: add and use dst_flags_t David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Alexey Dobriyan @ 2017-12-06 21:35 UTC (permalink / raw)
  To: davem; +Cc: netdev, Alexey Dobriyan

All values are small integers.

Space savings on x86_64:

	add/remove: 0/0 grow/shrink: 1/34 up/down: 1/-60 (-59)
	Function                                     old     new   delta
	dst_alloc                                    124     125      +1
	xfrm_negative_advice                          23      22      -1
	xfrm_dst_check                                27      26      -1
	udp_v6_early_demux                           845     844      -1
				...
	xfrm_resolve_and_create_bundle              2816    2812      -4
	dst_dev_put                                  104      99      -5
	xfrm_lookup                                 2027    2021      -6
	update_or_create_fnhe                       1339    1329     -10

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 include/net/dst.h | 8 ++++----
 net/core/dst.c    | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/net/dst.h b/include/net/dst.h
index 25decfa4e14a..77143ee9139c 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -55,7 +55,6 @@ struct dst_entry {
 #define DST_XFRM_TUNNEL		((dst_flags_t __force)0x20)
 #define DST_XFRM_QUEUE		((dst_flags_t __force)0x40)
 #define DST_METADATA		((dst_flags_t __force)0x80)
-	u8			__pad2;
 
 	/* A non-zero value of dst->obsolete forces by-hand validation
 	 * of the route entry.  Positive values are set by the generic
@@ -65,11 +64,12 @@ struct dst_entry {
 	 * Negative values are used by the implementation layer code to
 	 * force invocation of the dst_ops->check() method.
 	 */
-	short			obsolete;
+	s8			obsolete;
 #define DST_OBSOLETE_NONE	0
 #define DST_OBSOLETE_DEAD	2
 #define DST_OBSOLETE_FORCE_CHK	-1
 #define DST_OBSOLETE_KILL	-2
+	u16			__pad2;
 	unsigned short		header_len;	/* more space at head required */
 	unsigned short		trailer_len;	/* space to reserve at tail */
 
@@ -390,9 +390,9 @@ static inline int dst_discard(struct sk_buff *skb)
 	return dst_discard_out(&init_net, skb->sk, skb);
 }
 void *dst_alloc(struct dst_ops *ops, struct net_device *dev, int initial_ref,
-		int initial_obsolete, dst_flags_t flags);
+		s8 initial_obsolete, dst_flags_t flags);
 void dst_init(struct dst_entry *dst, struct dst_ops *ops,
-	      struct net_device *dev, int initial_ref, int initial_obsolete,
+	      struct net_device *dev, int initial_ref, s8 initial_obsolete,
 	      dst_flags_t flags);
 struct dst_entry *dst_destroy(struct dst_entry *dst);
 void dst_dev_put(struct dst_entry *dst);
diff --git a/net/core/dst.c b/net/core/dst.c
index d7cce39c3552..dba03bf26da7 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -60,7 +60,7 @@ const struct dst_metrics dst_default_metrics = {
 };
 
 void dst_init(struct dst_entry *dst, struct dst_ops *ops,
-	      struct net_device *dev, int initial_ref, int initial_obsolete,
+	      struct net_device *dev, int initial_ref, s8 initial_obsolete,
 	      dst_flags_t flags)
 {
 	dst->dev = dev;
@@ -92,7 +92,7 @@ void dst_init(struct dst_entry *dst, struct dst_ops *ops,
 EXPORT_SYMBOL(dst_init);
 
 void *dst_alloc(struct dst_ops *ops, struct net_device *dev,
-		int initial_ref, int initial_obsolete, dst_flags_t flags)
+		int initial_ref, s8 initial_obsolete, dst_flags_t flags)
 {
 	struct dst_entry *dst;
 
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] net: dst: add and use dst_flags_t
  2017-12-06 21:35 [PATCH 1/3] net: dst: add and use dst_flags_t Alexey Dobriyan
  2017-12-06 21:35 ` [PATCH 2/3] net: dst: switch to 8-bit dst->flags Alexey Dobriyan
  2017-12-06 21:35 ` [PATCH 3/3] net: dst: make dst->obsolete 8-bit Alexey Dobriyan
@ 2017-12-06 21:39 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-12-06 21:39 UTC (permalink / raw)
  To: adobriyan; +Cc: netdev


A proper patch series must have a header posting.

The header posting must explain what the patch series is doing,
how the patches in the series are related and therefore why they
belong together as a group, how it is doing what it is doing,
and why it is doing it that way.

Thank you.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-12-06 21:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-06 21:35 [PATCH 1/3] net: dst: add and use dst_flags_t Alexey Dobriyan
2017-12-06 21:35 ` [PATCH 2/3] net: dst: switch to 8-bit dst->flags Alexey Dobriyan
2017-12-06 21:35 ` [PATCH 3/3] net: dst: make dst->obsolete 8-bit Alexey Dobriyan
2017-12-06 21:39 ` [PATCH 1/3] net: dst: add and use dst_flags_t David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.