From 0eef48c4be5ae8d9de5fed4daaa1954323e08b96 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 17 Nov 2022 16:58:47 +1100 Subject: tcp: Unify tcp_defer_handler and tcp_splice_defer_handler() These two functions each step through non-spliced and spliced connections respectively and clean up entries for closed connections. To avoid scanning the connection table twice, we merge these into a single function which scans the unified table and performs the appropriate sort of cleanup action on each one. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- tcp_splice.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) (limited to 'tcp_splice.c') diff --git a/tcp_splice.c b/tcp_splice.c index c986a9c..ad2b216 100644 --- a/tcp_splice.c +++ b/tcp_splice.c @@ -111,7 +111,6 @@ static void tcp_splice_conn_epoll_events(uint16_t events, *b |= (events & B_OUT_WAIT) ? EPOLLOUT : 0; } -static void tcp_splice_destroy(struct ctx *c, struct tcp_splice_conn *conn); static int tcp_splice_epoll_ctl(const struct ctx *c, struct tcp_splice_conn *conn); @@ -257,7 +256,7 @@ void tcp_splice_conn_update(struct ctx *c, struct tcp_splice_conn *new) * @c: Execution context * @conn: Connection pointer */ -static void tcp_splice_destroy(struct ctx *c, struct tcp_splice_conn *conn) +void tcp_splice_destroy(struct ctx *c, struct tcp_splice_conn *conn) { if (conn->events & SPLICE_ESTABLISHED) { /* Flushing might need to block: don't recycle them. */ @@ -849,24 +848,3 @@ void tcp_splice_timer(struct ctx *c) tcp_splice_pipe_refill(c); } - -/** - * tcp_splice_defer_handler() - Close connections without timer on file pressure - * @c: Execution context - */ -void tcp_splice_defer_handler(struct ctx *c) -{ - int max_conns = c->tcp.conn_count / 100 * TCP_SPLICE_CONN_PRESSURE; - int max_files = c->nofile / 100 * TCP_SPLICE_FILE_PRESSURE; - struct tcp_splice_conn *conn; - - if (c->tcp.conn_count < MIN(max_files / 6, max_conns)) - return; - - for (conn = CONN(c->tcp.conn_count - 1); conn >= CONN(0); conn--) { - if (!conn->c.spliced) - continue; - if (conn->flags & CLOSING) - tcp_splice_destroy(c, conn); - } -} -- cgit v1.2.3