Re: ovf scheduler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I have updated the code and generated the patch, according to your indications.


On Tue, Jul 14, 2015 at 10:11 PM, Julian Anastasov <ja@xxxxxx> wrote:
>
>         Hello,
>
> On Tue, 14 Jul 2015, rhadoo.io88 wrote:
>
>> Unfortunately i was not aware of the FO scheduler, i looked it up just
>> now...indeed you could get similar behavior with FO scheduler and
>> proper thresholds.
>> The only trouble with that is that i can't set the thresholds from
>> within ldirectord , so i won't be able to keep all the config in one
>> place,  and that upper threshold seems to take into account all
>> connections ( active and inactive) , that making the upper limit a bit
>> vague.
>> i think this approach has the advantage of keeping all the config in
>> one place, having the weight set at the actual number of active
>> connections the node can handle whilst still allowing to have
>> thresholds on the total connections.
>
>         OK. But you have to update this scheduler because
> it is based on old code. You can use ip_vs_fo.c for
> reference. You have to fix any coding style warnings by using
> scripts/checkpatch.pl --strict /tmp/your.patch
> You can check Documentation/CodingStyle for reference.
> You can add comment that this scheduler can be used
> for TCP/SCTP but not for UDP because it uses only the
> activeconns.
>
>         Your patch should include also changes for Kconfig
> and Makefile.
>
>         Also, the 'curentw = atomic_read(&dest->weight);'
> can be used early to read the weight only once.
>
> Regards
>
> --
> Julian Anastasov <ja@xxxxxx>
From 69eab2c6e5add4e565b882fd91959de9cb8526fb Mon Sep 17 00:00:00 2001
From: Raducu Deaconu <rhadoo.io88@xxxxxxxxx>
Date: Thu, 16 Jul 2015 08:54:16 +0300
Subject: [PATCH] Add ovf scheduler

Signed-off-by: Raducu Deaconu <rhadoo.io88@xxxxxxxxx>
---
 net/netfilter/ipvs/Kconfig     |   11 +++++
 net/netfilter/ipvs/Makefile    |    1 +
 net/netfilter/ipvs/ip_vs_ovf.c |   87 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 99 insertions(+)
 create mode 100644 net/netfilter/ipvs/ip_vs_ovf.c

diff --git a/net/netfilter/ipvs/Kconfig b/net/netfilter/ipvs/Kconfig
index 3b6929d..2563c18 100644
--- a/net/netfilter/ipvs/Kconfig
+++ b/net/netfilter/ipvs/Kconfig
@@ -162,6 +162,17 @@ config  IP_VS_FO
 	  If you want to compile it in kernel, say Y. To compile it as a
 	  module, choose M here. If unsure, say N.
 
+config  IP_VS_OVF
+		tristate "weighted overflow scheduling"
+	---help---
+	  The weighted overflow scheduling algorithm directs network
+	  connections to the server with the highest weight that is
+	  currently available and overflows to the next when active
+	  connections exceed the node's weight.
+
+	  If you want to compile it in kernel, say Y. To compile it as a
+	  module, choose M here. If unsure, say N.
+
 config	IP_VS_LBLC
 	tristate "locality-based least-connection scheduling"
 	---help---
diff --git a/net/netfilter/ipvs/Makefile b/net/netfilter/ipvs/Makefile
index 38b2723..67f3f43 100644
--- a/net/netfilter/ipvs/Makefile
+++ b/net/netfilter/ipvs/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_IP_VS_WRR) += ip_vs_wrr.o
 obj-$(CONFIG_IP_VS_LC) += ip_vs_lc.o
 obj-$(CONFIG_IP_VS_WLC) += ip_vs_wlc.o
 obj-$(CONFIG_IP_VS_FO) += ip_vs_fo.o
+obj-$(CONFIG_IP_VS_OVF) += ip_vs_ovf.o
 obj-$(CONFIG_IP_VS_LBLC) += ip_vs_lblc.o
 obj-$(CONFIG_IP_VS_LBLCR) += ip_vs_lblcr.o
 obj-$(CONFIG_IP_VS_DH) += ip_vs_dh.o
diff --git a/net/netfilter/ipvs/ip_vs_ovf.c b/net/netfilter/ipvs/ip_vs_ovf.c
new file mode 100644
index 0000000..4e9458d
--- /dev/null
+++ b/net/netfilter/ipvs/ip_vs_ovf.c
@@ -0,0 +1,87 @@
+/*
+ * IPVS:        Overflow-Connection Scheduling module
+ *
+ * Authors:     Raducu Deaconu <rhadoo_io@xxxxxxxxx>
+ *
+ *              This program is free software; you can redistribute it and/or
+ *              modify it under the terms of the GNU General Public License
+ *              as published by the Free Software Foundation; either version
+ *              2 of the License, or (at your option) any later version.
+ *
+ * Scheduler implements "overflow" loadbalancing according to number of active
+ * connections , will keep all conections to the node with the highest weight
+ * and overflow to the next node if the number of connections exceeds the node's
+ * weight.
+ * Note that this scheduler might not be suitable for UDP because it only uses
+ * active connections
+ *
+ */
+
+#define KMSG_COMPONENT "IPVS"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+
+#include <net/ip_vs.h>
+
+/* OVF Connection scheduling  */
+static struct ip_vs_dest *
+ip_vs_ovf_schedule(struct ip_vs_service *svc, const struct sk_buff *skb,
+		   struct ip_vs_iphdr *iph)
+{
+	struct ip_vs_dest *dest, *hw = NULL;
+	int highestw = 0, curentw;
+
+	IP_VS_DBG(6, "ip_vs_ovf_schedule(): Scheduling...\n");
+	/* select the node with highest weight, go to next in line if active
+	* connections exceed weight
+	*
+	*/
+	list_for_each_entry_rcu(dest, &svc->destinations, n_list) {
+		curentw = atomic_read(&dest->weight);
+	if ((dest->flags & IP_VS_DEST_F_OVERLOAD) ||
+	    atomic_read(&dest->activeconns) > curentw ||
+	    curentw == 0)
+			continue;
+	if (!hw || curentw > highestw) {
+			hw = dest;
+			highestw = curentw;
+		}
+	}
+
+	if (hw) {
+		IP_VS_DBG_BUF(6, "OVF: server %s:%u activeconns %d weight %d\n",
+			      IP_VS_DBG_ADDR(svc->af, &hw->addr),
+			      ntohs(hweight->port),
+			      atomic_read(&hw->activeconns),
+			      atomic_read(&hw->weight));
+		return hw;
+	}
+
+	ip_vs_scheduler_err(svc, "no destination available");
+	return NULL;
+}
+
+static struct ip_vs_scheduler ip_vs_ovf_scheduler = {
+	.name =			"ovf",
+	.refcnt =		ATOMIC_INIT(0),
+	.module =		THIS_MODULE,
+	.n_list =		LIST_HEAD_INIT(ip_vs_ovf_scheduler.n_list),
+	.schedule =		ip_vs_ovf_schedule,
+};
+
+static int __init ip_vs_ovf_init(void)
+{
+	return register_ip_vs_scheduler(&ip_vs_ovf_scheduler);
+}
+
+static void __exit ip_vs_ovf_cleanup(void)
+{
+	unregister_ip_vs_scheduler(&ip_vs_ovf_scheduler);
+	synchronize_rcu();
+}
+
+module_init(ip_vs_ovf_init);
+module_exit(ip_vs_ovf_cleanup);
+MODULE_LICENSE("GPL");
-- 
1.7.10.4


[Index of Archives]     [Linux Filesystem Devel]     [Linux NFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]     [X.Org]

  Powered by Linux