[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <09feef91b51f675195b5b1b9a854d844c9999c0cebb429d785fe60f6c787dc8b@mail.kernel.org>
Date: Fri, 31 Oct 2025 16:20:49 +0000 (UTC)
From: bot+bpf-ci@...nel.org
To: alexis.lothore@...tlin.com,ast@...nel.org,daniel@...earbox.net,andrii@...nel.org,martin.lau@...ux.dev,eddyz87@...il.com,song@...nel.org,yonghong.song@...ux.dev,john.fastabend@...il.com,kpsingh@...nel.org,sdf@...ichev.me,haoluo@...gle.com,jolsa@...nel.org,shuah@...nel.org
Cc: ebpf@...uxfoundation.org,bastien.curutchet@...tlin.com,thomas.petazzoni@...tlin.com,bpf@...r.kernel.org,linux-kselftest@...r.kernel.org,linux-kernel@...r.kernel.org,alexis.lothore@...tlin.com,ast@...nel.org,andrii@...nel.org,daniel@...earbox.net,martin.lau@...nel.org,eddyz87@...il.com,yonghong.song@...ux.dev,clm@...a.com,ihor.solodrai@...ux.dev
Subject: Re: [PATCH bpf-next 2/4] selftests/bpf: integrate test_tc_edt into test_progs
```
commit fb0c5cfad37eaad30f584caaf53fe9824026bc92
Author: Alexis Lothoré (eBPF Foundation) <alexis.lothore@...tlin.com>
selftests/bpf: integrate test_tc_edt into test_progs
This patch converts test_tc_edt.sh to the test_progs framework,
creating a new test that measures BPF-based traffic shaping to verify
that the resulting rate matches 5Mbps within a 2% error margin.
> diff --git a/tools/testing/selftests/bpf/prog_tests/test_tc_edt.c b/tools/testing/selftests/bpf/prog_tests/test_tc_edt.c
> new file mode 100644
> index 000000000..a77e48fdf
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/test_tc_edt.c
[ ... ]
> +#define TARGET_RATE_MBPS 5.0
> +#define RATE_ERROR_PERCENT 2.0
[ ... ]
> +static void run_test(void)
> +{
> + __u64 rx_bytes_start, rx_bytes_end;
> + double rate_mbps, rate_error;
> + pthread_t server_thread = 0;
> + struct connection *conn;
> + __u64 ts_start, ts_end;
> + int ret;
> +
> +
> + conn = setup_connection();
> + if (!ASSERT_OK_PTR(conn, "setup client and server connection"))
> + return;
> +
> + ret = pthread_create(&server_thread, NULL, run_server,
> + (void *)(&conn->server_conn_fd));
> + if (!ASSERT_OK(ret, "start server rx thread"))
> + goto end_cleanup_conn;
> + if (!ASSERT_OK(read_rx_bytes(&rx_bytes_start), "read rx_bytes"))
> + goto end_kill_thread;
> + ts_start = get_time_ns();
> + while (true) {
> + send(conn->client_conn_fd, (void *)tx_buffer, BUFFER_LEN, 0);
> + ts_end = get_time_ns();
> + if ((ts_end - ts_start)/100000 >= TIMEOUT_MS) {
^^^^^^
Does this time conversion use the correct divisor? The timeout check
appears to divide nanoseconds by 100000, but TIMEOUT_MS is 2000
milliseconds. Converting nanoseconds to milliseconds requires dividing
by 1000000, not 100000. With the current calculation, the timeout would
trigger after 200 milliseconds rather than 2000 milliseconds.
> + tx_timeout = true;
> + ret = read_rx_bytes(&rx_bytes_end);
> + if (!ASSERT_OK(ret, "read_rx_bytes"))
> + goto end_cleanup_conn;
> + break;
> + }
> + }
> +
> + rate_mbps = (rx_bytes_end - rx_bytes_start) /
> + ((ts_end - ts_start) / 1000.0);
^^^^^^
Can this rate calculation produce the correct units? The numerator is in
bytes, and the denominator (nanoseconds / 1000.0) is in microseconds,
giving bytes per microsecond which equals megabytes per second (MB/s).
However, the commit message states the test verifies "5Mbps" (megabits
per second), and TARGET_RATE_MBPS suggests the same. Converting MB/s to
Mbps requires multiplying by 8 (bits per byte), which appears to be
missing. Is the test measuring in the wrong units, or is there a naming
inconsistency?
> + rate_error =
> + fabs((rate_mbps - TARGET_RATE_MBPS) * 100.0 / TARGET_RATE_MBPS);
> + fprintf(stderr, "Rate:\t%f\nError:\t%f\n", rate_mbps, rate_error);
> +
> + ASSERT_LE(rate_error, RATE_ERROR_PERCENT,
> + "rate error is lower than threshold");
> +
> +end_kill_thread:
> + tx_timeout = true;
> +end_cleanup_conn:
> + cleanup_connection(conn);
> +}
```
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
In-Reply-To-Subject: `selftests/bpf: integrate test_tc_edt into test_progs`
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/18978170972
Powered by blists - more mailing lists