OPTIM: lb-first: do not take the server lock on take_conn/drop_conn
authorWilly Tarreau <w@1wt.eu>
Wed, 17 Feb 2021 15:15:23 +0000 (16:15 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 10 Mar 2021 14:11:16 +0000 (15:11 +0100)
The operations are only an insert and a delete into the LB tree, which
doesn't require the server's lock at all as the lbprm lock is already
held. Let's drop it.

(cherry picked from commit 6b96e0e9d204bb7e30222964d641cc28a0e4d0c0)
Signed-off-by: Willy Tarreau <w@1wt.eu>

src/lb_fas.c

index 3debfec..9f6dc24 100644 (file)
@@ -36,7 +36,7 @@ static inline void fas_remove_from_tree(struct server *s)
 
 /* simply removes a server from a tree.
  *
- * The server's lock and the lbprm's lock must be held.
+ * The lbprm's lock must be held.
  */
 static inline void fas_dequeue_srv(struct server *s)
 {
@@ -49,7 +49,7 @@ static inline void fas_dequeue_srv(struct server *s)
  * reached. It is important to understand that the server weight is not used
  * here.
  *
- * The server's lock and the lbprm's lock must be held.
+ * The lbprm's lock must be held.
  */
 static inline void fas_queue_srv(struct server *s)
 {
@@ -66,18 +66,12 @@ static inline void fas_queue_srv(struct server *s)
  */
 static void fas_srv_reposition(struct server *s, int locked)
 {
-       if (!locked)
-               HA_SPIN_LOCK(SERVER_LOCK, &s->lock);
-
        HA_RWLOCK_WRLOCK(LBPRM_LOCK, &s->proxy->lbprm.lock);
        if (s->lb_tree) {
                fas_dequeue_srv(s);
                fas_queue_srv(s);
        }
        HA_RWLOCK_WRUNLOCK(LBPRM_LOCK, &s->proxy->lbprm.lock);
-
-       if (!locked)
-               HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
 }
 
 /* This function updates the server trees according to server <srv>'s new