]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
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>
Sat, 20 Feb 2021 11:38:18 +0000 (12:38 +0100)
There's no point anymore in keeping mt_lists for the buffer_wait and
buffer_wq since it's thread-local now.

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 f6d764d82c83f7dd14815e2e6c32c1eb8e2d0175..38ffaf7175cba3f5432dc8a73af1ccd0ffaefaf8 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 812808c0e744f5eb257a4201ee9fe6d449568577..47e4f44278319f91678021f809f7f3703a9de0eb 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 b76b30bdce3175169eb5029289f45e67390043fc..b5545ab2697cd8c31b239781b0fd34e0a870caa4 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 c26ad21f6343bce271e3cb56197a6b32192e3c3f..83c2a9827800bd2696f24e383e2d87d8b01625be 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 6dc0458519d4e78f00e7f412af8aaaecfca3ebac..4242a3f7b01bce385ec6894beddecefb565c9ce9 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 ff4effa179edad229e22a2109eba7cab5d0afd51..6451dcf15c3dca9aca2403b09596eb5be8de4f90 100644 (file)
@@ -1015,11 +1015,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;
 }
@@ -1042,7 +1042,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 395fa8a97875b45c71968af3cd93e4ac161426fb..a6d1d40ac0f89d033411e77917fc5e4a860dc685 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 27a15b6c1685168d7b89371249a5f4785d22c2d2..eee77cbed7452b35bfd0dab2bdcff6365d696f38 100644 (file)
@@ -1973,7 +1973,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;
 
@@ -2822,21 +2822,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) {
@@ -2870,7 +2870,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 2ff7aa9098965042a819d94b6664a6f1486cf1ed..464a075a9608adf96433ad78c4398cbfbf07d6dd 100644 (file)
@@ -604,11 +604,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;
 }
@@ -766,7 +766,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;
 
@@ -845,8 +845,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 077f4ea2dce5fbfadb8393c360bcd636e0f3a675..8e17d727d62b029c9227781be27b59cacc5f63d9 100644 (file)
@@ -448,11 +448,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;
 }
@@ -798,7 +798,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;
@@ -913,8 +913,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 cfa5f8c4d447607c2dd8b477627dc4edf40dd2db..30bedc3e61539e488c2bfe0864830b8f9b31c90d 100644 (file)
@@ -806,11 +806,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;
 }
@@ -987,7 +987,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;
 
@@ -1074,8 +1074,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 d7472116232d6605ce7f2171ed9b50a590877495..29d54c777e2cf83501978481e403c5d86a865510 100644 (file)
@@ -419,7 +419,7 @@ struct stream *stream_new(struct session *sess, enum obj_type *origin, struct bu
        /* 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;
 
@@ -634,8 +634,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);
@@ -767,13 +767,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;
 }
 
@@ -2885,7 +2885,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)",