From: Julian Anastasov <ja@ssi.bg>
To: Simon Horman <horms@verge.net.au>
Cc: lvs-devel@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH net-next 02/19] ipvs: preparations for using rcu in schedulers
Date: Fri, 22 Mar 2013 11:46:37 +0200 [thread overview]
Message-ID: <1363945614-11752-3-git-send-email-ja@ssi.bg> (raw)
In-Reply-To: <1363945614-11752-1-git-send-email-ja@ssi.bg>
Allow schedulers to use rcu_dereference when
returning destination on lookup. The RCU read-side critical
section will allow ip_vs_bind_dest to get dest refcnt as
preparation for the step where destinations will be
deleted without an IP_VS_WAIT_WHILE guard that holds the
packet processing during update.
Add new optional scheduler methods add_dest,
del_dest and upd_dest. For now the methods are called
together with update_service but update_service will be
removed in a following change.
Signed-off-by: Julian Anastasov <ja@ssi.bg>
---
include/net/ip_vs.h | 6 ++++++
net/netfilter/ipvs/ip_vs_core.c | 6 ++++++
net/netfilter/ipvs/ip_vs_ctl.c | 8 ++++++++
3 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 5ed8939..5af338b 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -805,6 +805,12 @@ struct ip_vs_scheduler {
int (*done_service)(struct ip_vs_service *svc);
/* scheduler updating service */
int (*update_service)(struct ip_vs_service *svc);
+ /* dest is linked */
+ int (*add_dest)(struct ip_vs_service *svc, struct ip_vs_dest *dest);
+ /* dest is unlinked */
+ int (*del_dest)(struct ip_vs_service *svc, struct ip_vs_dest *dest);
+ /* dest is updated */
+ int (*upd_dest)(struct ip_vs_service *svc, struct ip_vs_dest *dest);
/* selecting a server from the given service */
struct ip_vs_dest* (*schedule)(struct ip_vs_service *svc,
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index 207c3b9..7bf62d0 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -304,8 +304,10 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
* template is not available.
* return *ignored=0 i.e. ICMP and NF_DROP
*/
+ rcu_read_lock();
dest = svc->scheduler->schedule(svc, skb);
if (!dest) {
+ rcu_read_unlock();
IP_VS_DBG(1, "p-schedule: no dest found.\n");
kfree(param.pe_data);
*ignored = 0;
@@ -321,6 +323,7 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
* when the template expires */
ct = ip_vs_conn_new(¶m, &dest->addr, dport,
IP_VS_CONN_F_TEMPLATE, dest, skb->mark);
+ rcu_read_unlock();
if (ct == NULL) {
kfree(param.pe_data);
*ignored = -1;
@@ -449,8 +452,10 @@ ip_vs_schedule(struct ip_vs_service *svc, struct sk_buff *skb,
return NULL;
}
+ rcu_read_lock();
dest = svc->scheduler->schedule(svc, skb);
if (dest == NULL) {
+ rcu_read_unlock();
IP_VS_DBG(1, "Schedule: no dest found.\n");
return NULL;
}
@@ -471,6 +476,7 @@ ip_vs_schedule(struct ip_vs_service *svc, struct sk_buff *skb,
cp = ip_vs_conn_new(&p, &dest->addr,
dest->port ? dest->port : pptr[1],
flags, dest, skb->mark);
+ rcu_read_unlock();
if (!cp) {
*ignored = -1;
return NULL;
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index a66b1c7..ae765b8 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -823,6 +823,11 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
if (add) {
list_add(&dest->n_list, &svc->destinations);
svc->num_dests++;
+ if (svc->scheduler->add_dest)
+ svc->scheduler->add_dest(svc, dest);
+ } else {
+ if (svc->scheduler->upd_dest)
+ svc->scheduler->upd_dest(svc, dest);
}
/* call the update_service, because server weight may be changed */
@@ -1069,6 +1074,9 @@ static void __ip_vs_unlink_dest(struct ip_vs_service *svc,
list_del(&dest->n_list);
svc->num_dests--;
+ if (svcupd && svc->scheduler->del_dest)
+ svc->scheduler->del_dest(svc, dest);
+
/*
* Call the update_service function of its scheduler
*/
--
1.7.3.4
next prev parent reply other threads:[~2013-03-22 9:45 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-22 9:46 [PATCH net-next 00/19] IPVS optimizations, part 2 Julian Anastasov
2013-03-22 9:46 ` [PATCH net-next 01/19] ipvs: change ip_vs_sched_lock to mutex Julian Anastasov
2013-03-22 9:46 ` Julian Anastasov [this message]
2013-03-22 9:46 ` [PATCH net-next 03/19] ipvs: add ip_vs_dest_hold and ip_vs_dest_put Julian Anastasov
2013-03-22 9:46 ` [PATCH net-next 04/19] ipvs: convert dh scheduler to rcu Julian Anastasov
2013-03-22 9:46 ` [PATCH net-next 05/19] ipvs: convert lblc " Julian Anastasov
2013-03-22 9:46 ` [PATCH net-next 06/19] ipvs: convert lblcr " Julian Anastasov
2013-03-22 9:46 ` [PATCH net-next 07/19] ipvs: convert lc " Julian Anastasov
2013-03-22 9:46 ` [PATCH net-next 08/19] ipvs: convert nq " Julian Anastasov
2013-03-22 9:46 ` [PATCH net-next 09/19] ipvs: convert rr " Julian Anastasov
2013-03-22 9:46 ` [PATCH net-next 10/19] ipvs: convert sed " Julian Anastasov
2013-03-22 9:46 ` [PATCH net-next 11/19] ipvs: convert sh " Julian Anastasov
2013-03-22 9:46 ` [PATCH net-next 12/19] ipvs: convert wlc " Julian Anastasov
2013-03-22 9:46 ` [PATCH net-next 13/19] ipvs: convert wrr " Julian Anastasov
2013-03-22 9:46 ` [PATCH net-next 14/19] ipvs: reorganize dest trash Julian Anastasov
2013-03-22 9:46 ` [PATCH net-next 15/19] ipvs: do not expect result from done_service Julian Anastasov
2013-03-22 9:46 ` [PATCH net-next 16/19] ipvs: convert sched_lock to spin lock Julian Anastasov
2013-03-22 9:46 ` [PATCH net-next 17/19] ipvs: convert dests to rcu Julian Anastasov
2013-03-22 9:46 ` [PATCH net-next 18/19] ipvs: convert services " Julian Anastasov
2013-03-22 9:46 ` [PATCH net-next 19/19] ipvs: do not disable bh for long time Julian Anastasov
2013-03-28 5:41 ` [PATCH net-next 00/19] IPVS optimizations, part 2 Simon Horman
2013-03-28 8:57 ` Julian Anastasov
2013-03-28 9:05 ` Simon Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1363945614-11752-3-git-send-email-ja@ssi.bg \
--to=ja@ssi.bg \
--cc=horms@verge.net.au \
--cc=lvs-devel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).