From nobody Thu Feb 5 21:54:15 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4f6WFz5W10z6RGqC for ; Thu, 05 Feb 2026 21:54:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4f6WFz4Frxz3SBT for ; Thu, 05 Feb 2026 21:54:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1770328455; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hUUUZSW37XWOocxWVzNLeoXAgybLONq4udHDj0qGRss=; b=jlH+zc6WWWt1aMNPhX7vt3++cuM/dnnenArsjcO12vvaui0fIZ2ZyrN5eHbwdlzW2vgB02 7vOrDZk1/14o8zRKc8PhXRHzI61tO19HFS727z4p2MTkD1D9cQmKlg961qmz3bFqTzYNwb Qq0ASe5jY4V+8JBYCBAIHDUM4Yie35fSI49vfmMAVxEUK1erDO/OFpqjOLqNQtjvT70IbA SMjFvi5XVGTW5CFDNumVHItHqqE2hk3iBEbCBkbjPZMCJlBCfipBXyXZr6QPoRmr41TmxV dKwS+QXzhBw1V89qAhjqfSVXm/Xr2AR7dMz3gSNJbKXpCRSEEGz3MScPJoyuvQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1770328455; a=rsa-sha256; cv=none; b=W7zWuXux+MsGav5Q6hWoPIx28/9S6XnqzVnff43aq6qhYS3ZScCJuuB3+GUFrxACDxeR98 tUrM8QwPIWOTgX0CEGYZlrGCmX+8gSEuB/zPGhZxtixjIt/ZDsh1HAAtzQEZ/R/DtLLkLz Xjjq1Np1jzBCXZvWtmG/uZyQtslc2EBsZqXrgv3W1i8puTlHdwC0eHcAtwLdcg7C73qi2c jBpT204A7WycCA5Iz7STixe/26E1dADSWurwI/RUfBYQV0NFzAl7DPlKsBiuK/TzLqfQbH fS6alyQRU5jyi6iyECSFoApVG0rC+5nfy236bTyXHV1LkRzSrVj5I263Ltueow== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1770328455; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hUUUZSW37XWOocxWVzNLeoXAgybLONq4udHDj0qGRss=; b=hHLT6uc/dgB4VFtZZCY7e1Q0CZ79iDeZLHwcCBtiWOmjEqq1aPYbl6FwOjNBQHCfynTv7/ MLWZMRPlkoqLJH9ZSEJ5X0PavOVXp+TWmAArLKiccHg3lROg1FbIDM1qJg45iyyUZ/q9Me fN1P5o4Rm8j+cr+0ofEzikleuJW2Q4Jogw6rbVS+K+osgV2C9Lv84miPWaIlU+/XCV3xdL rzhvn+MoQI0681SudJB5+UtxQdRC2Y2HJTSzyDqeH/9VZFGOkbYgN3+WZ6M8b0yqATtCs7 QFdLVb2m/Q6tap5wCtjbrQN0yaM+ClIlfqiAnea2uWXHCg5xJOgySbBBS6W9cg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4f6WFz3XgLznkG for ; Thu, 05 Feb 2026 21:54:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 19900 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 05 Feb 2026 21:54:15 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Cheng Cui From: Marius Strobl Subject: git: a327d997f5a1 - stable/14 - siftr: flush pkt_nodes to the log file in batch List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: marius X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: a327d997f5a106d8ec2fe5255aaf63127bfe6a69 Auto-Submitted: auto-generated Date: Thu, 05 Feb 2026 21:54:15 +0000 Message-Id: <69851187.19900.7246bd28@gitrepo.freebsd.org> The branch stable/14 has been updated by marius: URL: https://cgit.FreeBSD.org/src/commit/?id=a327d997f5a106d8ec2fe5255aaf63127bfe6a69 commit a327d997f5a106d8ec2fe5255aaf63127bfe6a69 Author: Cheng Cui AuthorDate: 2023-07-25 13:53:55 +0000 Commit: Marius Strobl CommitDate: 2026-02-05 21:54:06 +0000 siftr: flush pkt_nodes to the log file in batch Reviewed by: rscheff, tuexen Differential Revision: https://reviews.freebsd.org/D41175 (cherry picked from commit fafb03ab4254ab0d3927bc8ec22e4ba432efdbeb) --- sys/netinet/siftr.c | 73 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 18 deletions(-) diff --git a/sys/netinet/siftr.c b/sys/netinet/siftr.c index 255714cec0b1..9709ced92fd6 100644 --- a/sys/netinet/siftr.c +++ b/sys/netinet/siftr.c @@ -372,12 +372,12 @@ siftr_new_hash_node(struct flow_info info, int dir, } } -static void -siftr_process_pkt(struct pkt_node * pkt_node) +static int +siftr_process_pkt(struct pkt_node * pkt_node, char *buf) { struct flow_hash_node *hash_node; struct listhead *counter_list; - struct ale *log_buf; + int ret_sz; if (pkt_node->flowid == 0) { panic("%s: flowid not available", __func__); @@ -387,7 +387,7 @@ siftr_process_pkt(struct pkt_node * pkt_node) hash_node = siftr_find_flow(counter_list, pkt_node->flowid); if (hash_node == NULL) { - return; + return 0; } else if (siftr_pkts_per_log > 1) { /* * Taking the remainder of the counter divided @@ -403,16 +403,11 @@ siftr_process_pkt(struct pkt_node * pkt_node) * we wrote a log message for this connection, return. */ if (hash_node->counter > 0) - return; + return 0; } - log_buf = alq_getn(siftr_alq, MAX_LOG_MSG_LEN, ALQ_WAITOK); - - if (log_buf == NULL) - return; /* Should only happen if the ALQ is shutting down. */ - /* Construct a log message. */ - log_buf->ae_bytesused = snprintf(log_buf->ae_data, MAX_LOG_MSG_LEN, + ret_sz = snprintf(buf, MAX_LOG_MSG_LEN, "%c,%jd.%06ld,%s,%hu,%s,%hu,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u," "%u,%u,%u,%u,%u,%u,%u,%u\n", direction[pkt_node->direction], @@ -444,7 +439,7 @@ siftr_process_pkt(struct pkt_node * pkt_node) pkt_node->flowid, pkt_node->flowtype); - alq_post_flags(siftr_alq, log_buf, 0); + return ret_sz; } static void @@ -454,6 +449,9 @@ siftr_pkt_manager_thread(void *arg) STAILQ_HEAD_INITIALIZER(tmp_pkt_queue); struct pkt_node *pkt_node, *pkt_node_temp; uint8_t draining; + struct ale *log_buf; + int ret_sz, cnt; + char *bufp; draining = 2; @@ -489,12 +487,51 @@ siftr_pkt_manager_thread(void *arg) */ mtx_unlock(&siftr_pkt_mgr_mtx); - /* Flush all pkt_nodes to the log file. */ - STAILQ_FOREACH_SAFE(pkt_node, &tmp_pkt_queue, nodes, - pkt_node_temp) { - siftr_process_pkt(pkt_node); - STAILQ_REMOVE_HEAD(&tmp_pkt_queue, nodes); - free(pkt_node, M_SIFTR_PKTNODE); +try_again: + pkt_node = STAILQ_FIRST(&tmp_pkt_queue); + if (pkt_node != NULL) { + if (STAILQ_NEXT(pkt_node, nodes) != NULL) { + cnt = 3; + } else { + cnt = 1; + } + + log_buf = alq_getn(siftr_alq, MAX_LOG_MSG_LEN * cnt, + ALQ_WAITOK); + + if (log_buf != NULL) { + log_buf->ae_bytesused = 0; + bufp = log_buf->ae_data; + } else { + /* + * Should only happen if the ALQ is shutting + * down. + */ + bufp = NULL; + } + + /* Flush all pkt_nodes to the log file. */ + STAILQ_FOREACH_SAFE(pkt_node, &tmp_pkt_queue, nodes, + pkt_node_temp) { + if (log_buf != NULL) { + ret_sz = siftr_process_pkt(pkt_node, + bufp); + bufp += ret_sz; + log_buf->ae_bytesused += ret_sz; + cnt--; + } + + STAILQ_REMOVE_HEAD(&tmp_pkt_queue, nodes); + free(pkt_node, M_SIFTR_PKTNODE); + + if (cnt <= 0 && !STAILQ_EMPTY(&tmp_pkt_queue)) { + alq_post_flags(siftr_alq, log_buf, 0); + goto try_again; + } + } + if (log_buf != NULL) { + alq_post_flags(siftr_alq, log_buf, 0); + } } KASSERT(STAILQ_EMPTY(&tmp_pkt_queue),