From nobody Tue Mar 14 20:52:42 2023 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 4Pbm1k3WsVz3yjfH; Tue, 14 Mar 2023 20:52:42 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Pbm1k35VQz3nl3; Tue, 14 Mar 2023 20:52:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678827162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nHWQ0tXH8t0CyQkEAAwl4bWWRbgKg2PAvFS65EgwiMY=; b=IfDlkLd7dtMzjFYMEriWZT8Dg+xWOtgVBgzPLl7HQzqCQc2uLmS8gGH6AEmprj1uOhtJ6e jhQ+B0Q0+EJW/DRroqHJs5L+WldydqknEUvoTxfsRduvp2sg0/0W2fwG/fn93E9fFrQP5l 0l6QDVmgqAImaTN2L61nnuEwTCsxYiDbqyae49cn+h0DF/VK/J2YVyLZKo+TpUE8h5maU4 HzkbbVY3zkI+VTq54WsfcJfFqV7dezW8KTMX1BcIJHCzVrym4Iy6gBiWBjXZGwLyFbBTds NefkI+4Z1YHJ7WHgZey1YmF6AQUEuTLFek42ZcH2TkQ0sKySKB5yNCkAEXVpww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678827162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nHWQ0tXH8t0CyQkEAAwl4bWWRbgKg2PAvFS65EgwiMY=; b=rMF4N8lbmSjWSUHrbUoXE54oxQC0sO8ncdrVP7kxkRLO3mtoCicCeSQpW2UD7krrtS0MAq bqzkfoRf1mrHmJWEPXTitASYapK2+r36P2DvEmv+m4ufR4QMkXKu5eOj4wza/obWgYfdSg +CNNu7x/Q2M51xtVICQP8JvXrUAVrQYuktUwzb8ecIAbXXJYWgARvqRyqweTsSpktTgsMR 0L6fAJ6RO7R0ODSgzmYzGEhqUbUJxl5uzv1q0jtwV0NW7I+2PWrqwHishJOtsOzUdeYeOe 5cBFytWA1ZRDAlM4SZ/iwHEw9PFePwZXW0dSYEQqdsLMIrh78RxpQpCCkIzOIw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1678827162; a=rsa-sha256; cv=none; b=hMe6DQzGFiqhQorO/tCYzFRQ8Vezn9sbBk45EXxEuBreKSljlFB+ga2nrTT4PXs9UhV6DC kGhaFRT5ZcM6vJewKVM3Mt2AzgcZ3Fb34s5bGsO5JJ5hn02vygO1SCu4Ew9tnPtNYybBD1 NvTE9rZ5RqRhf4FzuhoZwbvkV1ITWqd3Eh7fWxejKWzaYFrfQP5ink0uSELH6i+i7f8JFf 5msbEaVa1ZWbQaGBLtmTAIdm0qYFr5TDTkV52Tyg+nB0AwpB1cFoyoO0uI+CJlxTwsm8T0 VMgtF4Wl8Wo6a6MegAkVcMW00wnh4TnI/NxFk0DrjHbHZWBBbFYX3799kKtoZg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Pbm1k28TRzqM3; Tue, 14 Mar 2023 20:52:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 32EKqgn6001978; Tue, 14 Mar 2023 20:52:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32EKqgiM001977; Tue, 14 Mar 2023 20:52:42 GMT (envelope-from git) Date: Tue, 14 Mar 2023 20:52:42 GMT Message-Id: <202303142052.32EKqgiM001977@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vincenzo Maffione Subject: git: 4e31d33bfe67 - stable/13 - netmap: pkt-gen: init all slots of every tx ring 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: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vmaffione X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4e31d33bfe67343d7647242db672ad2d16c7a5f5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by vmaffione: URL: https://cgit.FreeBSD.org/src/commit/?id=4e31d33bfe67343d7647242db672ad2d16c7a5f5 commit 4e31d33bfe67343d7647242db672ad2d16c7a5f5 Author: Vincenzo Maffione AuthorDate: 2023-03-06 17:22:09 +0000 Commit: Vincenzo Maffione CommitDate: 2023-03-14 20:48:42 +0000 netmap: pkt-gen: init all slots of every tx ring sender_body() uses OPT_COPY to copy the frame into the destination slot for the first 100,000 packets. Then it removes OPT_COPY to improve performance. The function always starts with the first tx ring. If multiple tx rings are in use, it is possible that the initial 100k packets will only use the first ring. After OPT_COPY is removed, there may come a time when the first ring is full and sender_body() will move to the next ring which was never initialized. As a result it will send all zero packets. (This was discovered when the receiving NIC reported rx errors.) Before any transmissions, step through every tx ring and set NS_BUF_CHANGED on every slot. That will force send_packets() to initialize the slot when first used. Since it only copies when necessary, it performs better than always setting OPT_COPY. With this change, there is no reason for the "drop copy" code. Submitted by: Brian Poole MFC after: 7 days (cherry picked from commit 506336f2cd1fa0a3ba94bc247d7fad1a71d43ac2) --- tools/tools/netmap/pkt-gen.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tools/tools/netmap/pkt-gen.c b/tools/tools/netmap/pkt-gen.c index b06fef05579d..296208018fd4 100644 --- a/tools/tools/netmap/pkt-gen.c +++ b/tools/tools/netmap/pkt-gen.c @@ -1604,7 +1604,7 @@ sender_body(void *data) uint64_t n = targ->g->npackets / targ->g->nthreads; uint64_t sent = 0; uint64_t event = 0; - int options = targ->g->options | OPT_COPY; + int options = targ->g->options; struct timespec nexttime = { 0, 0}; // XXX silence compiler int rate_limit = targ->g->tx_rate; struct pkt *pkt = &targ->pkt; @@ -1678,6 +1678,19 @@ sender_body(void *data) targ->frags++; } D("frags %u frag_size %u", targ->frags, targ->frag_size); + + /* mark all slots of all rings as changed so initial copy will be done */ + for (i = targ->nmd->first_tx_ring; i <= targ->nmd->last_tx_ring; i++) { + uint32_t j; + struct netmap_slot *slot; + + txring = NETMAP_TXRING(nifp, i); + for (j = 0; j < txring->num_slots; j++) { + slot = &txring->slot[j]; + slot->flags = NS_BUF_CHANGED; + } + } + while (!targ->cancel && (n == 0 || sent < n)) { int rv; @@ -1714,10 +1727,6 @@ sender_body(void *data) /* * scan our queues and send on those with room */ - if (options & OPT_COPY && sent > 100000 && !(targ->g->options & OPT_COPY) ) { - D("drop copy"); - options &= ~OPT_COPY; - } for (i = targ->nmd->first_tx_ring; i <= targ->nmd->last_tx_ring; i++) { int m; uint64_t limit = rate_limit ? tosend : targ->g->burst;