MINOR: dynbuf: use regular lists instead of mt_lists for buffer_wait
authorWilly Tarreau <w@1wt.eu>
Sat, 20 Feb 2021 10:49:49 +0000 (11:49 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 10 Mar 2021 14:11:16 +0000 (15:11 +0100)
There's no point anymore in keeping mt_lists for the buffer_wait and
buffer_wq since it's thread-local now.

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

12 files changed:
include/haproxy/applet.h
include/haproxy/channel.h
include/haproxy/dynbuf-t.h
include/haproxy/dynbuf.h
include/haproxy/tinfo-t.h
src/check.c
src/dynbuf.c
src/flt_spoe.c
src/mux_fcgi.c
src/mux_h1.c
src/mux_h2.c
src/stream.c

index f6d764d..38ffaf7 100644 (file)
@@ -75,7 +75,7 @@ static inline struct appctx *appctx_new(struct applet *applet, unsigned long thr
                }
                appctx->t->process = task_run_applet;
                appctx->t->context = appctx;
-               MT_LIST_INIT(&appctx->buffer_wait.list);
+               LIST_INIT(&appctx->buffer_wait.list);
                appctx->buffer_wait.target = appctx;
                appctx->buffer_wait.wakeup_cb = appctx_buf_available;
                _HA_ATOMIC_ADD(&nb_applets, 1);
@@ -87,8 +87,8 @@ static inline struct appctx *appctx_new(struct applet *applet, unsigned long thr
 static inline void __appctx_free(struct appctx *appctx)
 {
        task_destroy(appctx->t);
-       if (MT_LIST_ADDED(&appctx->buffer_wait.list))
-               MT_LIST_DEL(&appctx->buffer_wait.list);
+       if (LIST_ADDED(&appctx->buffer_wait.list))
+               LIST_DEL_INIT(&appctx->buffer_wait.list);
 
        pool_free(pool_head_appctx, appctx);
        _HA_ATOMIC_SUB(&nb_applets, 1);
index 812808c..47e4f44 100644 (file)
@@ -851,8 +851,8 @@ static inline int channel_alloc_buffer(struct channel *chn, struct buffer_wait *
        if (b_alloc_margin(&chn->buf, margin) != NULL)
                return 1;
 
-       if (!MT_LIST_ADDED(&wait->list))
-               MT_LIST_ADDQ(&ti->buffer_wq, &wait->list);
+       if (!LIST_ADDED(&wait->list))
+               LIST_ADDQ(&ti->buffer_wq, &wait->list);
 
        return 0;
 }
index b76b30b..b5545ab 100644 (file)
@@ -28,7 +28,7 @@
 struct buffer_wait {
        void *target;              /* The waiting object that should be woken up */
        int (*wakeup_cb)(void *);  /* The function used to wake up the <target>, passed as argument */
-       struct mt_list list;        /* Next element in the <buffer_wq> list */
+       struct list list;          /* Next element in the <buffer_wq> list */
 };
 
 #endif /* _HAPROXY_DYNBUF_T_H */
index c26ad21..83c2a98 100644 (file)
@@ -197,7 +197,7 @@ void __offer_buffer(void *from, unsigned int threshold);
 
 static inline void offer_buffers(void *from, unsigned int threshold)
 {
-       if (!MT_LIST_ISEMPTY(&ti->buffer_wq))
+       if (!LIST_ISEMPTY(&ti->buffer_wq))
                __offer_buffer(from, threshold);
 }
 
index 6dc0458..4242a3f 100644 (file)
@@ -45,7 +45,7 @@ struct thread_info {
 #ifdef CONFIG_HAP_LOCAL_POOLS
        struct list pool_lru_head;                         /* oldest objects   */
 #endif
-       struct mt_list buffer_wq;  /* buffer waiters */
+       struct list buffer_wq;     /* buffer waiters */
 
        /* pad to cache line (64B) */
        char __pad[0];            /* unused except to check remaining room */
index a49ca2c..7226def 100644 (file)
@@ -1012,11 +1012,11 @@ struct buffer *check_get_buf(struct check *check, struct buffer *bptr)
 {
        struct buffer *buf = NULL;
 
-       if (likely(!MT_LIST_ADDED(&check->buf_wait.list)) &&
+       if (likely(!LIST_ADDED(&check->buf_wait.list)) &&
            unlikely((buf = b_alloc_margin(bptr, 0)) == NULL)) {
                check->buf_wait.target = check;
                check->buf_wait.wakeup_cb = check_buf_available;
-               MT_LIST_ADDQ(&ti->buffer_wq, &check->buf_wait.list);
+               LIST_ADDQ(&ti->buffer_wq, &check->buf_wait.list);
        }
        return buf;
 }
@@ -1039,7 +1039,7 @@ const char *init_check(struct check *check, int type)
 
        check->bi = BUF_NULL;
        check->bo = BUF_NULL;
-       MT_LIST_INIT(&check->buf_wait.list);
+       LIST_INIT(&check->buf_wait.list);
 
        check->wait_list.tasklet = tasklet_new();
        if (!check->wait_list.tasklet)
index 395fa8a..a6d1d40 100644 (file)
@@ -33,7 +33,7 @@ int init_buffer()
                return 0;
 
        for (thr = 0; thr < MAX_THREADS; thr++)
-               MT_LIST_INIT(&ha_thread_info[thr].buffer_wq);
+               LIST_INIT(&ha_thread_info[thr].buffer_wq);
 
 
        /* The reserved buffer is what we leave behind us. Thus we always need
@@ -99,8 +99,7 @@ void buffer_dump(FILE *o, struct buffer *b, int from, int to)
 /* see offer_buffer() for details */
 void __offer_buffer(void *from, unsigned int threshold)
 {
-       struct buffer_wait *wait;
-       struct mt_list *elt1, elt2;
+       struct buffer_wait *wait, *wait_back;
        int avail;
 
        /* For now, we consider that all objects need 1 buffer, so we can stop
@@ -114,14 +113,14 @@ void __offer_buffer(void *from, unsigned int threshold)
         */
        avail = pool_head_buffer->allocated - pool_head_buffer->used - global.tune.reserved_bufs / 2;
 
-       mt_list_for_each_entry_safe(wait, &ti->buffer_wq, list, elt1, elt2) {
+       list_for_each_entry_safe(wait, wait_back, &ti->buffer_wq, list) {
                if (avail <= threshold)
                        break;
 
                if (wait->target == from || !wait->wakeup_cb(wait->target))
                        continue;
 
-               MT_LIST_DEL_SAFE(elt1);
+               LIST_DEL_INIT(&wait->list);
                avail--;
        }
 }
index 4f9cbd0..f756609 100644 (file)
@@ -1985,7 +1985,7 @@ spoe_create_appctx(struct spoe_config *conf)
        SPOE_APPCTX(appctx)->buffer          = BUF_NULL;
        SPOE_APPCTX(appctx)->cur_fpa         = 0;
 
-       MT_LIST_INIT(&SPOE_APPCTX(appctx)->buffer_wait.list);
+       LIST_INIT(&SPOE_APPCTX(appctx)->buffer_wait.list);
        SPOE_APPCTX(appctx)->buffer_wait.target = appctx;
        SPOE_APPCTX(appctx)->buffer_wait.wakeup_cb = (int (*)(void *))spoe_wakeup_appctx;
 
@@ -2834,21 +2834,21 @@ spoe_acquire_buffer(struct buffer *buf, struct buffer_wait *buffer_wait)
        if (buf->size)
                return 1;
 
-       if (MT_LIST_ADDED(&buffer_wait->list))
-               MT_LIST_DEL(&buffer_wait->list);
+       if (LIST_ADDED(&buffer_wait->list))
+               LIST_DEL_INIT(&buffer_wait->list);
 
        if (b_alloc_margin(buf, global.tune.reserved_bufs))
                return 1;
 
-       MT_LIST_ADDQ(&ti->buffer_wq, &buffer_wait->list);
+       LIST_ADDQ(&ti->buffer_wq, &buffer_wait->list);
        return 0;
 }
 
 static void
 spoe_release_buffer(struct buffer *buf, struct buffer_wait *buffer_wait)
 {
-       if (MT_LIST_ADDED(&buffer_wait->list))
-               MT_LIST_DEL(&buffer_wait->list);
+       if (LIST_ADDED(&buffer_wait->list))
+               LIST_DEL_INIT(&buffer_wait->list);
 
        /* Release the buffer if needed */
        if (buf->size) {
@@ -2882,7 +2882,7 @@ spoe_create_context(struct stream *s, struct filter *filter)
        ctx->events      = conf->agent->events;
        ctx->groups      = &conf->agent->groups;
        ctx->buffer      = BUF_NULL;
-       MT_LIST_INIT(&ctx->buffer_wait.list);
+       LIST_INIT(&ctx->buffer_wait.list);
        ctx->buffer_wait.target = ctx;
        ctx->buffer_wait.wakeup_cb = (int (*)(void *))spoe_wakeup_context;
        LIST_INIT(&ctx->list);
index 7c88e1a..855cb5a 100644 (file)
@@ -602,11 +602,11 @@ static inline struct buffer *fcgi_get_buf(struct fcgi_conn *fconn, struct buffer
 {
        struct buffer *buf = NULL;
 
-       if (likely(!MT_LIST_ADDED(&fconn->buf_wait.list)) &&
+       if (likely(!LIST_ADDED(&fconn->buf_wait.list)) &&
            unlikely((buf = b_alloc_margin(bptr, 0)) == NULL)) {
                fconn->buf_wait.target = fconn;
                fconn->buf_wait.wakeup_cb = fcgi_buf_available;
-               MT_LIST_ADDQ(&ti->buffer_wq, &fconn->buf_wait.list);
+               LIST_ADDQ(&ti->buffer_wq, &fconn->buf_wait.list);
        }
        return buf;
 }
@@ -758,7 +758,7 @@ static int fcgi_init(struct connection *conn, struct proxy *px, struct session *
        br_init(fconn->mbuf, sizeof(fconn->mbuf) / sizeof(fconn->mbuf[0]));
        fconn->streams_by_id = EB_ROOT;
        LIST_INIT(&fconn->send_list);
-       MT_LIST_INIT(&fconn->buf_wait.list);
+       LIST_INIT(&fconn->buf_wait.list);
 
        conn->ctx = fconn;
 
@@ -837,8 +837,8 @@ static void fcgi_release(struct fcgi_conn *fconn)
 
                TRACE_DEVEL("freeing fconn", FCGI_EV_FCONN_END, conn);
 
-               if (MT_LIST_ADDED(&fconn->buf_wait.list))
-                       MT_LIST_DEL(&fconn->buf_wait.list);
+               if (LIST_ADDED(&fconn->buf_wait.list))
+                       LIST_DEL_INIT(&fconn->buf_wait.list);
 
                fcgi_release_buf(fconn, &fconn->dbuf);
                fcgi_release_mbuf(fconn);
index 76fd402..b2e6ece 100644 (file)
@@ -416,11 +416,11 @@ static inline struct buffer *h1_get_buf(struct h1c *h1c, struct buffer *bptr)
 {
        struct buffer *buf = NULL;
 
-       if (likely(!MT_LIST_ADDED(&h1c->buf_wait.list)) &&
+       if (likely(!LIST_ADDED(&h1c->buf_wait.list)) &&
            unlikely((buf = b_alloc_margin(bptr, 0)) == NULL)) {
                h1c->buf_wait.target = h1c;
                h1c->buf_wait.wakeup_cb = h1_buf_available;
-               MT_LIST_ADDQ(&ti->buffer_wq, &h1c->buf_wait.list);
+               LIST_ADDQ(&ti->buffer_wq, &h1c->buf_wait.list);
        }
        return buf;
 }
@@ -697,7 +697,7 @@ static int h1_init(struct connection *conn, struct proxy *proxy, struct session
        h1c->h1s   = NULL;
        h1c->task  = NULL;
 
-       MT_LIST_INIT(&h1c->buf_wait.list);
+       LIST_INIT(&h1c->buf_wait.list);
        h1c->wait_event.tasklet = tasklet_new();
        if (!h1c->wait_event.tasklet)
                goto fail;
@@ -785,8 +785,8 @@ static void h1_release(struct h1c *h1c)
                }
 
 
-               if (MT_LIST_ADDED(&h1c->buf_wait.list))
-                       MT_LIST_DEL(&h1c->buf_wait.list);
+               if (LIST_ADDED(&h1c->buf_wait.list))
+                       LIST_DEL_INIT(&h1c->buf_wait.list);
 
                h1_release_buf(h1c, &h1c->ibuf);
                h1_release_buf(h1c, &h1c->obuf);
index 7fcade5..9272ae4 100644 (file)
@@ -798,11 +798,11 @@ static inline struct buffer *h2_get_buf(struct h2c *h2c, struct buffer *bptr)
 {
        struct buffer *buf = NULL;
 
-       if (likely(!MT_LIST_ADDED(&h2c->buf_wait.list)) &&
+       if (likely(!LIST_ADDED(&h2c->buf_wait.list)) &&
            unlikely((buf = b_alloc_margin(bptr, 0)) == NULL)) {
                h2c->buf_wait.target = h2c;
                h2c->buf_wait.wakeup_cb = h2_buf_available;
-               MT_LIST_ADDQ(&ti->buffer_wq, &h2c->buf_wait.list);
+               LIST_ADDQ(&ti->buffer_wq, &h2c->buf_wait.list);
        }
        return buf;
 }
@@ -979,7 +979,7 @@ static int h2_init(struct connection *conn, struct proxy *prx, struct session *s
        LIST_INIT(&h2c->send_list);
        LIST_INIT(&h2c->fctl_list);
        LIST_INIT(&h2c->blocked_list);
-       MT_LIST_INIT(&h2c->buf_wait.list);
+       LIST_INIT(&h2c->buf_wait.list);
 
        conn->ctx = h2c;
 
@@ -1066,8 +1066,8 @@ static void h2_release(struct h2c *h2c)
                TRACE_DEVEL("freeing h2c", H2_EV_H2C_END, conn);
                hpack_dht_free(h2c->ddht);
 
-               if (MT_LIST_ADDED(&h2c->buf_wait.list))
-                       MT_LIST_DEL(&h2c->buf_wait.list);
+               if (LIST_ADDED(&h2c->buf_wait.list))
+                       LIST_DEL_INIT(&h2c->buf_wait.list);
 
                h2_release_buf(h2c, &h2c->dbuf);
                h2_release_mbuf(h2c);
index 7e5f5e5..6fca1d1 100644 (file)
@@ -390,7 +390,7 @@ struct stream *stream_new(struct session *sess, enum obj_type *origin)
        /* OK, we're keeping the stream, so let's properly initialize the stream */
        LIST_INIT(&s->back_refs);
 
-       MT_LIST_INIT(&s->buffer_wait.list);
+       LIST_INIT(&s->buffer_wait.list);
        s->buffer_wait.target = s;
        s->buffer_wait.wakeup_cb = stream_buf_available;
 
@@ -594,8 +594,8 @@ static void stream_free(struct stream *s)
                put_pipe(s->res.pipe);
 
        /* We may still be present in the buffer wait queue */
-       if (MT_LIST_ADDED(&s->buffer_wait.list))
-               MT_LIST_DEL(&s->buffer_wait.list);
+       if (LIST_ADDED(&s->buffer_wait.list))
+               LIST_DEL_INIT(&s->buffer_wait.list);
 
        if (s->req.buf.size || s->res.buf.size) {
                b_free(&s->req.buf);
@@ -727,13 +727,13 @@ static void stream_free(struct stream *s)
  */
 static int stream_alloc_work_buffer(struct stream *s)
 {
-       if (MT_LIST_ADDED(&s->buffer_wait.list))
-               MT_LIST_DEL(&s->buffer_wait.list);
+       if (LIST_ADDED(&s->buffer_wait.list))
+               LIST_DEL_INIT(&s->buffer_wait.list);
 
        if (b_alloc_margin(&s->res.buf, 0))
                return 1;
 
-       MT_LIST_ADDQ(&ti->buffer_wq, &s->buffer_wait.list);
+       LIST_ADDQ(&ti->buffer_wq, &s->buffer_wait.list);
        return 0;
 }
 
@@ -2849,7 +2849,7 @@ static int stats_dump_full_strm_to_buffer(struct stream_interface *si, struct st
                chunk_appendf(&trash,
                             "  flags=0x%x, conn_retries=%d, srv_conn=%p, pend_pos=%p waiting=%d\n",
                             strm->flags, strm->si[1].conn_retries, strm->srv_conn, strm->pend_pos,
-                            MT_LIST_ADDED(&strm->buffer_wait.list));
+                            LIST_ADDED(&strm->buffer_wait.list));
 
                chunk_appendf(&trash,
                             "  frontend=%s (id=%u mode=%s), listener=%s (id=%u)",