Skip to contentSkip to conversation

bonding: add the debugfs interface to see RLB hash table

PATCH Applied Taku Izumi 3 participants 16 messages Dec 3, 2010 – Dec 16, 2010

Subsystems (3)
lore
Share & tools
lore

Taku Izumi

author
#0 lore raw

v2 cover bonding: add the debugfs interface to see RLB hash table

Hi Jay,

Thank you for your quick review. I update my patchset according to your comment. But I didn't take measures against your concern about seq_file. If I come up with a good idea, I'll correct it.

--
This patchset provides the debugfs facility to the bonding driver and the interface to see RLB hashtable in it.

*[PATCH 1/3] bonding: add the debugfs facility to the bonding driver *[PATCH 2/3] bonding: migrate some macros from bond_alb.c to bond_alb.h *[PATCH 3/3] bonding: add the debugfs interface to see RLB hash table

Best regards,
Taku Izumi

author
#1 lore raw

PATCH v2 1/3 bonding: add the debugfs facility to the bonding driver

This patch provides the debugfs facility to the bonding driver. The "bonding" directory is created in the debugfs root and directories of each bonding interface (like bond0, bond1...) are created in that.

 # mount -t debugfs none /sys/kernel/debug
 # ls /sys/kernel/debug/bonding
 bond0  bond1
---
 drivers/net/bonding/Makefile       |    2
 drivers/net/bonding/bond_debugfs.c |   92 +++++++++++++++++++++++++++++++++++++
 drivers/net/bonding/bond_main.c    |   10 +++-
 drivers/net/bonding/bonding.h      |    9 +++
 4 files changed, 111 insertions(+), 2 deletions(-)
drivers/net/bonding/bond_main.c +9 -1
Index: net-next/drivers/net/bonding/bond_main.c
===================================================================
@@ -3507,6 +3507,8 @@ static int bond_event_changename(struct
 	bond_remove_proc_entry(bond);
 	bond_create_proc_entry(bond);
 
+	bond_debug_reregister(bond);
+
 	return NOTIFY_DONE;
 }
 
@@ -4789,6 +4791,8 @@ static void bond_uninit(struct net_devic
 
 	bond_remove_proc_entry(bond);
 
+	bond_debug_unregister(bond);
+
 	__hw_addr_flush(&bond->mc_list);
 
 	list_for_each_entry_safe(vlan, tmp, &bond->vlan_list, vlan_list) {
@@ -5191,6 +5195,8 @@ static int bond_init(struct net_device *
 
 	bond_prepare_sysfs_group(bond);
 
+	bond_debug_register(bond);
+
 	__hw_addr_init(&bond->mc_list);
 	return 0;
 }
@@ -5312,6 +5318,8 @@ static int __init bonding_init(void)
 	if (res)
 		goto err_link;
 
+	bond_create_debugfs();
+
 	for (i = 0; i < max_bonds; i++) {
 		res = bond_create(&init_net, NULL);
 		if (res)
@@ -5322,7 +5330,6 @@ static int __init bonding_init(void)
 	if (res)
 		goto err;
 
-
 	register_netdevice_notifier(&bond_netdev_notifier);
 	register_inetaddr_notifier(&bond_inetaddr_notifier);
 	bond_register_ipv6_notifier();
@@ -5346,6 +5353,7 @@ static void __exit bonding_exit(void)
 	bond_unregister_ipv6_notifier();
 
 	bond_destroy_sysfs();
+	bond_destroy_debugfs();
 
 	rtnl_link_unregister(&bond_link_ops);
 	unregister_pernet_subsys(&bond_net_ops);
drivers/net/bonding/Makefile +1 -1
Index: net-next/drivers/net/bonding/Makefile
===================================================================
@@ -4,7 +4,7 @@
 
 obj-$(CONFIG_BONDING) += bonding.o
 
-bonding-objs := bond_main.o bond_3ad.o bond_alb.o bond_sysfs.o
+bonding-objs := bond_main.o bond_3ad.o bond_alb.o bond_sysfs.o bond_debugfs.o
 
 ipv6-$(subst m,y,$(CONFIG_IPV6)) += bond_ipv6.o
 bonding-objs += $(ipv6-y)
drivers/net/bonding/bond_debugfs.c new file +92 -0

92 lines not on this page · raw message

drivers/net/bonding/bonding.h +9 -0
Index: net-next/drivers/net/bonding/bonding.h
===================================================================
@@ -259,6 +259,10 @@ struct bonding {
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
 	struct   in6_addr master_ipv6;
 #endif
+#ifdef CONFIG_DEBUG_FS
+	/* debugging suport via debugfs */
+	struct	 dentry *debug_dir;
+#endif /* CONFIG_DEBUG_FS */
 };
 
 /**
@@ -380,6 +384,11 @@ void bond_select_active_slave(struct bon
 void bond_change_active_slave(struct bonding *bond, struct slave *new_active);
 void bond_register_arp(struct bonding *);
 void bond_unregister_arp(struct bonding *);
+void bond_create_debugfs(void);
+void bond_destroy_debugfs(void);
+void bond_debug_register(struct bonding *bond);
+void bond_debug_unregister(struct bonding *bond);
+void bond_debug_reregister(struct bonding *bond);
 
 struct bond_net {
 	struct net *		net;	/* Associated network namespace */
author
#2 lore raw

Re: [PATCH 1/3] bonding: add the debugfs facility to the bonding driver

This patch provides the debugfs facility to the bonding driver. The "bonding" directory is created in the debugfs root and directories of each bonding interface (like bond0, bond1...) are created in that.

 # mount -t debugfs none /sys/kernel/debug
 # ls /sys/kernel/debug/bonding
 bond0  bond1
---
 drivers/net/bonding/Makefile       |    2
 drivers/net/bonding/bond_debugfs.c |   96 +++++++++++++++++++++++++++++++++++++
 drivers/net/bonding/bond_main.c    |   10 +++
 drivers/net/bonding/bonding.h      |    9 +++
 4 files changed, 115 insertions(+), 2 deletions(-)
drivers/net/bonding/bond_main.c +9 -1
Index: net-next/drivers/net/bonding/bond_main.c
===================================================================
@@ -3507,6 +3507,8 @@ static int bond_event_changename(struct
 	bond_remove_proc_entry(bond);
 	bond_create_proc_entry(bond);
 
+	bond_debug_reregister(bond);
+
 	return NOTIFY_DONE;
 }
 
@@ -4789,6 +4791,8 @@ static void bond_uninit(struct net_devic
 
 	bond_remove_proc_entry(bond);
 
+	bond_debug_unregister(bond);
+
 	__hw_addr_flush(&bond->mc_list);
 
 	list_for_each_entry_safe(vlan, tmp, &bond->vlan_list, vlan_list) {
@@ -5191,6 +5195,8 @@ static int bond_init(struct net_device *
 
 	bond_prepare_sysfs_group(bond);
 
+	bond_debug_register(bond);
+
 	__hw_addr_init(&bond->mc_list);
 	return 0;
 }
@@ -5312,6 +5318,8 @@ static int __init bonding_init(void)
 	if (res)
 		goto err_link;
 
+	bond_create_debugfs();
+
 	for (i = 0; i < max_bonds; i++) {
 		res = bond_create(&init_net, NULL);
 		if (res)
@@ -5322,7 +5330,6 @@ static int __init bonding_init(void)
 	if (res)
 		goto err;
 
-
 	register_netdevice_notifier(&bond_netdev_notifier);
 	register_inetaddr_notifier(&bond_inetaddr_notifier);
 	bond_register_ipv6_notifier();
@@ -5346,6 +5353,7 @@ static void __exit bonding_exit(void)
 	bond_unregister_ipv6_notifier();
 
 	bond_destroy_sysfs();
+	bond_destroy_debugfs();
 
 	rtnl_link_unregister(&bond_link_ops);
 	unregister_pernet_subsys(&bond_net_ops);
drivers/net/bonding/Makefile +1 -1
Index: net-next/drivers/net/bonding/Makefile
===================================================================
@@ -4,7 +4,7 @@
 
 obj-$(CONFIG_BONDING) += bonding.o
 
-bonding-objs := bond_main.o bond_3ad.o bond_alb.o bond_sysfs.o
+bonding-objs := bond_main.o bond_3ad.o bond_alb.o bond_sysfs.o bond_debugfs.o
 
 ipv6-$(subst m,y,$(CONFIG_IPV6)) += bond_ipv6.o
 bonding-objs += $(ipv6-y)
drivers/net/bonding/bond_debugfs.c new file +96 -0

96 lines not on this page · raw message

drivers/net/bonding/bonding.h +9 -0
Index: net-next/drivers/net/bonding/bonding.h
===================================================================
@@ -259,6 +259,10 @@ struct bonding {
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
 	struct   in6_addr master_ipv6;
 #endif
+#ifdef CONFIG_DEBUG_FS
+	/* debugging suport via debugfs */
+	struct	 dentry *debug_dir;
+#endif /* CONFIG_DEBUG_FS */
 };
 
 /**
@@ -380,6 +384,11 @@ void bond_select_active_slave(struct bon
 void bond_change_active_slave(struct bonding *bond, struct slave *new_active);
 void bond_register_arp(struct bonding *);
 void bond_unregister_arp(struct bonding *);
+void bond_create_debugfs(void);
+void bond_destroy_debugfs(void);
+void bond_debug_register(struct bonding *bond);
+void bond_debug_unregister(struct bonding *bond);
+void bond_debug_reregister(struct bonding *bond);
 
 struct bond_net {
 	struct net *		net;	/* Associated network namespace */
#3 lore raw

Re: [PATCH 1/3] bonding: add the debugfs facility to the bonding driver

Quoted 11 lines · Taku Izumi

This patch provides the debugfs facility to the bonding driver. The "bonding" directory is created in the debugfs root and directories of each bonding interface (like bond0, bond1...) are created in that.

# mount -t debugfs none /sys/kernel/debug
# ls /sys/kernel/debug/bonding
bond0  bond1

Tested replacement patch 1 with original patches 2 and 3. Works
as advertised, no pesky crashes.

	-J
Quoted 210 lines

---

drivers/net/bonding/Makefile       |    2
drivers/net/bonding/bond_debugfs.c |   96 +++++++++++++++++++++++++++++++++++++
drivers/net/bonding/bond_main.c    |   10 +++
drivers/net/bonding/bonding.h      |    9 +++
4 files changed, 115 insertions(+), 2 deletions(-)

Index: net-next/drivers/net/bonding/bond_main.c
===================================================================

drivers/net/bonding/bond_main.c +9 -1
@@ -3507,6 +3507,8 @@ static int bond_event_changename(struct
 	bond_remove_proc_entry(bond);
 	bond_create_proc_entry(bond);
 
+	bond_debug_reregister(bond);
+
 	return NOTIFY_DONE;
 }
 
@@ -4789,6 +4791,8 @@ static void bond_uninit(struct net_devic
 
 	bond_remove_proc_entry(bond);
 
+	bond_debug_unregister(bond);
+
 	__hw_addr_flush(&bond->mc_list);
 
 	list_for_each_entry_safe(vlan, tmp, &bond->vlan_list, vlan_list) {
@@ -5191,6 +5195,8 @@ static int bond_init(struct net_device *
 
 	bond_prepare_sysfs_group(bond);
 
+	bond_debug_register(bond);
+
 	__hw_addr_init(&bond->mc_list);
 	return 0;
 }
@@ -5312,6 +5318,8 @@ static int __init bonding_init(void)
 	if (res)
 		goto err_link;
 
+	bond_create_debugfs();
+
 	for (i = 0; i < max_bonds; i++) {
 		res = bond_create(&init_net, NULL);
 		if (res)
@@ -5322,7 +5330,6 @@ static int __init bonding_init(void)
 	if (res)
 		goto err;
 
-
 	register_netdevice_notifier(&bond_netdev_notifier);
 	register_inetaddr_notifier(&bond_inetaddr_notifier);
 	bond_register_ipv6_notifier();
@@ -5346,6 +5353,7 @@ static void __exit bonding_exit(void)
 	bond_unregister_ipv6_notifier();
 
 	bond_destroy_sysfs();
+	bond_destroy_debugfs();
 
 	rtnl_link_unregister(&bond_link_ops);
 	unregister_pernet_subsys(&bond_net_ops);

Index: net-next/drivers/net/bonding/Makefile
===================================================================

drivers/net/bonding/Makefile +0 -0
@@ -4,7 +4,7 @@
 

obj-$(CONFIG_BONDING) += bonding.o

drivers/net/bonding/Makefile +1 -1
-bonding-objs := bond_main.o bond_3ad.o bond_alb.o bond_sysfs.o
+bonding-objs := bond_main.o bond_3ad.o bond_alb.o bond_sysfs.o bond_debugfs.o

ipv6-$(subst m,y,$(CONFIG_IPV6)) += bond_ipv6.o bonding-objs += $(ipv6-y)
Index: net-next/drivers/net/bonding/bond_debugfs.c
===================================================================

drivers/net/bonding/bond_debugfs.c new file +96 -0
@@ -0,0 +1,96 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/netdevice.h>
+
+#include "bonding.h"
+
+#ifdef CONFIG_DEBUG_FS
+
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
+
+static struct dentry *bonding_debug_root;
+
+void bond_debug_register(struct bonding *bond)
+{
+	if (!bonding_debug_root)
+		return;
+
+	bond->debug_dir =
+		debugfs_create_dir(bond->dev->name, bonding_debug_root);
+
+	if (!bond->debug_dir) {
+		pr_warning("%s: Warning: failed to register to debugfs\n",
+			bond->dev->name);
+		return;
+	}
+}
+
+void bond_debug_unregister(struct bonding *bond)
+{
+	if (!bonding_debug_root)
+		return;
+
+	debugfs_remove_recursive(bond->debug_dir);
+}
+
+void bond_debug_reregister(struct bonding *bond)
+{
+	struct dentry *d;
+
+	if (!bonding_debug_root)
+		return;
+
+	d = debugfs_rename(bonding_debug_root, bond->debug_dir,
+			   bonding_debug_root, bond->dev->name);
+	if (d) {
+		bond->debug_dir = d;
+	} else {
+		pr_warning("%s: Warning: failed to reregister, "
+				"so just unregister old one\n",
+				bond->dev->name);
+		bond_debug_unregister(bond);
+	}
+}
+
+void bond_create_debugfs(void)
+{
+	bonding_debug_root = debugfs_create_dir("bonding", NULL);
+
+	if (!bonding_debug_root) {
+		pr_warning("Warning: Cannot create bonding directory"
+				" in debugfs\n");
+	}
+}
+
+void bond_destroy_debugfs(void)
+{
+	debugfs_remove_recursive(bonding_debug_root);
+	bonding_debug_root = NULL;
+}
+
+
+#else /* !CONFIG_DEBUG_FS */
+
+void bond_debug_register(struct bonding *bond)
+{
+}
+
+void bond_debug_unregister(struct bonding *bond)
+{
+}
+
+void bond_debug_reregister(struct bonding *bond)
+{
+}
+
+void bond_create_debugfs(void)
+{
+}
+
+void bond_destroy_debugfs(void)
+{
+}
+
+#endif /* CONFIG_DEBUG_FS */

Index: net-next/drivers/net/bonding/bonding.h
===================================================================

drivers/net/bonding/bonding.h +9 -1
@@ -259,6 +259,10 @@ struct bonding {
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
 	struct   in6_addr master_ipv6;
 #endif
+#ifdef CONFIG_DEBUG_FS
+	/* debugging suport via debugfs */
+	struct	 dentry *debug_dir;
+#endif /* CONFIG_DEBUG_FS */
 };
 
 /**
@@ -380,6 +384,11 @@ void bond_select_active_slave(struct bon
 void bond_change_active_slave(struct bonding *bond, struct slave *new_active);
 void bond_register_arp(struct bonding *);
 void bond_unregister_arp(struct bonding *);
+void bond_create_debugfs(void);
+void bond_destroy_debugfs(void);
+void bond_debug_register(struct bonding *bond);
+void bond_debug_unregister(struct bonding *bond);
+void bond_debug_reregister(struct bonding *bond);
 
 struct bond_net {
 	struct net *		net;	/* Associated network namespace */
 
 
--

To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#4 lore raw

Re: [PATCH 1/3] bonding: add the debugfs facility to the bonding driver

From: Jay Vosburgh <[email protected]>
Date: Fri, 10 Dec 2010 16:21:45 -0800

Quoted 12 lines
Quoted 10 lines · Taku Izumi

This patch provides the debugfs facility to the bonding driver. The "bonding" directory is created in the debugfs root and directories of each bonding interface (like bond0, bond1...) are created in that.

# mount -t debugfs none /sys/kernel/debug
# ls /sys/kernel/debug/bonding
bond0  bond1
Quoted 6 lines
Quoted 1 line

Tested replacement patch 1 with original patches 2 and 3. Works
as advertised, no pesky crashes.

I'll apply this patch #1. Taku-san, could you please report patch #2 and #3 and remember to include Jay's signoff.

Thanks.

author
#5 lore raw

Re: [PATCH 1/3] bonding: add the debugfs facility to the bonding driver

Quoted 17 lines · David Miller

From: Jay Vosburgh<[email protected]>
Date: Fri, 10 Dec 2010 16:21:45 -0800

Quoted 14 lines
Quoted 11 lines · Taku Izumi

This patch provides the debugfs facility to the bonding driver. The "bonding" directory is created in the debugfs root and directories of each bonding interface (like bond0, bond1...) are created in that.

# mount -t debugfs none /sys/kernel/debug
# ls /sys/kernel/debug/bonding
bond0  bond1
Quoted 8 lines
Quoted 4 lines

Tested replacement patch 1 with original patches 2 and 3. Works
as advertised, no pesky crashes.

I'll apply this patch #1. Taku-san, could you please report patch #2 and #3 and remember to include Jay's signoff.

I resent the patch #2 and #3 with Jay's signoff.

Best regards,
Taku Izumi

maintainer
#6 lore raw

Re: [PATCH 1/3] bonding: add the debugfs facility to the bonding driver

From: Taku Izumi <[email protected]>
Date: Mon, 13 Dec 2010 14:09:30 +0900

Quoted 1 line

I resent the patch #2 and #3 with Jay's signoff.

Thank you.

author
#7 lore raw

PATCH v2 2/3 bonding: migrate some macros from bond_alb.c to bond_alb.h

In reply to Taku Izumi

This patch simply migrates some macros from bond_alb.c to bond_alb.h.

---
 drivers/net/bonding/bond_alb.c |   36 ------------------------------------
 drivers/net/bonding/bond_alb.h |   38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 36 deletions(-)
drivers/net/bonding/bond_alb.c +0 -36
Index: net-next/drivers/net/bonding/bond_alb.c
===================================================================
@@ -44,42 +44,6 @@
 #include "bond_alb.h"
 
 
-#define ALB_TIMER_TICKS_PER_SEC	    10	/* should be a divisor of HZ */
-#define BOND_TLB_REBALANCE_INTERVAL 10	/* In seconds, periodic re-balancing.
-					 * Used for division - never set
-					 * to zero !!!
-					 */
-#define BOND_ALB_LP_INTERVAL	    1	/* In seconds, periodic send of
-					 * learning packets to the switch
-					 */
-
-#define BOND_TLB_REBALANCE_TICKS (BOND_TLB_REBALANCE_INTERVAL \
-				  * ALB_TIMER_TICKS_PER_SEC)
-
-#define BOND_ALB_LP_TICKS (BOND_ALB_LP_INTERVAL \
-			   * ALB_TIMER_TICKS_PER_SEC)
-
-#define TLB_HASH_TABLE_SIZE 256	/* The size of the clients hash table.
-				 * Note that this value MUST NOT be smaller
-				 * because the key hash table is BYTE wide !
-				 */
-
-
-#define TLB_NULL_INDEX		0xffffffff
-#define MAX_LP_BURST		3
-
-/* rlb defs */
-#define RLB_HASH_TABLE_SIZE	256
-#define RLB_NULL_INDEX		0xffffffff
-#define RLB_UPDATE_DELAY	2*ALB_TIMER_TICKS_PER_SEC /* 2 seconds */
-#define RLB_ARP_BURST_SIZE	2
-#define RLB_UPDATE_RETRY	3	/* 3-ticks - must be smaller than the rlb
-					 * rebalance interval (5 min).
-					 */
-/* RLB_PROMISC_TIMEOUT = 10 sec equals the time that the current slave is
- * promiscuous after failover
- */
-#define RLB_PROMISC_TIMEOUT	10*ALB_TIMER_TICKS_PER_SEC
 
 #ifndef __long_aligned
 #define __long_aligned __attribute__((aligned((sizeof(long)))))
drivers/net/bonding/bond_alb.h +38 -0
Index: net-next/drivers/net/bonding/bond_alb.h
===================================================================
@@ -31,6 +31,44 @@ struct slave;
 #define BOND_ALB_INFO(bond)   ((bond)->alb_info)
 #define SLAVE_TLB_INFO(slave) ((slave)->tlb_info)
 
+#define ALB_TIMER_TICKS_PER_SEC	    10	/* should be a divisor of HZ */
+#define BOND_TLB_REBALANCE_INTERVAL 10	/* In seconds, periodic re-balancing.
+					 * Used for division - never set
+					 * to zero !!!
+					 */
+#define BOND_ALB_LP_INTERVAL	    1	/* In seconds, periodic send of
+					 * learning packets to the switch
+					 */
+
+#define BOND_TLB_REBALANCE_TICKS (BOND_TLB_REBALANCE_INTERVAL \
+				  * ALB_TIMER_TICKS_PER_SEC)
+
+#define BOND_ALB_LP_TICKS (BOND_ALB_LP_INTERVAL \
+			   * ALB_TIMER_TICKS_PER_SEC)
+
+#define TLB_HASH_TABLE_SIZE 256	/* The size of the clients hash table.
+				 * Note that this value MUST NOT be smaller
+				 * because the key hash table is BYTE wide !
+				 */
+
+
+#define TLB_NULL_INDEX		0xffffffff
+#define MAX_LP_BURST		3
+
+/* rlb defs */
+#define RLB_HASH_TABLE_SIZE	256
+#define RLB_NULL_INDEX		0xffffffff
+#define RLB_UPDATE_DELAY	(2*ALB_TIMER_TICKS_PER_SEC) /* 2 seconds */
+#define RLB_ARP_BURST_SIZE	2
+#define RLB_UPDATE_RETRY	3 /* 3-ticks - must be smaller than the rlb
+				   * rebalance interval (5 min).
+				   */
+/* RLB_PROMISC_TIMEOUT = 10 sec equals the time that the current slave is
+ * promiscuous after failover
+ */
+#define RLB_PROMISC_TIMEOUT	(10*ALB_TIMER_TICKS_PER_SEC)
+
+
 struct tlb_client_info {
 	struct slave *tx_slave;	/* A pointer to slave used for transmiting
 				 * packets to a Client that the Hash function
author
#8 lore raw

Re: [PATCH 2/3] bonding: migrate some macros from bond_alb.c to bond_alb.h

This patch simply migrates some macros from bond_alb.c to bond_alb.h.

---
 drivers/net/bonding/bond_alb.c |   36 ------------------------------------
 drivers/net/bonding/bond_alb.h |   38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 36 deletions(-)
drivers/net/bonding/bond_alb.c +0 -36
Index: net-next/drivers/net/bonding/bond_alb.c
===================================================================
@@ -44,42 +44,6 @@
 #include "bond_alb.h"
 
 
-#define ALB_TIMER_TICKS_PER_SEC	    10	/* should be a divisor of HZ */
-#define BOND_TLB_REBALANCE_INTERVAL 10	/* In seconds, periodic re-balancing.
-					 * Used for division - never set
-					 * to zero !!!
-					 */
-#define BOND_ALB_LP_INTERVAL	    1	/* In seconds, periodic send of
-					 * learning packets to the switch
-					 */
-
-#define BOND_TLB_REBALANCE_TICKS (BOND_TLB_REBALANCE_INTERVAL \
-				  * ALB_TIMER_TICKS_PER_SEC)
-
-#define BOND_ALB_LP_TICKS (BOND_ALB_LP_INTERVAL \
-			   * ALB_TIMER_TICKS_PER_SEC)
-
-#define TLB_HASH_TABLE_SIZE 256	/* The size of the clients hash table.
-				 * Note that this value MUST NOT be smaller
-				 * because the key hash table is BYTE wide !
-				 */
-
-
-#define TLB_NULL_INDEX		0xffffffff
-#define MAX_LP_BURST		3
-
-/* rlb defs */
-#define RLB_HASH_TABLE_SIZE	256
-#define RLB_NULL_INDEX		0xffffffff
-#define RLB_UPDATE_DELAY	2*ALB_TIMER_TICKS_PER_SEC /* 2 seconds */
-#define RLB_ARP_BURST_SIZE	2
-#define RLB_UPDATE_RETRY	3	/* 3-ticks - must be smaller than the rlb
-					 * rebalance interval (5 min).
-					 */
-/* RLB_PROMISC_TIMEOUT = 10 sec equals the time that the current slave is
- * promiscuous after failover
- */
-#define RLB_PROMISC_TIMEOUT	10*ALB_TIMER_TICKS_PER_SEC
 
 #ifndef __long_aligned
 #define __long_aligned __attribute__((aligned((sizeof(long)))))
drivers/net/bonding/bond_alb.h +38 -0
Index: net-next/drivers/net/bonding/bond_alb.h
===================================================================
@@ -31,6 +31,44 @@ struct slave;
 #define BOND_ALB_INFO(bond)   ((bond)->alb_info)
 #define SLAVE_TLB_INFO(slave) ((slave)->tlb_info)
 
+#define ALB_TIMER_TICKS_PER_SEC	    10	/* should be a divisor of HZ */
+#define BOND_TLB_REBALANCE_INTERVAL 10	/* In seconds, periodic re-balancing.
+					 * Used for division - never set
+					 * to zero !!!
+					 */
+#define BOND_ALB_LP_INTERVAL	    1	/* In seconds, periodic send of
+					 * learning packets to the switch
+					 */
+
+#define BOND_TLB_REBALANCE_TICKS (BOND_TLB_REBALANCE_INTERVAL \
+				  * ALB_TIMER_TICKS_PER_SEC)
+
+#define BOND_ALB_LP_TICKS (BOND_ALB_LP_INTERVAL \
+			   * ALB_TIMER_TICKS_PER_SEC)
+
+#define TLB_HASH_TABLE_SIZE 256	/* The size of the clients hash table.
+				 * Note that this value MUST NOT be smaller
+				 * because the key hash table is BYTE wide !
+				 */
+
+
+#define TLB_NULL_INDEX		0xffffffff
+#define MAX_LP_BURST		3
+
+/* rlb defs */
+#define RLB_HASH_TABLE_SIZE	256
+#define RLB_NULL_INDEX		0xffffffff
+#define RLB_UPDATE_DELAY	(2*ALB_TIMER_TICKS_PER_SEC) /* 2 seconds */
+#define RLB_ARP_BURST_SIZE	2
+#define RLB_UPDATE_RETRY	3 /* 3-ticks - must be smaller than the rlb
+				   * rebalance interval (5 min).
+				   */
+/* RLB_PROMISC_TIMEOUT = 10 sec equals the time that the current slave is
+ * promiscuous after failover
+ */
+#define RLB_PROMISC_TIMEOUT	(10*ALB_TIMER_TICKS_PER_SEC)
+
+
 struct tlb_client_info {
 	struct slave *tx_slave;	/* A pointer to slave used for transmiting
 				 * packets to a Client that the Hash function
author
#10 lore raw

PATCH v2 3/3 bonding: add the debugfs interface to see RLB hash table

In reply to Taku Izumi

This patch provices the debugfs interface to see RLB hash table like the following:

# cat /sys/kernel/debug/bonding/bond0/rlb_hash_table
SourceIP        DestinationIP   Destination MAC   DEV
10.124.196.205  10.124.196.205  ff:ff:ff:ff:ff:ff eth4
10.124.196.205  10.124.196.81   00:19:99:XX:XX:XX eth3
10.124.196.205  10.124.196.1    00:21:d8:XX:XX:XX eth0

This is helpful to check if the receive load balancing works as expected.

---
 drivers/net/bonding/bond_debugfs.c |   50 +++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
drivers/net/bonding/bond_debugfs.c +50 -0
Index: net-next/drivers/net/bonding/bond_debugfs.c
===================================================================
@@ -4,6 +4,7 @@
 #include <linux/netdevice.h>
 
 #include "bonding.h"
+#include "bond_alb.h"
 
 #ifdef CONFIG_DEBUG_FS
 
@@ -12,6 +13,52 @@
 
 static struct dentry *bonding_debug_root;
 
+/*
+ *  Show RLB hash table
+ */
+static int bond_debug_rlb_hash_show(struct seq_file *m, void *v)
+{
+	struct bonding *bond = m->private;
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+	struct rlb_client_info *client_info;
+	u32 hash_index;
+
+	if (bond->params.mode != BOND_MODE_ALB)
+		return 0;
+
+	seq_printf(m, "SourceIP        DestinationIP   "
+			"Destination MAC   DEV\n");
+
+	spin_lock_bh(&(BOND_ALB_INFO(bond).rx_hashtbl_lock));
+
+	hash_index = bond_info->rx_hashtbl_head;
+	for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
+		client_info = &(bond_info->rx_hashtbl[hash_index]);
+		seq_printf(m, "%-15pI4 %-15pI4 %-17pM %s\n",
+			&client_info->ip_src,
+			&client_info->ip_dst,
+			&client_info->mac_dst,
+			client_info->slave->dev->name);
+	}
+
+	spin_unlock_bh(&(BOND_ALB_INFO(bond).rx_hashtbl_lock));
+
+	return 0;
+}
+
+static int bond_debug_rlb_hash_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, bond_debug_rlb_hash_show, inode->i_private);
+}
+
+static const struct file_operations bond_debug_rlb_hash_fops = {
+	.owner		= THIS_MODULE,
+	.open		= bond_debug_rlb_hash_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
 void bond_debug_register(struct bonding *bond)
 {
 	if (!bonding_debug_root)
@@ -25,6 +72,9 @@ void bond_debug_register(struct bonding
 			bond->dev->name);
 		return;
 	}
+
+	debugfs_create_file("rlb_hash_table", 0400, bond->debug_dir,
+				bond, &bond_debug_rlb_hash_fops);
 }
 
 void bond_debug_unregister(struct bonding *bond)
author
#11 lore raw

This patch provices the debugfs interface to see RLB hash table like the following:

# cat /sys/kernel/debug/bonding/bond0/rlb_hash_table
SourceIP        DestinationIP   Destination MAC   DEV
10.124.196.205  10.124.196.205  ff:ff:ff:ff:ff:ff eth4
10.124.196.205  10.124.196.81   00:19:99:XX:XX:XX eth3
10.124.196.205  10.124.196.1    00:21:d8:XX:XX:XX eth0

This is helpful to check if the receive load balancing works as expected.

---
 drivers/net/bonding/bond_debugfs.c |   50 +++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
drivers/net/bonding/bond_debugfs.c +50 -0
Index: net-next/drivers/net/bonding/bond_debugfs.c
===================================================================
@@ -4,6 +4,7 @@
 #include <linux/netdevice.h>
 
 #include "bonding.h"
+#include "bond_alb.h"
 
 #ifdef CONFIG_DEBUG_FS
 
@@ -12,6 +13,52 @@
 
 static struct dentry *bonding_debug_root;
 
+/*
+ *  Show RLB hash table
+ */
+static int bond_debug_rlb_hash_show(struct seq_file *m, void *v)
+{
+	struct bonding *bond = m->private;
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+	struct rlb_client_info *client_info;
+	u32 hash_index;
+
+	if (bond->params.mode != BOND_MODE_ALB)
+		return 0;
+
+	seq_printf(m, "SourceIP        DestinationIP   "
+			"Destination MAC   DEV\n");
+
+	spin_lock_bh(&(BOND_ALB_INFO(bond).rx_hashtbl_lock));
+
+	hash_index = bond_info->rx_hashtbl_head;
+	for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
+		client_info = &(bond_info->rx_hashtbl[hash_index]);
+		seq_printf(m, "%-15pI4 %-15pI4 %-17pM %s\n",
+			&client_info->ip_src,
+			&client_info->ip_dst,
+			&client_info->mac_dst,
+			client_info->slave->dev->name);
+	}
+
+	spin_unlock_bh(&(BOND_ALB_INFO(bond).rx_hashtbl_lock));
+
+	return 0;
+}
+
+static int bond_debug_rlb_hash_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, bond_debug_rlb_hash_show, inode->i_private);
+}
+
+static const struct file_operations bond_debug_rlb_hash_fops = {
+	.owner		= THIS_MODULE,
+	.open		= bond_debug_rlb_hash_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
 void bond_debug_register(struct bonding *bond)
 {
 	if (!bonding_debug_root)
@@ -25,6 +72,9 @@ void bond_debug_register(struct bonding
 			bond->dev->name);
 		return;
 	}
+
+	debugfs_create_file("rlb_hash_table", 0400, bond->debug_dir,
+				bond, &bond_debug_rlb_hash_fops);
 }
 
 void bond_debug_unregister(struct bonding *bond)
maintainer Applied
#12 lore raw

From: Taku Izumi <[email protected]>
Date: Mon, 13 Dec 2010 14:04:43 +0900

Quoted 10 lines

This patch provices the debugfs interface to see RLB hash table like the following:

# cat /sys/kernel/debug/bonding/bond0/rlb_hash_table
SourceIP        DestinationIP   Destination MAC   DEV
10.124.196.205  10.124.196.205  ff:ff:ff:ff:ff:ff eth4
10.124.196.205  10.124.196.81   00:19:99:XX:XX:XX eth3
10.124.196.205  10.124.196.1    00:21:d8:XX:XX:XX eth0
Quoted 4 lines

This is helpful to check if the receive load balancing works as expected.

Applied.

#13 lore raw
In reply to Taku Izumi
Quoted 6 lines · Taku Izumi

Hi Jay,

Thank you for your quick review. I update my patchset according to your comment. But I didn't take measures against your concern about seq_file. If I come up with a good idea, I'll correct it.

Quoted 7 lines

--
This patchset provides the debugfs facility to the bonding driver and the interface to see RLB hashtable in it.

*[PATCH 1/3] bonding: add the debugfs facility to the bonding driver *[PATCH 2/3] bonding: migrate some macros from bond_alb.c to bond_alb.h *[PATCH 3/3] bonding: add the debugfs interface to see RLB hash table

After applying your patches to net-next-2.6, I'm seeing the
following crash when executing "rmmod bonding":

BUG: unable to handle kernel paging request at 6b6b6b9f
IP: [<c0201f11>] debugfs_remove_recursive+0x1e/0x11a
*pde = 00000000 
Oops: 0000 [#1] PREEMPT SMP 
last sysfs file: /sys/devices/virtual/net/bond0/flags
Modules linked in: bonding(-) ipv6 mperf microcode loop tg3 e1000 libphy sworks_agp agpgart edd ext3 mbcache jbd pata_serverworks mptspi mptscsih mptbase [last unloaded: speedstep_lib]

Pid: 5237, comm: rmmod Not tainted 2.6.37-rc1-cur+ #11 /eserver xSeries 335 -[8676GBX]-
EIP: 0060:[<c0201f11>] EFLAGS: 00010202 CPU: 2
EIP is at debugfs_remove_recursive+0x1e/0x11a
EAX: 6b6b6b6b EBX: f4d99480 ECX: 00000000 EDX: f3d5a5d4
ESI: f4d99950 EDI: f2d445b8 EBP: f4d03eb8 ESP: f4d03ea8
DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
Process rmmod (pid: 5237, ti=f4d02000 task=f3d5a240 task.ti=f4d02000)

Stack:
 f4d03ec0 f4d99480 f4d99950 f4d99000 f4d03ec0 f801dc05 f4d03ef4 f8015c5b
 c0156ab6 f4d03ed8 c0134ff0 f4d9949c f4d03ee4 c037ec67 f4d99150 f4d03ef4
 f4d99000 f4d03f20 f4d99000 f4d03f08 c030eafe f4d03f20 c0ce4140 f80233a4
Call Trace:
 [<f801dc05>] ? bond_debug_unregister+0xe/0x10 [bonding]
 [<f8015c5b>] ? bond_uninit+0x324/0x36d [bonding]
 [<c0156ab6>] ? trace_hardirqs_on+0xb/0xd
 [<c0134ff0>] ? local_bh_enable_ip+0x97/0xae
 [<c037ec67>] ? _raw_spin_unlock_bh+0x2f/0x32
 [<c030eafe>] ? rollback_registered_many+0x187/0x1fb
 [<c030eb81>] ? unregister_netdevice_many+0xf/0x4d
 [<c0318890>] ? __rtnl_link_unregister+0x56/0x8a
 [<c0318f45>] ? rtnl_link_unregister+0x19/0x21
 [<f801e32d>] ? bonding_exit+0x30/0x3c [bonding]
 [<c0162ddc>] ? sys_delete_module+0x184/0x1dc
 [<c01555fe>] ? put_lock_stats+0xd/0x22
 [<c0155708>] ? lock_release_holdtime+0xf5/0xfa
 [<c01a8fa3>] ? sys_munmap+0x39/0x3f
 [<c037f098>] ? restore_all_notrace+0x0/0x18
 [<c010294c>] ? sysenter_do_call+0x12/0x32
Code: fc ff 89 d8 e8 27 77 fc ff 5b 5e 5d c3 55 89 e5 57 89 c7 56 53 83 ec 04 85 c0 0f 84 01 01 00 00 8b 40 40 85 c0 0f 84 f6 00 00 00 <83> 78 34 00 0f 84 ec 00 00 00 8b 47 34 31 d2 89 fe 05 a4 00 00 
EIP: [<c0201f11>] debugfs_remove_recursive+0x1e/0x11a SS:ESP 0068:f4d03ea8
CR2: 000000006b6b6b9f
---[ end trace e274f539dfd6ed30 ]---

This happens regardless of activity; e.g., "insmod bonding
mode=balance-alb" followed immediately by "rmmod bonding" generates the above.

	Any thoughts?

	-J

---
-Jay Vosburgh, IBM Linux Technology Center, [email protected]

author
#14 lore raw

Hi Jay,

Quoted 43 lines

After applying your patches to net-next-2.6, I'm seeing the
following crash when executing "rmmod bonding":

BUG: unable to handle kernel paging request at 6b6b6b9f
IP: [<c0201f11>] debugfs_remove_recursive+0x1e/0x11a
*pde = 00000000
Oops: 0000 [#1] PREEMPT SMP
last sysfs file: /sys/devices/virtual/net/bond0/flags
Modules linked in: bonding(-) ipv6 mperf microcode loop tg3 e1000 libphy sworks_agp agpgart edd ext3 mbcache jbd pata_serverworks mptspi mptscsih mptbase [last unloaded: speedstep_lib]

Pid: 5237, comm: rmmod Not tainted 2.6.37-rc1-cur+ #11 /eserver xSeries 335 -[8676GBX]-
EIP: 0060:[<c0201f11>] EFLAGS: 00010202 CPU: 2
EIP is at debugfs_remove_recursive+0x1e/0x11a
EAX: 6b6b6b6b EBX: f4d99480 ECX: 00000000 EDX: f3d5a5d4
ESI: f4d99950 EDI: f2d445b8 EBP: f4d03eb8 ESP: f4d03ea8
DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
Process rmmod (pid: 5237, ti=f4d02000 task=f3d5a240 task.ti=f4d02000)

Stack:
  f4d03ec0 f4d99480 f4d99950 f4d99000 f4d03ec0 f801dc05 f4d03ef4 f8015c5b
  c0156ab6 f4d03ed8 c0134ff0 f4d9949c f4d03ee4 c037ec67 f4d99150 f4d03ef4
  f4d99000 f4d03f20 f4d99000 f4d03f08 c030eafe f4d03f20 c0ce4140 f80233a4
Call Trace:
  [<f801dc05>] ? bond_debug_unregister+0xe/0x10 [bonding]
  [<f8015c5b>] ? bond_uninit+0x324/0x36d [bonding]
  [<c0156ab6>] ? trace_hardirqs_on+0xb/0xd
  [<c0134ff0>] ? local_bh_enable_ip+0x97/0xae
  [<c037ec67>] ? _raw_spin_unlock_bh+0x2f/0x32
  [<c030eafe>] ? rollback_registered_many+0x187/0x1fb
  [<c030eb81>] ? unregister_netdevice_many+0xf/0x4d
  [<c0318890>] ? __rtnl_link_unregister+0x56/0x8a
  [<c0318f45>] ? rtnl_link_unregister+0x19/0x21
  [<f801e32d>] ? bonding_exit+0x30/0x3c [bonding]
  [<c0162ddc>] ? sys_delete_module+0x184/0x1dc
  [<c01555fe>] ? put_lock_stats+0xd/0x22
  [<c0155708>] ? lock_release_holdtime+0xf5/0xfa
  [<c01a8fa3>] ? sys_munmap+0x39/0x3f
  [<c037f098>] ? restore_all_notrace+0x0/0x18
  [<c010294c>] ? sysenter_do_call+0x12/0x32
Code: fc ff 89 d8 e8 27 77 fc ff 5b 5e 5d c3 55 89 e5 57 89 c7 56 53 83 ec 04 85 c0 0f 84 01 01 00 00 8b 40 40 85 c0 0f 84 f6 00 00 00<83>  78 34 00 0f 84 ec 00 00 00 8b 47 34 31 d2 89 fe 05 a4 00 00
EIP: [<c0201f11>] debugfs_remove_recursive+0x1e/0x11a SS:ESP 0068:f4d03ea8
CR2: 000000006b6b6b9f
---[ end trace e274f539dfd6ed30 ]---
Quoted 5 lines

This happens regardless of activity; e.g., "insmod bonding
mode=balance-alb" followed immediately by "rmmod bonding" generates the above.

Any thoughts?

Thank you for testing. I could reproduce a similar crash. I'm debugging now...

Best regards,
Taku izumi

author
#15 lore raw
In reply to Jay Vosburgh

Hi Jay,

I updated the patch 1/3. The problem seems to be fixed.
The problem is not reproduced at least in my test by applying my new patch. Could you test again?

Best regards,
Taku Izumi