DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Hunt, David" <david.hunt@intel.com>
To: Tadhg Kearney <tadhg.kearney@intel.com>, <dev@dpdk.org>
Cc: <anatoly.burakov@intel.com>, <reshma.pattan@intel.com>
Subject: Re: [PATCH v4 3/3] test/power: add unit tests for uncore API
Date: Fri, 23 Sep 2022 14:15:46 +0100	[thread overview]
Message-ID: <6f3093d0-de7d-656e-098c-3fae8d5b266c@intel.com> (raw)
In-Reply-To: <20220920094822.1403168-4-tadhg.kearney@intel.com>

Hi Tadhg,

On 20/09/2022 10:48, Tadhg Kearney wrote:
> Add basic unit tests covering all nine uncore API's.
>
> Signed-off-by: Tadhg Kearney<tadhg.kearney@intel.com>
> ---
>   app/test/meson.build         |   2 +
>   app/test/test_power_uncore.c | 299 +++++++++++++++++++++++++++++++++++
>   2 files changed, 301 insertions(+)
>   create mode 100644 app/test/test_power_uncore.c
>
> diff --git a/app/test/meson.build b/app/test/meson.build
> index bf1d81f84a..170401ccdc 100644
> --- a/app/test/meson.build
> +++ b/app/test/meson.build
> @@ -100,6 +100,7 @@ test_sources = files(
>           'test_power.c',
>           'test_power_cpufreq.c',
>           'test_power_kvm_vm.c',
> +        'test_power_uncore.c',
>           'test_prefetch.c',
>           'test_rand_perf.c',
>           'test_rawdev.c',
> @@ -240,6 +241,7 @@ fast_tests = [
>           ['power_cpufreq_autotest', false, true],
>           ['power_autotest', true, true],
>           ['power_kvm_vm_autotest', false, true],
> +        ['power_uncore_autotest', true, true],
>           ['reorder_autotest', true, true],
>           ['service_autotest', true, true],
>           ['thash_autotest', true, true],
> diff --git a/app/test/test_power_uncore.c b/app/test/test_power_uncore.c
> new file mode 100644
> index 0000000000..7bc3ed7260
> --- /dev/null
> +++ b/app/test/test_power_uncore.c
> @@ -0,0 +1,299 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2010-2022 Intel Corporation
> + */
> +
> +#include "test.h"
> +
> +#ifndef RTE_LIB_POWER
> +
> +static int
> +test_power_uncore(void)
> +{
> +	printf("Power management library not supported, skipping test\n");
> +	return TEST_SKIPPED;
> +}
> +
> +#else
> +#include <rte_power_uncore.h>
> +#include <power_common.h>
> +
> +#define MAX_UNCORE_FREQS 32
> +
> +#define VALID_PKG 0
> +#define VALID_DIE 0
> +#define INVALID_PKG (rte_power_uncore_get_num_pkgs() + 1)
> +#define INVALID_DIE (rte_power_uncore_get_num_dies(VALID_PKG) + 1)
> +#define VALID_INDEX 1
> +#define INVALID_INDEX (MAX_UNCORE_FREQS + 1)
> +
> +static int check_power_uncore_init(void)
> +{
> +	int ret;
> +
> +	/* Test initialisation of uncore configuration*/
> +	ret = rte_power_uncore_init(VALID_PKG, VALID_DIE);
> +	if (ret < 0) {
> +		printf("Cannot initialise uncore power management for pkg %u die %u, this "
> +			"may occur if environment is not configured "
> +			"correctly(APCI cpufreq) or operating in another valid "
> +			"Power management environment\n", VALID_PKG, VALID_DIE);
> +		return -1;
> +	}
> +
> +	/* Unsuccessful Test */
> +	ret = rte_power_uncore_init(INVALID_PKG, INVALID_DIE);
> +	if (ret == 0) {
> +		printf("Unexpectedly was able to initialise uncore power management "
> +			"for pkg %u die %u\n", INVALID_PKG, INVALID_DIE);
> +		return -1;
> +	}
> +
> +	return 0;
> +}
> +
> +static int
> +check_power_get_uncore_freq(void)
> +{
> +	int ret;
> +
> +	/* Successfully get uncore freq */
> +	ret = rte_power_get_uncore_freq(VALID_PKG, VALID_DIE);
> +	if (ret < 0) {
> +		printf("Failed to get uncore frequency for pkg %u die %u\n",
> +							VALID_PKG, VALID_DIE);
> +		return -1;
> +	}
> +
> +	/* Unsuccessful Test */
> +	ret = rte_power_get_uncore_freq(INVALID_PKG, INVALID_DIE);
> +	if (ret >= 0) {
> +		printf("Unexpectedly got invalid uncore frequency for pkg %u die %u\n",
> +							INVALID_PKG, INVALID_DIE);
> +		return -1;
> +	}
> +
> +	return 0;
> +}
> +
> +static int
> +check_power_set_uncore_freq(void)
> +{
> +	int ret;
> +
> +	/* Successfully set uncore freq */
> +	ret = rte_power_set_uncore_freq(VALID_PKG, VALID_DIE, VALID_INDEX);
> +	if (ret < 0) {
> +		printf("Failed to set uncore frequency for pkg %u die %u index %u\n",
> +							VALID_PKG, VALID_DIE, VALID_INDEX);
> +		return -1;
> +	}
> +
> +	/* Try to unsuccessfully set invalid uncore freq index */
> +	ret = rte_power_set_uncore_freq(VALID_PKG, VALID_DIE, INVALID_INDEX);
> +	if (ret == 0) {
> +		printf("Unexpectedly set invalid uncore index for pkg %u die %u index %u\n",
> +							VALID_PKG, VALID_DIE, INVALID_INDEX);
> +		return -1;
> +	}
> +
> +	/* Unsuccessful Test */
> +	ret = rte_power_set_uncore_freq(INVALID_PKG, INVALID_DIE, VALID_INDEX);
> +	if (ret == 0) {
> +		printf("Unexpectedly set invalid uncore frequency for pkg %u die %u index %u\n",
> +							INVALID_PKG, INVALID_DIE, VALID_INDEX);
> +		return -1;
> +	}
> +
> +	return 0;
> +}
> +
> +static int
> +check_power_uncore_freq_max(void)
> +{
> +	int ret;
> +
> +	/* Successfully get max uncore freq */
> +	ret = rte_power_uncore_freq_max(VALID_PKG, VALID_DIE);
> +	if (ret < 0) {
> +		printf("Failed to set max uncore frequency for pkg %u die %u\n",
> +							VALID_PKG, VALID_DIE);
> +		return -1;
> +	}
> +
> +	/* Unsuccessful Test */
> +	ret = rte_power_uncore_freq_max(INVALID_PKG, INVALID_DIE);
> +	if (ret == 0) {
> +		printf("Unexpectedly set invalid max uncore frequency for pkg %u die %u\n",
> +							INVALID_PKG, INVALID_DIE);
> +		return -1;
> +	}
> +
> +	return 0;
> +}
> +
> +static int
> +check_power_uncore_freq_min(void)
> +{
> +	int ret;
> +
> +	/* Successfully get min uncore freq */
> +	ret = rte_power_uncore_freq_min(VALID_PKG, VALID_DIE);
> +	if (ret < 0) {
> +		printf("Failed to set min uncore frequency for pkg %u die %u\n",
> +							VALID_PKG, VALID_DIE);
> +		return -1;
> +	}
> +
> +	/* Unsuccessful Test */
> +	ret = rte_power_uncore_freq_min(INVALID_PKG, INVALID_DIE);
> +	if (ret == 0) {
> +		printf("Unexpectedly set invalid min uncore frequency for pkg %u die %u\n",
> +							INVALID_PKG, INVALID_DIE);
> +		return -1;
> +	}
> +
> +	return 0;
> +}
> +
> +static int
> +check_power_uncore_get_num_freqs(void)
> +{
> +	int ret;
> +
> +	/* Successfully get number of uncore freq */
> +	ret = rte_power_uncore_get_num_freqs(VALID_PKG, VALID_DIE);
> +	if (ret < 0) {
> +		printf("Failed to get number of uncore frequencies for pkg %u die %u\n",
> +							VALID_PKG, VALID_DIE);
> +		return -1;
> +	}
> +
> +	/* Unsuccessful Test */
> +	ret = rte_power_uncore_get_num_freqs(INVALID_PKG, INVALID_DIE);
> +	if (ret >= 0) {
> +		printf("Unexpectedly got number of invalid frequencies for pkg %u die %u\n",
> +							INVALID_PKG, INVALID_DIE);
> +		return -1;
> +	}
> +
> +	return 0;
> +}
> +
> +static int
> +check_power_uncore_get_num_pkgs(void)
> +{
> +	int ret;
> +
> +	/* Successfully get number of uncore pkgs */
> +	ret = rte_power_uncore_get_num_pkgs();
> +	if (ret == 0) {
> +		printf("Failed to get number of uncore pkgs\n");
> +		return -1;
> +	}
> +
> +	return 0;
> +}
> +
> +static int
> +check_power_uncore_get_num_dies(void)
> +{
> +	int ret;
> +
> +	/* Successfully get number of uncore dies */
> +	ret = rte_power_uncore_get_num_dies(VALID_PKG);
> +	if (ret == 0) {
> +		printf("Failed to get number of uncore dies for pkg %u\n",
> +							VALID_PKG);
> +		return -1;
> +	}
> +
> +	/* Unsuccessful test */
> +	ret = rte_power_uncore_get_num_dies(INVALID_PKG);
> +	if (ret > 0) {
> +		printf("Unexpectedly got number of invalid dies for pkg %u\n",
> +							INVALID_PKG);
> +		return -1;
> +	}
> +
> +	return 0;
> +}
> +
> +static int
> +check_power_uncore_exit(void)
> +{
> +	int ret;
> +
> +	/* Successfully exit uncore power management */
> +	ret = rte_power_uncore_exit(VALID_PKG, VALID_DIE);
> +	if (ret < 0) {
> +		printf("Failed to exit uncore power management for pkg %u die %u\n",
> +							VALID_PKG, VALID_DIE);
> +	}
> +
> +	/* Unsuccessful Test */
> +	ret = rte_power_uncore_exit(INVALID_PKG, INVALID_DIE);
> +	if (ret == 0) {
> +		printf("Unexpectedly was able to exit uncore power management for pkg %u die %u\n",
> +							INVALID_PKG, INVALID_DIE);
> +		return -1;
> +	}
> +
> +	return 0;
> +}
> +
> +static int
> +test_power_uncore(void)
> +{
> +	int ret;
> +
> +	ret = rte_power_uncore_get_num_pkgs();
> +	if (ret == 0) {
> +		printf("Uncore frequency management only supported on x86 with linux kernel >= 5.6.");
> +		return TEST_SKIPPED;
> +	}
> +


Suggest re-wording this message. I'm running a 5.17 kernel, and still 
see this message because CONFIG_INTEL_UNCORE_FREQ_CONTROL is not set.

Maybe "Uncore frequency management not supported/enabled on this kernel. 
Please enable CONFIG_INTEL_UNCORE_FREQ_CONTROL."

Also, the '\n' is missing from the end of the line.


> +	ret = check_power_uncore_init();
> +	if (ret < 0)
> +		goto fail_all;
> +
> +	ret = check_power_get_uncore_freq();
> +	if (ret < 0)
> +		goto fail_all;
> +
> +	ret = check_power_set_uncore_freq();
> +	if (ret < 0)
> +		goto fail_all;
> +
> +	ret = check_power_uncore_freq_max();
> +	if (ret < 0)
> +		goto fail_all;
> +
> +	ret = check_power_uncore_freq_min();
> +	if (ret < 0)
> +		goto fail_all;
> +
> +	ret = check_power_uncore_get_num_freqs();
> +	if (ret < 0)
> +		goto fail_all;
> +
> +	ret = check_power_uncore_get_num_pkgs();
> +	if (ret < 0)
> +		goto fail_all;
> +
> +	ret = check_power_uncore_get_num_dies();
> +	if (ret < 0)
> +		goto fail_all;
> +
> +	ret = check_power_uncore_exit();
> +	if (ret < 0)
> +		return -1;
> +
> +	return 0;
> +
> +fail_all:
> +	rte_power_uncore_exit(VALID_PKG, VALID_DIE);
> +	return -1;
> +}
> +#endif
> +
> +REGISTER_TEST_COMMAND(power_uncore_autotest, test_power_uncore);


The rest looks good to me, and once the above requested changes are 
addressed:

Reviewed-by: David Hunt <david.hunt@intel.com>



  reply	other threads:[~2022-09-23 13:15 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-20  9:48 [PATCH v4 0/3] add uncore api to be called through l3fwd-power Tadhg Kearney
2022-09-20  9:48 ` [PATCH v4 1/3] power: add uncore frequency control API to the power library Tadhg Kearney
2022-09-23 13:15   ` Hunt, David
2022-09-20  9:48 ` [PATCH v4 2/3] l3fwd-power: add option to call uncore API Tadhg Kearney
2022-09-23 13:13   ` Hunt, David
2022-09-20  9:48 ` [PATCH v4 3/3] test/power: add unit tests for " Tadhg Kearney
2022-09-23 13:15   ` Hunt, David [this message]
2022-09-27 10:09 ` [PATCH v5 0/3] add uncore api to be called through l3fwd-power Tadhg Kearney
2022-09-27 10:09   ` [PATCH v5 1/3] power: add uncore frequency control API to the power library Tadhg Kearney
2022-09-27 10:09   ` [PATCH v5 2/3] l3fwd-power: add option to call uncore API Tadhg Kearney
2022-09-27 10:09   ` [PATCH v5 3/3] test/power: add unit tests for " Tadhg Kearney
2022-09-28  9:06   ` [PATCH v6 0/3] add uncore api to be called through l3fwd-power Tadhg Kearney
2022-09-28  9:06     ` [PATCH v6 1/3] power: add uncore frequency control API to the power library Tadhg Kearney
2022-09-28  9:06     ` [PATCH v6 2/3] l3fwd-power: add option to call uncore API Tadhg Kearney
2022-09-28 12:18       ` Hunt, David
2022-09-28  9:06     ` [PATCH v6 3/3] test/power: add unit tests for " Tadhg Kearney
2022-09-28 13:30     ` [PATCH v7 0/3] add uncore api to be called through l3fwd-power Tadhg Kearney
2022-09-28 13:30       ` [PATCH v7 1/3] power: add uncore frequency control API to the power library Tadhg Kearney
2022-10-04 17:09         ` Thomas Monjalon
2022-10-05 10:50           ` Kearney, Tadhg
2022-10-05 12:11             ` Thomas Monjalon
2022-09-28 13:30       ` [PATCH v7 2/3] l3fwd-power: add option to call uncore API Tadhg Kearney
2022-09-28 13:30       ` [PATCH v7 3/3] test/power: add unit tests for " Tadhg Kearney
2022-09-29 13:27       ` [PATCH v7 0/3] add uncore api to be called through l3fwd-power Hunt, David
2022-10-05 16:20       ` [PATCH v8 0/3] add Intel " Tadhg Kearney
2022-10-05 16:20         ` [PATCH v8 1/3] power: add Intel uncore frequency control API to power library Tadhg Kearney
2022-10-05 16:20         ` [PATCH v8 2/3] l3fwd-power: add option to call uncore API Tadhg Kearney
2022-10-05 16:20         ` [PATCH v8 3/3] test/power: add unit tests for " Tadhg Kearney
2022-10-06  9:38         ` [PATCH v9 0/3] add Intel uncore api to be called through l3fwd-power Tadhg Kearney
2022-10-06  9:38           ` [PATCH v9 1/3] power: add Intel uncore frequency control API to power library Tadhg Kearney
2022-10-06 17:32             ` Stephen Hemminger
2022-10-07 10:30               ` Hunt, David
2022-10-10 12:46             ` Thomas Monjalon
2022-10-06  9:38           ` [PATCH v9 2/3] l3fwd-power: add option to call uncore API Tadhg Kearney
2022-10-06  9:38           ` [PATCH v9 3/3] test/power: add unit tests for " Tadhg Kearney
2022-10-10 12:52           ` [PATCH v9 0/3] add Intel uncore api to be called through l3fwd-power Thomas Monjalon

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=6f3093d0-de7d-656e-098c-3fae8d5b266c@intel.com \
    --to=david.hunt@intel.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=reshma.pattan@intel.com \
    --cc=tadhg.kearney@intel.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).