* [PATCHES] IPVS - use list_for_each_entry_continue, fix NQ
@ 2003-09-27 12:02 Julian Anastasov
2003-09-30 8:56 ` David S. Miller
0 siblings, 1 reply; 4+ messages in thread
From: Julian Anastasov @ 2003-09-27 12:02 UTC (permalink / raw)
To: David S. Miller; +Cc: Wensong Zhang, netdev
[-- Attachment #1: Type: TEXT/PLAIN, Size: 245 bytes --]
Hello,
The attached patches against today's 2.6 BK tree introduce
list_for_each_entry_continue and use it for some IPVS schedulers. There is
also a NQ scheduler fix. Please consider for inclusion.
Regards
--
Julian Anastasov <ja@ssi.bg>
[-- Attachment #2: Introduce list_for_each_entry_continue --]
[-- Type: TEXT/PLAIN, Size: 1510 bytes --]
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.1352 -> 1.1353
# include/linux/list.h 1.34 -> 1.35
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/09/27 ja@ssi.bg 1.1353
# Introduce list_for_each_entry_continue
# --------------------------------------------
#
diff -Nru a/include/linux/list.h b/include/linux/list.h
--- a/include/linux/list.h Sat Sep 27 10:43:58 2003
+++ b/include/linux/list.h Sat Sep 27 10:43:58 2003
@@ -325,6 +325,19 @@
pos = list_entry(pos->member.prev, typeof(*pos), member), \
prefetch(pos->member.prev))
+/**
+ * list_for_each_entry_continue - iterate over list of given type
+ * continuing after existing point
+ * @pos: the type * to use as a loop counter.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_continue(pos, head, member) \
+ for (pos = list_entry(pos->member.next, typeof(*pos), member), \
+ prefetch(pos->member.next); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.next, typeof(*pos), member), \
+ prefetch(pos->member.next))
/**
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
[-- Attachment #3: [IPV4/IPVS] Simplify ip_vs_wrr_gcd_weight --]
[-- Type: TEXT/PLAIN, Size: 1294 bytes --]
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.1353 -> 1.1354
# net/ipv4/ipvs/ip_vs_wrr.c 1.2 -> 1.3
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/09/27 ja@ssi.bg 1.1354
# [IPV4/IPVS] Simplify ip_vs_wrr_gcd_weight
# --------------------------------------------
#
diff -Nru a/net/ipv4/ipvs/ip_vs_wrr.c b/net/ipv4/ipvs/ip_vs_wrr.c
--- a/net/ipv4/ipvs/ip_vs_wrr.c Sat Sep 27 11:06:29 2003
+++ b/net/ipv4/ipvs/ip_vs_wrr.c Sat Sep 27 11:06:29 2003
@@ -58,26 +58,18 @@
{
struct ip_vs_dest *dest;
int weight;
- int g = 1;
+ int g = 0;
list_for_each_entry(dest, &svc->destinations, n_list) {
weight = atomic_read(&dest->weight);
if (weight > 0) {
- g = weight;
- goto search_gcd;
+ if (g > 0)
+ g = gcd(weight, g);
+ else
+ g = weight;
}
}
-
- return g;
-
- search_gcd:
- list_for_each_entry(dest, &svc->destinations, n_list) {
- weight = atomic_read(&dest->weight);
- if (weight > 0)
- g = gcd(weight, g);
- }
-
- return g;
+ return g ? g : 1;
}
[-- Attachment #4: [IPV4/IPVS] NQ scheduler fix --]
[-- Type: TEXT/PLAIN, Size: 2325 bytes --]
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.1354 -> 1.1355
# net/ipv4/ipvs/ip_vs_nq.c 1.2 -> 1.3
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/09/27 ja@ssi.bg 1.1355
# [IPV4/IPVS] The NQ scheduler must not return servers with weight 0
# --------------------------------------------
#
diff -Nru a/net/ipv4/ipvs/ip_vs_nq.c b/net/ipv4/ipvs/ip_vs_nq.c
--- a/net/ipv4/ipvs/ip_vs_nq.c Sat Sep 27 13:47:18 2003
+++ b/net/ipv4/ipvs/ip_vs_nq.c Sat Sep 27 13:47:18 2003
@@ -81,8 +81,8 @@
static struct ip_vs_dest *
ip_vs_nq_schedule(struct ip_vs_service *svc, struct iphdr *iph)
{
- struct ip_vs_dest *dest, *least;
- unsigned int loh, doh;
+ struct ip_vs_dest *dest, *least = NULL;
+ unsigned int loh = 0, doh;
IP_VS_DBG(6, "ip_vs_nq_schedule(): Scheduling...\n");
@@ -99,27 +99,10 @@
* new connections.
*/
- list_for_each_entry(least, &svc->destinations, n_list) {
- if (!(least->flags & IP_VS_DEST_F_OVERLOAD) &&
- atomic_read(&least->weight) > 0) {
- loh = ip_vs_nq_dest_overhead(least);
-
- /* return the server directly if it is idle */
- if (atomic_read(&least->activeconns) == 0)
- goto out;
-
- goto nextstage;
- }
- }
- return NULL;
-
- /*
- * Find the destination with the least load.
- */
- nextstage:
list_for_each_entry(dest, &svc->destinations, n_list) {
- if (dest->flags & IP_VS_DEST_F_OVERLOAD)
+ if (dest->flags & IP_VS_DEST_F_OVERLOAD ||
+ !atomic_read(&dest->weight))
continue;
doh = ip_vs_nq_dest_overhead(dest);
@@ -127,15 +110,20 @@
/* return the server directly if it is idle */
if (atomic_read(&dest->activeconns) == 0) {
least = dest;
+ loh = doh;
goto out;
}
- if (loh * atomic_read(&dest->weight) >
- doh * atomic_read(&least->weight)) {
+ if (!least ||
+ (loh * atomic_read(&dest->weight) >
+ doh * atomic_read(&least->weight))) {
least = dest;
loh = doh;
}
}
+
+ if (!least)
+ return NULL;
out:
IP_VS_DBG(6, "NQ: server %u.%u.%u.%u:%u "
[-- Attachment #5: [IPV4/IPVS] Use list_for_each_entry_continue --]
[-- Type: TEXT/PLAIN, Size: 6138 bytes --]
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.1355 -> 1.1356
# net/ipv4/ipvs/ip_vs_wlc.c 1.2 -> 1.3
# net/ipv4/ipvs/ip_vs_lblcr.c 1.5 -> 1.6
# net/ipv4/ipvs/ip_vs_lblc.c 1.4 -> 1.5
# net/ipv4/ipvs/ip_vs_lc.c 1.2 -> 1.3
# net/ipv4/ipvs/ip_vs_sed.c 1.2 -> 1.3
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/09/27 ja@ssi.bg 1.1356
# [IPV4/IPVS] Use list_for_each_entry_continue in some schedulers
# --------------------------------------------
#
diff -Nru a/net/ipv4/ipvs/ip_vs_lblc.c b/net/ipv4/ipvs/ip_vs_lblc.c
--- a/net/ipv4/ipvs/ip_vs_lblc.c Sat Sep 27 13:51:15 2003
+++ b/net/ipv4/ipvs/ip_vs_lblc.c Sat Sep 27 13:51:15 2003
@@ -458,10 +458,11 @@
* The server with weight=0 is quiesced and will not receive any
* new connection.
*/
- list_for_each_entry(least, &svc->destinations, n_list) {
- if (least->flags & IP_VS_DEST_F_OVERLOAD)
+ list_for_each_entry(dest, &svc->destinations, n_list) {
+ if (dest->flags & IP_VS_DEST_F_OVERLOAD)
continue;
- if (atomic_read(&least->weight) > 0) {
+ if (atomic_read(&dest->weight) > 0) {
+ least = dest;
loh = atomic_read(&least->activeconns) * 50
+ atomic_read(&least->inactconns);
goto nextstage;
@@ -473,7 +474,7 @@
* Find the destination with the least load.
*/
nextstage:
- list_for_each_entry(dest, &svc->destinations, n_list) {
+ list_for_each_entry_continue(dest, &svc->destinations, n_list) {
if (dest->flags & IP_VS_DEST_F_OVERLOAD)
continue;
diff -Nru a/net/ipv4/ipvs/ip_vs_lblcr.c b/net/ipv4/ipvs/ip_vs_lblcr.c
--- a/net/ipv4/ipvs/ip_vs_lblcr.c Sat Sep 27 13:51:15 2003
+++ b/net/ipv4/ipvs/ip_vs_lblcr.c Sat Sep 27 13:51:15 2003
@@ -711,11 +711,12 @@
* The server with weight=0 is quiesced and will not receive any
* new connection.
*/
- list_for_each_entry(least, &svc->destinations, n_list) {
- if (least->flags & IP_VS_DEST_F_OVERLOAD)
+ list_for_each_entry(dest, &svc->destinations, n_list) {
+ if (dest->flags & IP_VS_DEST_F_OVERLOAD)
continue;
- if (atomic_read(&least->weight) > 0) {
+ if (atomic_read(&dest->weight) > 0) {
+ least = dest;
loh = atomic_read(&least->activeconns) * 50
+ atomic_read(&least->inactconns);
goto nextstage;
@@ -727,7 +728,7 @@
* Find the destination with the least load.
*/
nextstage:
- list_for_each_entry(dest, &svc->destinations, n_list) {
+ list_for_each_entry_continue(dest, &svc->destinations, n_list) {
if (dest->flags & IP_VS_DEST_F_OVERLOAD)
continue;
diff -Nru a/net/ipv4/ipvs/ip_vs_lc.c b/net/ipv4/ipvs/ip_vs_lc.c
--- a/net/ipv4/ipvs/ip_vs_lc.c Sat Sep 27 13:51:15 2003
+++ b/net/ipv4/ipvs/ip_vs_lc.c Sat Sep 27 13:51:15 2003
@@ -65,8 +65,8 @@
static struct ip_vs_dest *
ip_vs_lc_schedule(struct ip_vs_service *svc, struct iphdr *iph)
{
- struct ip_vs_dest *dest, *least;
- unsigned int loh, doh;
+ struct ip_vs_dest *dest, *least = NULL;
+ unsigned int loh = 0, doh;
IP_VS_DBG(6, "ip_vs_lc_schedule(): Scheduling...\n");
@@ -79,31 +79,18 @@
* served, but no new connection is assigned to the server.
*/
- list_for_each_entry(least, &svc->destinations, n_list) {
- if (least->flags & IP_VS_DEST_F_OVERLOAD)
- continue;
- if (atomic_read(&least->weight) > 0) {
- loh = ip_vs_lc_dest_overhead(least);
- goto nextstage;
- }
- }
- return NULL;
-
- /*
- * Find the destination with the least load.
- */
- nextstage:
list_for_each_entry(dest, &svc->destinations, n_list) {
if ((dest->flags & IP_VS_DEST_F_OVERLOAD) ||
atomic_read(&dest->weight) == 0)
continue;
doh = ip_vs_lc_dest_overhead(dest);
- if (doh < loh) {
+ if (!least || doh < loh) {
least = dest;
loh = doh;
}
}
+ if (least)
IP_VS_DBG(6, "LC: server %u.%u.%u.%u:%u activeconns %d inactconns %d\n",
NIPQUAD(least->addr), ntohs(least->port),
atomic_read(&least->activeconns),
diff -Nru a/net/ipv4/ipvs/ip_vs_sed.c b/net/ipv4/ipvs/ip_vs_sed.c
--- a/net/ipv4/ipvs/ip_vs_sed.c Sat Sep 27 13:51:15 2003
+++ b/net/ipv4/ipvs/ip_vs_sed.c Sat Sep 27 13:51:15 2003
@@ -103,9 +103,10 @@
* new connections.
*/
- list_for_each_entry(least, &svc->destinations, n_list) {
- if (!(least->flags & IP_VS_DEST_F_OVERLOAD) &&
- atomic_read(&least->weight) > 0) {
+ list_for_each_entry(dest, &svc->destinations, n_list) {
+ if (!(dest->flags & IP_VS_DEST_F_OVERLOAD) &&
+ atomic_read(&dest->weight) > 0) {
+ least = dest;
loh = ip_vs_sed_dest_overhead(least);
goto nextstage;
}
@@ -116,7 +117,7 @@
* Find the destination with the least load.
*/
nextstage:
- list_for_each_entry(dest, &svc->destinations, n_list) {
+ list_for_each_entry_continue(dest, &svc->destinations, n_list) {
if (dest->flags & IP_VS_DEST_F_OVERLOAD)
continue;
doh = ip_vs_sed_dest_overhead(dest);
diff -Nru a/net/ipv4/ipvs/ip_vs_wlc.c b/net/ipv4/ipvs/ip_vs_wlc.c
--- a/net/ipv4/ipvs/ip_vs_wlc.c Sat Sep 27 13:51:15 2003
+++ b/net/ipv4/ipvs/ip_vs_wlc.c Sat Sep 27 13:51:15 2003
@@ -91,9 +91,10 @@
* new connections.
*/
- list_for_each_entry(least, &svc->destinations, n_list) {
- if (!(least->flags & IP_VS_DEST_F_OVERLOAD) &&
- atomic_read(&least->weight) > 0) {
+ list_for_each_entry(dest, &svc->destinations, n_list) {
+ if (!(dest->flags & IP_VS_DEST_F_OVERLOAD) &&
+ atomic_read(&dest->weight) > 0) {
+ least = dest;
loh = ip_vs_wlc_dest_overhead(least);
goto nextstage;
}
@@ -104,7 +105,7 @@
* Find the destination with the least load.
*/
nextstage:
- list_for_each_entry(dest, &svc->destinations, n_list) {
+ list_for_each_entry_continue(dest, &svc->destinations, n_list) {
if (dest->flags & IP_VS_DEST_F_OVERLOAD)
continue;
doh = ip_vs_wlc_dest_overhead(dest);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCHES] IPVS - use list_for_each_entry_continue, fix NQ
2003-09-27 12:02 [PATCHES] IPVS - use list_for_each_entry_continue, fix NQ Julian Anastasov
@ 2003-09-30 8:56 ` David S. Miller
2003-09-30 9:02 ` David S. Miller
2003-09-30 9:22 ` Julian Anastasov
0 siblings, 2 replies; 4+ messages in thread
From: David S. Miller @ 2003-09-30 8:56 UTC (permalink / raw)
To: Julian Anastasov; +Cc: wensong, netdev
On Sat, 27 Sep 2003 15:02:57 +0300 (EEST)
Julian Anastasov <ja@ssi.bg> wrote:
> The attached patches against today's 2.6 BK tree introduce
> list_for_each_entry_continue and use it for some IPVS schedulers. There is
> also a NQ scheduler fix. Please consider for inclusion.
Looks good, applied. Can you please CC: netdev@oss.sgi.com on all
patch submissions, even small and obvious ones? Thanks.
I assume you guys are still reviewing Rusty's skb_linearize()
removal patch?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCHES] IPVS - use list_for_each_entry_continue, fix NQ
2003-09-30 8:56 ` David S. Miller
@ 2003-09-30 9:02 ` David S. Miller
2003-09-30 9:22 ` Julian Anastasov
1 sibling, 0 replies; 4+ messages in thread
From: David S. Miller @ 2003-09-30 9:02 UTC (permalink / raw)
To: David S. Miller; +Cc: ja, wensong, netdev
On Tue, 30 Sep 2003 01:56:59 -0700
"David S. Miller" <davem@redhat.com> wrote:
> Can you please CC: netdev@oss.sgi.com
I'm such an idiot, please excuse my stupidity on this one :)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCHES] IPVS - use list_for_each_entry_continue, fix NQ
2003-09-30 8:56 ` David S. Miller
2003-09-30 9:02 ` David S. Miller
@ 2003-09-30 9:22 ` Julian Anastasov
1 sibling, 0 replies; 4+ messages in thread
From: Julian Anastasov @ 2003-09-30 9:22 UTC (permalink / raw)
To: David S. Miller; +Cc: wensong, netdev
Hello,
On Tue, 30 Sep 2003, David S. Miller wrote:
> > list_for_each_entry_continue and use it for some IPVS schedulers. There is
> > also a NQ scheduler fix. Please consider for inclusion.
>
> Looks good, applied. Can you please CC: netdev@oss.sgi.com on all
> patch submissions, even small and obvious ones? Thanks.
Always :)
> I assume you guys are still reviewing Rusty's skb_linearize()
> removal patch?
Yes, we will synchronize with Wensong to avoid double work.
As for me, I like 90% of the changes and started to import them in
my tree, I hope we will be back at the end of this week.
Regards
--
Julian Anastasov <ja@ssi.bg>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-09-30 9:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-27 12:02 [PATCHES] IPVS - use list_for_each_entry_continue, fix NQ Julian Anastasov
2003-09-30 8:56 ` David S. Miller
2003-09-30 9:02 ` David S. Miller
2003-09-30 9:22 ` Julian Anastasov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).