MINOR: dynbuf: use regular lists instead of mt_lists for buffer_wait

There's no point anymore in keeping mt_lists for the buffer_wait and
buffer_wq since it's thread-local now.
This commit is contained in:
Willy Tarreau 2021-02-20 11:49:49 +01:00
parent e8e5091510
commit 90f366b595
12 changed files with 44 additions and 45 deletions

View 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->process = task_run_applet;
appctx->t->context = appctx; 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.target = appctx;
appctx->buffer_wait.wakeup_cb = appctx_buf_available; appctx->buffer_wait.wakeup_cb = appctx_buf_available;
_HA_ATOMIC_ADD(&nb_applets, 1); _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) static inline void __appctx_free(struct appctx *appctx)
{ {
task_destroy(appctx->t); task_destroy(appctx->t);
if (MT_LIST_ADDED(&appctx->buffer_wait.list)) if (LIST_ADDED(&appctx->buffer_wait.list))
MT_LIST_DEL(&appctx->buffer_wait.list); LIST_DEL_INIT(&appctx->buffer_wait.list);
pool_free(pool_head_appctx, appctx); pool_free(pool_head_appctx, appctx);
_HA_ATOMIC_SUB(&nb_applets, 1); _HA_ATOMIC_SUB(&nb_applets, 1);

View 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) if (b_alloc_margin(&chn->buf, margin) != NULL)
return 1; return 1;
if (!MT_LIST_ADDED(&wait->list)) if (!LIST_ADDED(&wait->list))
MT_LIST_ADDQ(&ti->buffer_wq, &wait->list); LIST_ADDQ(&ti->buffer_wq, &wait->list);
return 0; return 0;
} }

View File

@ -28,7 +28,7 @@
struct buffer_wait { struct buffer_wait {
void *target; /* The waiting object that should be woken up */ 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 */ 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 */ #endif /* _HAPROXY_DYNBUF_T_H */

View File

@ -197,7 +197,7 @@ void __offer_buffer(void *from, unsigned int threshold);
static inline void offer_buffers(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); __offer_buffer(from, threshold);
} }

View File

@ -45,7 +45,7 @@ struct thread_info {
#ifdef CONFIG_HAP_LOCAL_POOLS #ifdef CONFIG_HAP_LOCAL_POOLS
struct list pool_lru_head; /* oldest objects */ struct list pool_lru_head; /* oldest objects */
#endif #endif
struct mt_list buffer_wq; /* buffer waiters */ struct list buffer_wq; /* buffer waiters */
/* pad to cache line (64B) */ /* pad to cache line (64B) */
char __pad[0]; /* unused except to check remaining room */ char __pad[0]; /* unused except to check remaining room */

View File

@ -1015,11 +1015,11 @@ struct buffer *check_get_buf(struct check *check, struct buffer *bptr)
{ {
struct buffer *buf = NULL; 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)) { unlikely((buf = b_alloc_margin(bptr, 0)) == NULL)) {
check->buf_wait.target = check; check->buf_wait.target = check;
check->buf_wait.wakeup_cb = check_buf_available; 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; return buf;
} }
@ -1042,7 +1042,7 @@ const char *init_check(struct check *check, int type)
check->bi = BUF_NULL; check->bi = BUF_NULL;
check->bo = 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(); check->wait_list.tasklet = tasklet_new();
if (!check->wait_list.tasklet) if (!check->wait_list.tasklet)

View File

@ -33,7 +33,7 @@ int init_buffer()
return 0; return 0;
for (thr = 0; thr < MAX_THREADS; thr++) 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 /* 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 */ /* see offer_buffer() for details */
void __offer_buffer(void *from, unsigned int threshold) void __offer_buffer(void *from, unsigned int threshold)
{ {
struct buffer_wait *wait; struct buffer_wait *wait, *wait_back;
struct mt_list *elt1, elt2;
int avail; int avail;
/* For now, we consider that all objects need 1 buffer, so we can stop /* 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; 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) if (avail <= threshold)
break; break;
if (wait->target == from || !wait->wakeup_cb(wait->target)) if (wait->target == from || !wait->wakeup_cb(wait->target))
continue; continue;
MT_LIST_DEL_SAFE(elt1); LIST_DEL_INIT(&wait->list);
avail--; avail--;
} }
} }

View File

@ -1973,7 +1973,7 @@ spoe_create_appctx(struct spoe_config *conf)
SPOE_APPCTX(appctx)->buffer = BUF_NULL; SPOE_APPCTX(appctx)->buffer = BUF_NULL;
SPOE_APPCTX(appctx)->cur_fpa = 0; 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.target = appctx;
SPOE_APPCTX(appctx)->buffer_wait.wakeup_cb = (int (*)(void *))spoe_wakeup_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) if (buf->size)
return 1; return 1;
if (MT_LIST_ADDED(&buffer_wait->list)) if (LIST_ADDED(&buffer_wait->list))
MT_LIST_DEL(&buffer_wait->list); LIST_DEL_INIT(&buffer_wait->list);
if (b_alloc_margin(buf, global.tune.reserved_bufs)) if (b_alloc_margin(buf, global.tune.reserved_bufs))
return 1; return 1;
MT_LIST_ADDQ(&ti->buffer_wq, &buffer_wait->list); LIST_ADDQ(&ti->buffer_wq, &buffer_wait->list);
return 0; return 0;
} }
static void static void
spoe_release_buffer(struct buffer *buf, struct buffer_wait *buffer_wait) spoe_release_buffer(struct buffer *buf, struct buffer_wait *buffer_wait)
{ {
if (MT_LIST_ADDED(&buffer_wait->list)) if (LIST_ADDED(&buffer_wait->list))
MT_LIST_DEL(&buffer_wait->list); LIST_DEL_INIT(&buffer_wait->list);
/* Release the buffer if needed */ /* Release the buffer if needed */
if (buf->size) { if (buf->size) {
@ -2870,7 +2870,7 @@ spoe_create_context(struct stream *s, struct filter *filter)
ctx->events = conf->agent->events; ctx->events = conf->agent->events;
ctx->groups = &conf->agent->groups; ctx->groups = &conf->agent->groups;
ctx->buffer = BUF_NULL; 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.target = ctx;
ctx->buffer_wait.wakeup_cb = (int (*)(void *))spoe_wakeup_context; ctx->buffer_wait.wakeup_cb = (int (*)(void *))spoe_wakeup_context;
LIST_INIT(&ctx->list); LIST_INIT(&ctx->list);

View File

@ -604,11 +604,11 @@ static inline struct buffer *fcgi_get_buf(struct fcgi_conn *fconn, struct buffer
{ {
struct buffer *buf = NULL; 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)) { unlikely((buf = b_alloc_margin(bptr, 0)) == NULL)) {
fconn->buf_wait.target = fconn; fconn->buf_wait.target = fconn;
fconn->buf_wait.wakeup_cb = fcgi_buf_available; 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; 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])); br_init(fconn->mbuf, sizeof(fconn->mbuf) / sizeof(fconn->mbuf[0]));
fconn->streams_by_id = EB_ROOT; fconn->streams_by_id = EB_ROOT;
LIST_INIT(&fconn->send_list); LIST_INIT(&fconn->send_list);
MT_LIST_INIT(&fconn->buf_wait.list); LIST_INIT(&fconn->buf_wait.list);
conn->ctx = fconn; conn->ctx = fconn;
@ -845,8 +845,8 @@ static void fcgi_release(struct fcgi_conn *fconn)
TRACE_DEVEL("freeing fconn", FCGI_EV_FCONN_END, conn); TRACE_DEVEL("freeing fconn", FCGI_EV_FCONN_END, conn);
if (MT_LIST_ADDED(&fconn->buf_wait.list)) if (LIST_ADDED(&fconn->buf_wait.list))
MT_LIST_DEL(&fconn->buf_wait.list); LIST_DEL_INIT(&fconn->buf_wait.list);
fcgi_release_buf(fconn, &fconn->dbuf); fcgi_release_buf(fconn, &fconn->dbuf);
fcgi_release_mbuf(fconn); fcgi_release_mbuf(fconn);

View File

@ -448,11 +448,11 @@ static inline struct buffer *h1_get_buf(struct h1c *h1c, struct buffer *bptr)
{ {
struct buffer *buf = NULL; 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)) { unlikely((buf = b_alloc_margin(bptr, 0)) == NULL)) {
h1c->buf_wait.target = h1c; h1c->buf_wait.target = h1c;
h1c->buf_wait.wakeup_cb = h1_buf_available; 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; return buf;
} }
@ -798,7 +798,7 @@ static int h1_init(struct connection *conn, struct proxy *proxy, struct session
h1c->h1s = NULL; h1c->h1s = NULL;
h1c->task = NULL; h1c->task = NULL;
MT_LIST_INIT(&h1c->buf_wait.list); LIST_INIT(&h1c->buf_wait.list);
h1c->wait_event.tasklet = tasklet_new(); h1c->wait_event.tasklet = tasklet_new();
if (!h1c->wait_event.tasklet) if (!h1c->wait_event.tasklet)
goto fail; goto fail;
@ -913,8 +913,8 @@ static void h1_release(struct h1c *h1c)
} }
if (MT_LIST_ADDED(&h1c->buf_wait.list)) if (LIST_ADDED(&h1c->buf_wait.list))
MT_LIST_DEL(&h1c->buf_wait.list); LIST_DEL_INIT(&h1c->buf_wait.list);
h1_release_buf(h1c, &h1c->ibuf); h1_release_buf(h1c, &h1c->ibuf);
h1_release_buf(h1c, &h1c->obuf); h1_release_buf(h1c, &h1c->obuf);

View File

@ -806,11 +806,11 @@ static inline struct buffer *h2_get_buf(struct h2c *h2c, struct buffer *bptr)
{ {
struct buffer *buf = NULL; 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)) { unlikely((buf = b_alloc_margin(bptr, 0)) == NULL)) {
h2c->buf_wait.target = h2c; h2c->buf_wait.target = h2c;
h2c->buf_wait.wakeup_cb = h2_buf_available; 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; 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->send_list);
LIST_INIT(&h2c->fctl_list); LIST_INIT(&h2c->fctl_list);
LIST_INIT(&h2c->blocked_list); LIST_INIT(&h2c->blocked_list);
MT_LIST_INIT(&h2c->buf_wait.list); LIST_INIT(&h2c->buf_wait.list);
conn->ctx = h2c; conn->ctx = h2c;
@ -1074,8 +1074,8 @@ static void h2_release(struct h2c *h2c)
TRACE_DEVEL("freeing h2c", H2_EV_H2C_END, conn); TRACE_DEVEL("freeing h2c", H2_EV_H2C_END, conn);
hpack_dht_free(h2c->ddht); hpack_dht_free(h2c->ddht);
if (MT_LIST_ADDED(&h2c->buf_wait.list)) if (LIST_ADDED(&h2c->buf_wait.list))
MT_LIST_DEL(&h2c->buf_wait.list); LIST_DEL_INIT(&h2c->buf_wait.list);
h2_release_buf(h2c, &h2c->dbuf); h2_release_buf(h2c, &h2c->dbuf);
h2_release_mbuf(h2c); h2_release_mbuf(h2c);

View 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 */ /* OK, we're keeping the stream, so let's properly initialize the stream */
LIST_INIT(&s->back_refs); 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.target = s;
s->buffer_wait.wakeup_cb = stream_buf_available; s->buffer_wait.wakeup_cb = stream_buf_available;
@ -634,8 +634,8 @@ static void stream_free(struct stream *s)
put_pipe(s->res.pipe); put_pipe(s->res.pipe);
/* We may still be present in the buffer wait queue */ /* We may still be present in the buffer wait queue */
if (MT_LIST_ADDED(&s->buffer_wait.list)) if (LIST_ADDED(&s->buffer_wait.list))
MT_LIST_DEL(&s->buffer_wait.list); LIST_DEL_INIT(&s->buffer_wait.list);
if (s->req.buf.size || s->res.buf.size) { if (s->req.buf.size || s->res.buf.size) {
b_free(&s->req.buf); 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) static int stream_alloc_work_buffer(struct stream *s)
{ {
if (MT_LIST_ADDED(&s->buffer_wait.list)) if (LIST_ADDED(&s->buffer_wait.list))
MT_LIST_DEL(&s->buffer_wait.list); LIST_DEL_INIT(&s->buffer_wait.list);
if (b_alloc_margin(&s->res.buf, 0)) if (b_alloc_margin(&s->res.buf, 0))
return 1; return 1;
MT_LIST_ADDQ(&ti->buffer_wq, &s->buffer_wait.list); LIST_ADDQ(&ti->buffer_wq, &s->buffer_wait.list);
return 0; return 0;
} }
@ -2885,7 +2885,7 @@ static int stats_dump_full_strm_to_buffer(struct stream_interface *si, struct st
chunk_appendf(&trash, chunk_appendf(&trash,
" flags=0x%x, conn_retries=%d, srv_conn=%p, pend_pos=%p waiting=%d\n", " 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, 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, chunk_appendf(&trash,
" frontend=%s (id=%u mode=%s), listener=%s (id=%u)", " frontend=%s (id=%u mode=%s), listener=%s (id=%u)",