From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 317CAA04F5 for ; Wed, 11 Dec 2019 22:28:19 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 28D251BE9E; Wed, 11 Dec 2019 22:28:19 +0100 (CET) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id A63CA2C6A for ; Wed, 11 Dec 2019 22:28:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576099697; 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: in-reply-to:in-reply-to:references:references; bh=20IZxZiTY2ICMsVDQX78cWeRiSeQZCj6ETHp2+/kXO8=; b=bBQSGcruJGkhTeulwdtWeHgUEqO9kPSFNgu+SxX9QnDlWQFF4bHsPsOqoTmGoPv9SZv1Hu 7SIz82pmaZS9AWSXwCW19aKdMRGb/vorZWWjhxERRbXswLium9GSPvC2Td8PcuMpNisFu8 rnb3rxsm7yZ+lYaOj6qdsj0RUCiD7A8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-382-AawxQc4sMMSWYap1A1M8xQ-1; Wed, 11 Dec 2019 16:28:15 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8B18C107ACCC; Wed, 11 Dec 2019 21:28:14 +0000 (UTC) Received: from rh.redhat.com (ovpn-116-64.ams2.redhat.com [10.36.116.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77C5510013A1; Wed, 11 Dec 2019 21:28:13 +0000 (UTC) From: Kevin Traynor To: David Hunt Cc: Anatoly Burakov , dpdk stable Date: Wed, 11 Dec 2019 21:26:15 +0000 Message-Id: <20191211212702.27851-23-ktraynor@redhat.com> In-Reply-To: <20191211212702.27851-1-ktraynor@redhat.com> References: <20191211212702.27851-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: AawxQc4sMMSWYap1A1M8xQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-stable] patch 'examples/vm_power: fix OOB frequency oscillations' has been queued to LTS release 18.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to LTS release 18.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 12/17/19. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasi= ng (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable-queue This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable-queue/commit/823157fedf327cc983= 27636691cc74f95fb27de6 Thanks. Kevin. --- >From 823157fedf327cc98327636691cc74f95fb27de6 Mon Sep 17 00:00:00 2001 From: David Hunt Date: Wed, 24 Jul 2019 14:18:03 +0100 Subject: [PATCH] examples/vm_power: fix OOB frequency oscillations [ upstream commit 31c9a66465ad623258c4449fea54c0b42a2deae1 ] The branch ratio algorithm in the vm_power_manager sample application can be very sensitive at patricular loads in a workload, causing oscillations between min and max frequency. For example, if a workload is at 50%, scaling up may change the ratio enough that it immediately thinks it needs to scale down again. This patch introduces a sliding window recording the scale up/down direction for the last 32 samples, and scales up if any samples indicate we should scale up, otherwise scale down. Each core has it's own window. Fixes: 4b1a631b8a8a ("examples/vm_power: add oob monitoring functions") Signed-off-by: David Hunt Acked-by: Anatoly Burakov --- examples/vm_power_manager/oob_monitor_x86.c | 34 +++++++++++++++++++-- examples/vm_power_manager/power_manager.c | 3 +- examples/vm_power_manager/power_manager.h | 12 ++++++++ 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/examples/vm_power_manager/oob_monitor_x86.c b/examples/vm_powe= r_manager/oob_monitor_x86.c index ebd96b205..aecfcb2eb 100644 --- a/examples/vm_power_manager/oob_monitor_x86.c +++ b/examples/vm_power_manager/oob_monitor_x86.c @@ -40,4 +40,5 @@ apply_policy(int core) =09float ratio; =09int ret; +=09int freq_window_idx, up_count =3D 0, i; =20 =09g_active =3D 0; @@ -102,8 +103,35 @@ apply_policy(int core) =09ratio =3D (float)miss_diff * (float)100 / (float)hits_diff; =20 -=09if (ratio < ci->branch_ratio_threshold) -=09=09power_manager_scale_core_min(core); +=09/* +=09 * Store the last few directions that the ratio indicates +=09 * we should take. If there's on 'up', then we scale up +=09 * quickly. If all indicate 'down', only then do we scale +=09 * down. Each core_details struct has it's own array. +=09 */ +=09freq_window_idx =3D ci->cd[core].freq_window_idx; +=09if (ratio > ci->branch_ratio_threshold) +=09=09ci->cd[core].freq_directions[freq_window_idx] =3D 1; =09else -=09=09power_manager_scale_core_max(core); +=09=09ci->cd[core].freq_directions[freq_window_idx] =3D 0; + +=09freq_window_idx++; +=09freq_window_idx =3D freq_window_idx & (FREQ_WINDOW_SIZE-1); +=09ci->cd[core].freq_window_idx =3D freq_window_idx; + +=09up_count =3D 0; +=09for (i =3D 0; i < FREQ_WINDOW_SIZE; i++) +=09=09up_count +=3D ci->cd[core].freq_directions[i]; + +=09if (up_count =3D=3D 0) { +=09=09if (ci->cd[core].freq_state !=3D FREQ_MIN) { +=09=09=09power_manager_scale_core_min(core); +=09=09=09ci->cd[core].freq_state =3D FREQ_MIN; +=09=09} +=09} else { +=09=09if (ci->cd[core].freq_state !=3D FREQ_MAX) { +=09=09=09power_manager_scale_core_max(core); +=09=09=09ci->cd[core].freq_state =3D FREQ_MAX; +=09=09} +=09} =20 =09g_active =3D 1; diff --git a/examples/vm_power_manager/power_manager.c b/examples/vm_power_= manager/power_manager.c index 318fb0255..a7e98cf40 100644 --- a/examples/vm_power_manager/power_manager.c +++ b/examples/vm_power_manager/power_manager.c @@ -77,4 +77,5 @@ core_info_init(void) =09ci->branch_ratio_threshold =3D BRANCH_RATIO_THRESHOLD; =09ci->cd =3D malloc(ci->core_count * sizeof(struct core_details)); +=09memset(ci->cd, 0, ci->core_count * sizeof(struct core_details)); =09if (!ci->cd) { =09=09RTE_LOG(ERR, POWER_MANAGER, "Failed to allocate memory for core info= ."); @@ -83,6 +84,4 @@ core_info_init(void) =09for (i =3D 0; i < ci->core_count; i++) { =09=09ci->cd[i].global_enabled_cpus =3D 1; -=09=09ci->cd[i].oob_enabled =3D 0; -=09=09ci->cd[i].msr_fd =3D 0; =09} =09printf("%d cores in system\n", ci->core_count); diff --git a/examples/vm_power_manager/power_manager.h b/examples/vm_power_= manager/power_manager.h index 605b3c8f6..3de2f7aa0 100644 --- a/examples/vm_power_manager/power_manager.h +++ b/examples/vm_power_manager/power_manager.h @@ -9,4 +9,13 @@ extern "C" { #endif + +#define FREQ_WINDOW_SIZE 32 + +enum { +=09FREQ_UNKNOWN, +=09FREQ_MIN, +=09FREQ_MAX +}; + struct core_details { =09uint64_t last_branches; @@ -15,4 +24,7 @@ struct core_details { =09uint16_t oob_enabled; =09int msr_fd; +=09uint16_t freq_directions[FREQ_WINDOW_SIZE]; +=09uint16_t freq_window_idx; +=09uint16_t freq_state; }; =20 --=20 2.21.0 --- Diff of the applied patch vs upstream commit (please double-check if non-= empty: --- --- -=092019-12-11 21:24:14.554673866 +0000 +++ 0023-examples-vm_power-fix-OOB-frequency-oscillations.patch=092019-12-1= 1 21:24:12.624652106 +0000 @@ -1 +1 @@ -From 31c9a66465ad623258c4449fea54c0b42a2deae1 Mon Sep 17 00:00:00 2001 +From 823157fedf327cc98327636691cc74f95fb27de6 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 31c9a66465ad623258c4449fea54c0b42a2deae1 ] + @@ -17 +18,0 @@ -Cc: stable@dpdk.org @@ -77 +78 @@ -index 9d4e587b0..7b4f4b3c4 100644 +index 318fb0255..a7e98cf40 100644 @@ -80 +81 @@ -@@ -63,4 +63,5 @@ core_info_init(void) +@@ -77,4 +77,5 @@ core_info_init(void) @@ -86 +87 @@ -@@ -69,6 +70,4 @@ core_info_init(void) +@@ -83,6 +84,4 @@ core_info_init(void) @@ -94 +95 @@ -index e81a60ae5..e324766b6 100644 +index 605b3c8f6..3de2f7aa0 100644