DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Mattias Rönnblom" <hofors@lysator.liu.se>
To: Kevin Laatz <kevin.laatz@intel.com>, dev@dpdk.org
Cc: anatoly.burakov@intel.com,
	"Mattias Rönnblom" <mattias.ronnblom@ericsson.com>
Subject: Re: [PATCH v7 3/4] app/test: add unit tests for lcore poll busyness
Date: Sat, 1 Oct 2022 00:20:54 +0200	[thread overview]
Message-ID: <90833044-c7c3-c753-6b40-b9bb1eb881bf@lysator.liu.se> (raw)
In-Reply-To: <20220914092929.1159773-4-kevin.laatz@intel.com>



On 2022-09-14 11:29, Kevin Laatz wrote:
> Add API unit tests and perf unit tests for the newly added lcore poll
> busyness feature.
> 
> Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
> ---
>   app/test/meson.build                     |   4 +
>   app/test/test_lcore_poll_busyness_api.c  | 134 +++++++++++++++++++++++
>   app/test/test_lcore_poll_busyness_perf.c |  72 ++++++++++++
>   3 files changed, 210 insertions(+)
>   create mode 100644 app/test/test_lcore_poll_busyness_api.c
>   create mode 100644 app/test/test_lcore_poll_busyness_perf.c
> 
> diff --git a/app/test/meson.build b/app/test/meson.build
> index bf1d81f84a..d543e730a2 100644
> --- a/app/test/meson.build
> +++ b/app/test/meson.build
> @@ -74,6 +74,8 @@ test_sources = files(
>           'test_ipsec_perf.c',
>           'test_kni.c',
>           'test_kvargs.c',
> +        'test_lcore_poll_busyness_api.c',
> +        'test_lcore_poll_busyness_perf.c',
>           'test_lcores.c',
>           'test_logs.c',
>           'test_lpm.c',
> @@ -192,6 +194,7 @@ fast_tests = [
>           ['interrupt_autotest', true, true],
>           ['ipfrag_autotest', false, true],
>           ['lcores_autotest', true, true],
> +        ['lcore_poll_busyness_autotest', true, true],
>           ['logs_autotest', true, true],
>           ['lpm_autotest', true, true],
>           ['lpm6_autotest', true, true],
> @@ -292,6 +295,7 @@ perf_test_names = [
>           'trace_perf_autotest',
>           'ipsec_perf_autotest',
>           'thash_perf_autotest',
> +        'lcore_poll_busyness_perf_autotest'
>   ]
>   
>   driver_test_names = [
> diff --git a/app/test/test_lcore_poll_busyness_api.c b/app/test/test_lcore_poll_busyness_api.c
> new file mode 100644
> index 0000000000..db76322994
> --- /dev/null
> +++ b/app/test/test_lcore_poll_busyness_api.c
> @@ -0,0 +1,134 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2022 Intel Corporation
> + */
> +
> +#include <rte_lcore.h>
> +
> +#include "test.h"
> +
> +/* Arbitrary amount of "work" to simulate busyness with */
> +#define WORK		32
> +#define TIMESTAMP_ITERS	1000000
> +
> +#define LCORE_POLL_BUSYNESS_NOT_SET	-1
> +
> +static int
> +test_lcore_poll_busyness_enable_disable(void)
> +{
> +	int initial_state, curr_state;
> +	bool req_state;
> +
> +	/* Get the initial state */
> +	initial_state = rte_lcore_poll_busyness_enabled();
> +	if (initial_state == -ENOTSUP)
> +		return TEST_SKIPPED;
> +
> +	/* Set state to the inverse of the initial state and check for the change */
> +	req_state = !initial_state;
> +	rte_lcore_poll_busyness_enabled_set(req_state);
> +	curr_state = rte_lcore_poll_busyness_enabled();
> +	if (curr_state != req_state)
> +		return TEST_FAILED;
> +
> +	/* Now change the state back to the original state. By changing it back, both
> +	 * enable and disable will have been tested.
> +	 */
> +	req_state = !curr_state;
> +	rte_lcore_poll_busyness_enabled_set(req_state);
> +	curr_state = rte_lcore_poll_busyness_enabled();
> +	if (curr_state != req_state)
> +		return TEST_FAILED;
> +
> +	return TEST_SUCCESS;
> +}
> +
> +static int
> +test_lcore_poll_busyness_invalid_lcore(void)
> +{
> +	int ret;
> +
> +	/* Check if lcore poll busyness is enabled */
> +	if (rte_lcore_poll_busyness_enabled() == -ENOTSUP)
> +		return TEST_SKIPPED;
> +
> +	/* Only lcore_id <= RTE_MAX_LCORE are valid */
> +	ret = rte_lcore_poll_busyness(RTE_MAX_LCORE);
> +	if (ret != -EINVAL)
> +		return TEST_FAILED;
> +
> +	return TEST_SUCCESS;
> +}
> +
> +static int
> +test_lcore_poll_busyness_inactive_lcore(void)
> +{
> +	int ret;
> +
> +	/* Check if lcore poll busyness is enabled */
> +	if (rte_lcore_poll_busyness_enabled() == -ENOTSUP)
> +		return TEST_SKIPPED;
> +
> +	/* Use the test thread lcore_id for this test. Since it is not a polling
> +	 * application, the busyness is expected to return -1.
> +	 *
> +	 * Note: this will not work with affinitized cores
> +	 */
> +	ret = rte_lcore_poll_busyness(rte_lcore_id());
> +	if (ret != LCORE_POLL_BUSYNESS_NOT_SET)
> +		return TEST_FAILED;
> +
> +	return TEST_SUCCESS;
> +}
> +
> +static void
> +simulate_lcore_poll_busyness(int iters)
> +{
> +	int i;
> +
> +	for (i = 0; i < iters; i++)
> +		RTE_LCORE_POLL_BUSYNESS_TIMESTAMP(WORK);
> +}
> +
> +/* The test cannot know of an application running to test for valid lcore poll
> + * busyness data. For this test, we simulate lcore poll busyness for the
> + * lcore_id of the test thread for testing purposes.
> + */
> +static int
> +test_lcore_poll_busyness_active_lcore(void)
> +{
> +	int ret;
> +
> +	/* Check if lcore poll busyness is enabled */
> +	if (rte_lcore_poll_busyness_enabled() == -ENOTSUP)
> +		return TEST_SKIPPED;
> +
> +	simulate_lcore_poll_busyness(TIMESTAMP_ITERS);
> +
> +	/* After timestamping with "work" many times, lcore poll busyness should be > 0 */
> +	ret = rte_lcore_poll_busyness(rte_lcore_id());
> +	if (ret <= 0)
> +		return TEST_FAILED;
> +
> +	return TEST_SUCCESS;
> +}
> +
> +static struct unit_test_suite lcore_poll_busyness_tests = {
> +	.suite_name = "lcore poll busyness autotest",
> +	.setup = NULL,
> +	.teardown = NULL,
> +	.unit_test_cases = {
> +		TEST_CASE(test_lcore_poll_busyness_enable_disable),
> +		TEST_CASE(test_lcore_poll_busyness_invalid_lcore),
> +		TEST_CASE(test_lcore_poll_busyness_inactive_lcore),
> +		TEST_CASE(test_lcore_poll_busyness_active_lcore),
> +		TEST_CASES_END()
> +	}
> +};
> +
> +static int
> +test_lcore_poll_busyness_api(void)
> +{
> +	return unit_test_suite_runner(&lcore_poll_busyness_tests);
> +}
> +
> +REGISTER_TEST_COMMAND(lcore_poll_busyness_autotest, test_lcore_poll_busyness_api);
> diff --git a/app/test/test_lcore_poll_busyness_perf.c b/app/test/test_lcore_poll_busyness_perf.c
> new file mode 100644
> index 0000000000..5c27d21b00
> --- /dev/null
> +++ b/app/test/test_lcore_poll_busyness_perf.c
> @@ -0,0 +1,72 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2022 Intel Corporation
> + */
> +
> +#include <unistd.h>
> +#include <inttypes.h>
> +
> +#include <rte_lcore.h>
> +#include <rte_cycles.h>
> +
> +#include "test.h"
> +
> +/* Arbitrary amount of "work" to simulate busyness with */
> +#define WORK		32
> +#define TIMESTAMP_ITERS	1000000
> +#define TEST_ITERS	10000
> +
> +static void
> +simulate_lcore_poll_busyness(int iters)
> +{
> +	int i;
> +
> +	for (i = 0; i < iters; i++)
> +		RTE_LCORE_POLL_BUSYNESS_TIMESTAMP(WORK);
> +}
> +
> +static void
> +test_timestamp_perf(void)
> +{
> +	uint64_t start, end, diff;
> +	uint64_t min = UINT64_MAX;
> +	uint64_t max = 0;
> +	uint64_t total = 0;
> +	int i;
> +
> +	for (i = 0; i < TEST_ITERS; i++) {
> +		start = rte_rdtsc();
> +		RTE_LCORE_POLL_BUSYNESS_TIMESTAMP(WORK);

This is how it will look for a thread which is always busy. That's a 
relevant case, but not the only such.

Do one with WORK replaced by (i & 1), and you get the other extreme. 
Applications that poll multiple sources of work before performing any 
actual processing, and which are following your advice about the use of 
the macro, will see these kind of latencies.

> +		end = rte_rdtsc();
> +
> +		diff = end - start;
> +		min = RTE_MIN(diff, min);
> +		max = RTE_MAX(diff, max);
> +		total += diff;
> +	}
> +
> +	printf("### Timestamp perf ###\n");
> +	printf("Min cycles: %"PRIu64"\n", min);
> +	printf("Avg cycles: %"PRIu64"\n", total / TEST_ITERS);
> +	printf("Max cycles: %"PRIu64"\n", max);
> +	printf("\n");
> +}
> +
> +
> +static int
> +test_lcore_poll_busyness_perf(void)
> +{
> +	if (rte_lcore_poll_busyness_enabled()  == -ENOTSUP) {
> +		printf("Lcore poll busyness may be disabled...\n");
> +		return TEST_SKIPPED;
> +	}
> +
> +	/* Initialize and prime the timestamp struct with simulated "work" for this lcore */
> +	simulate_lcore_poll_busyness(10000);
> +
> +	/* Run perf tests */
> +	test_timestamp_perf();
> +
> +	return TEST_SUCCESS;
> +}
> +
> +REGISTER_TEST_COMMAND(lcore_poll_busyness_perf_autotest, test_lcore_poll_busyness_perf);

  reply	other threads:[~2022-09-30 22:20 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-15 13:12 [PATCH v1 1/2] eal: add lcore busyness telemetry Anatoly Burakov
2022-07-15 13:12 ` [PATCH v1 2/2] eal: add cpuset lcore telemetry entries Anatoly Burakov
2022-07-15 13:35 ` [PATCH v1 1/2] eal: add lcore busyness telemetry Burakov, Anatoly
2022-07-15 13:46 ` Jerin Jacob
2022-07-15 14:11   ` Bruce Richardson
2022-07-15 14:18   ` Burakov, Anatoly
2022-07-15 22:13 ` Morten Brørup
2022-07-16 14:38   ` Thomas Monjalon
2022-07-17  3:10   ` Honnappa Nagarahalli
2022-07-17  9:56     ` Morten Brørup
2022-07-18  9:43       ` Burakov, Anatoly
2022-07-18 10:59         ` Morten Brørup
2022-07-19 12:20           ` Thomas Monjalon
2022-07-18 15:46         ` Stephen Hemminger
2022-08-24 16:24 ` [PATCH v2 0/3] Add lcore poll " Kevin Laatz
2022-08-24 16:24   ` [PATCH v2 1/3] eal: add " Kevin Laatz
2022-08-24 16:24   ` [PATCH v2 2/3] eal: add cpuset lcore telemetry entries Kevin Laatz
2022-08-24 16:24   ` [PATCH v2 3/3] doc: add howto guide for lcore poll busyness Kevin Laatz
2022-08-25  7:47   ` [PATCH v2 0/3] Add lcore poll busyness telemetry Morten Brørup
2022-08-25 10:53     ` Kevin Laatz
2022-08-25 15:28 ` [PATCH v3 " Kevin Laatz
2022-08-25 15:28   ` [PATCH v3 1/3] eal: add " Kevin Laatz
2022-08-26  7:05     ` Jerin Jacob
2022-08-26  8:07       ` Bruce Richardson
2022-08-26  8:16         ` Jerin Jacob
2022-08-26  8:29           ` Morten Brørup
2022-08-26 15:27             ` Kevin Laatz
2022-08-26 15:46               ` Morten Brørup
2022-08-29 10:41                 ` Bruce Richardson
2022-08-29 10:53                   ` Thomas Monjalon
2022-08-29 12:36                     ` Kevin Laatz
2022-08-29 12:49                       ` Morten Brørup
2022-08-29 13:37                         ` Kevin Laatz
2022-08-29 13:44                           ` Morten Brørup
2022-08-29 14:21                             ` Kevin Laatz
2022-08-29 11:22                   ` Morten Brørup
2022-08-26 22:06     ` Mattias Rönnblom
2022-08-29  8:23       ` Bruce Richardson
2022-08-29 13:16       ` Kevin Laatz
2022-08-30 10:26       ` Kevin Laatz
2022-08-25 15:28   ` [PATCH v3 2/3] eal: add cpuset lcore telemetry entries Kevin Laatz
2022-08-25 15:28   ` [PATCH v3 3/3] doc: add howto guide for lcore poll busyness Kevin Laatz
2022-09-01 14:39 ` [PATCH v4 0/3] Add lcore poll busyness telemetry Kevin Laatz
2022-09-01 14:39   ` [PATCH v4 1/3] eal: add " Kevin Laatz
2022-09-01 14:39   ` [PATCH v4 2/3] eal: add cpuset lcore telemetry entries Kevin Laatz
2022-09-01 14:39   ` [PATCH v4 3/3] doc: add howto guide for lcore poll busyness Kevin Laatz
2022-09-02 15:58 ` [PATCH v5 0/3] Add lcore poll busyness telemetry Kevin Laatz
2022-09-02 15:58   ` [PATCH v5 1/3] eal: add " Kevin Laatz
2022-09-03 13:33     ` Jerin Jacob
2022-09-06  9:37       ` Kevin Laatz
2022-09-02 15:58   ` [PATCH v5 2/3] eal: add cpuset lcore telemetry entries Kevin Laatz
2022-09-02 15:58   ` [PATCH v5 3/3] doc: add howto guide for lcore poll busyness Kevin Laatz
2022-09-13 13:19 ` [PATCH v6 0/4] Add lcore poll busyness telemetry Kevin Laatz
2022-09-13 13:19   ` [PATCH v6 1/4] eal: add " Kevin Laatz
2022-09-13 13:48     ` Morten Brørup
2022-09-13 13:19   ` [PATCH v6 2/4] eal: add cpuset lcore telemetry entries Kevin Laatz
2022-09-13 13:19   ` [PATCH v6 3/4] app/test: add unit tests for lcore poll busyness Kevin Laatz
2022-09-13 13:19   ` [PATCH v6 4/4] doc: add howto guide " Kevin Laatz
2022-09-14  9:29 ` [PATCH v7 0/4] Add lcore poll busyness telemetry Kevin Laatz
2022-09-14  9:29   ` [PATCH v7 1/4] eal: add " Kevin Laatz
2022-09-14 14:30     ` Stephen Hemminger
2022-09-16 12:35       ` Kevin Laatz
2022-09-19 10:19     ` Konstantin Ananyev
2022-09-22 17:14       ` Kevin Laatz
2022-09-26  9:37         ` Konstantin Ananyev
2022-09-29 12:41           ` Kevin Laatz
2022-09-30 12:32             ` Jerin Jacob
2022-10-01 14:17             ` Konstantin Ananyev
2022-10-03 20:02               ` Mattias Rönnblom
2022-10-04  9:15                 ` Morten Brørup
2022-10-04 11:57                   ` Bruce Richardson
2022-10-04 14:26                     ` Mattias Rönnblom
2022-10-04 23:30                     ` Konstantin Ananyev
2022-09-30 22:13     ` Mattias Rönnblom
2022-09-14  9:29   ` [PATCH v7 2/4] eal: add cpuset lcore telemetry entries Kevin Laatz
2022-09-14  9:29   ` [PATCH v7 3/4] app/test: add unit tests for lcore poll busyness Kevin Laatz
2022-09-30 22:20     ` Mattias Rönnblom [this message]
2022-09-14  9:29   ` [PATCH v7 4/4] doc: add howto guide " Kevin Laatz
2022-09-14 14:33   ` [PATCH v7 0/4] Add lcore poll busyness telemetry Stephen Hemminger
2022-09-16 12:35     ` Kevin Laatz
2022-09-16 14:10       ` Kevin Laatz
2022-10-05 13:44   ` Kevin Laatz
2022-10-06 13:25     ` Morten Brørup
2022-10-06 15:26       ` Mattias Rönnblom
2022-10-10 15:22         ` Morten Brørup
2022-10-10 17:38           ` Mattias Rönnblom
2022-10-12 12:25             ` Morten Brørup

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=90833044-c7c3-c753-6b40-b9bb1eb881bf@lysator.liu.se \
    --to=hofors@lysator.liu.se \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=kevin.laatz@intel.com \
    --cc=mattias.ronnblom@ericsson.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).