Skip to contentSkip to conversation

ipvs:Fix locking requirements in the function ip_vs_unlink_service

PATCH Julian Anastasov 1 participant 2 messages Sep 12, 2015 2 messages not in the archive

Subsystems (4)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Julian Anastasov

author maintainer
#1 lore raw

Hello,

Review

Quoted 8 lines · Nicholas Krause

This fixes locking requirements in the function ip_vs_unlink_service to properly use bottom half spinlocking around the call to the function __ip_vs_del_service in order to meet the locking that this paricular function requires as stated in it's comments related to locking.

(quoted diff) +2 -0
+	spin_lock_bh(&svc->sched_lock);
 	__ip_vs_del_service(svc, cleanup);
+	spin_unlock_bh(&svc->sched_lock);

BH locking is not needed anymore. Also, sched_lock is
used by schedulers to protect only access to svc->sched_data fields.

It seems the comment is outdated after
commit ceec4c381681 ("ipvs: convert services to rcu").

Regards

--
Julian Anastasov <[email protected]>

A message that is not in the archive (sent off-list or not yet received): [email protected]

author maintainer
#3 lore raw

Hello,

Quoted 11 lines · nick
Quoted 7 lines

BH locking is not needed anymore. Also, sched_lock is
used by schedulers to protect only access to svc->sched_data fields.

It seems the comment is outdated after
commit ceec4c381681 ("ipvs: convert services to rcu").

Julian,
You are correct after reading the commit id for rcu locking conversion that this comment is outdated. However the locking may still be required but in terms of rcu_read_lock/ unlock around this function call as it's still a critical region.

This function is called under __ip_vs_mutex, so
there is single writer that modifies the configuration. As "readers" the schedulers access the configuration under rcu_read_lock (eg. called in tcp_conn_schedule) but they are free to use other locking too. ip_vs_wlc.c scheduler is example where sched_lock is not used because only svc->destinations is accessed which is protected with RCU by definition. You can check __ip_vs_unlink_dest() how dest is unlinked with list_del_rcu() before sched->del_dest method is called.

Regards

--
Julian Anastasov <[email protected]>