From b4c75f3a048e0cdde9572cb3ece031ecb81d85c6 Mon Sep 17 00:00:00 2001 From: Gautam Prasad Date: Wed, 26 Apr 2017 17:09:30 +0530 Subject: [PATCH] Update host cpu util calculation to consider idle proc cycles The Lpar utilization used to consider donatedProcCycles. As per discussion with hypervisor team, donatedProcCycles are not guaranteed to be utilised by any other Lpar on the host. So, from host perspective, it might get utilised by another lpar as uncapped or it might not get utilised. Since we are already including uncapped proc cycles in calculation, we need to ignore donated. Also, the formula needs to take into account idle proc cycles on lpar. Change-Id: Ia26d16796be21320eb64f2be15f958c1d0b0d174 Closes-Bug: 1686422 --- nova_powervm/tests/virt/powervm/test_host.py | 10 +++++----- nova_powervm/virt/powervm/host.py | 10 ++++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/nova_powervm/tests/virt/powervm/test_host.py b/nova_powervm/tests/virt/powervm/test_host.py index 40299973..7293cd1e 100644 --- a/nova_powervm/tests/virt/powervm/test_host.py +++ b/nova_powervm/tests/virt/powervm/test_host.py @@ -265,7 +265,7 @@ class TestHostCPUStats(test.TestCase): prev_lpar_sample = mock_prev_phyp.sample.lpars[0].processor prev_lpar_sample.util_cap_proc_cycles = 0 prev_lpar_sample.util_uncap_proc_cycles = 0 - prev_lpar_sample.donated_proc_cycles = 0 + prev_lpar_sample.idle_proc_cycles = 0 delta3 = host_stats._delta_proc_cycles(mock_phyp.sample.lpars, mock_prev_phyp.sample.lpars) self.assertEqual(0, delta3) @@ -278,11 +278,11 @@ class TestHostCPUStats(test.TestCase): mock_phyp, mock_prev_phyp = self._get_mock_phyps() mock_phyp.sample.lpars[0].processor.util_cap_proc_cycles = 250000 mock_phyp.sample.lpars[0].processor.util_uncap_proc_cycles = 250000 - mock_phyp.sample.lpars[0].processor.donated_proc_cycles = 500 + mock_phyp.sample.lpars[0].processor.idle_proc_cycles = 500 mock_prev_phyp.sample.lpars[0].processor.util_cap_proc_cycles = 0 num = 455000 mock_prev_phyp.sample.lpars[0].processor.util_uncap_proc_cycles = num - mock_prev_phyp.sample.lpars[0].processor.donated_proc_cycles = 1000 + mock_prev_phyp.sample.lpars[0].processor.idle_proc_cycles = 1000 # Test that a previous sample allows us to gather just the delta. new_elem = self._get_sample(4, mock_phyp.sample) @@ -395,13 +395,13 @@ class TestHostCPUStats(test.TestCase): mock_lpar_4A.processor = mock.MagicMock( util_cap_proc_cycles=5005045000, util_uncap_proc_cycles=5005045000, - donated_proc_cycles=10000) + idle_proc_cycles=10000) mock_lpar_4A_prev = mock.Mock() mock_lpar_4A_prev.configure_mock(id=4, name='A') mock_lpar_4A_prev.processor = mock.MagicMock( util_cap_proc_cycles=40000, util_uncap_proc_cycles=40000, - donated_proc_cycles=0) + idle_proc_cycles=0) mock_phyp = mock.MagicMock(sample=mock.MagicMock(lpars=[mock_lpar_4A])) mock_prev_phyp = mock.MagicMock( sample=mock.MagicMock(lpars=[mock_lpar_4A_prev])) diff --git a/nova_powervm/virt/powervm/host.py b/nova_powervm/virt/powervm/host.py index 4875efc2..796d6c93 100644 --- a/nova_powervm/virt/powervm/host.py +++ b/nova_powervm/virt/powervm/host.py @@ -310,15 +310,17 @@ class HostCPUStats(pcm_util.MetricCache): # sample. if (prev_sample.processor.util_cap_proc_cycles == prev_sample.processor.util_uncap_proc_cycles == - prev_sample.processor.donated_proc_cycles == 0): + prev_sample.processor.idle_proc_cycles == 0): return 0 - + # The VM utilization on host is its capped + uncapped - idle cycles. + # Donated proc cycles should not be considered as these are + # not guaranteed to be getting utilized by any other lpar on the host. prev_amount = (prev_sample.processor.util_cap_proc_cycles + prev_sample.processor.util_uncap_proc_cycles - - prev_sample.processor.donated_proc_cycles) + prev_sample.processor.idle_proc_cycles) cur_amount = (cur_sample.processor.util_cap_proc_cycles + cur_sample.processor.util_uncap_proc_cycles - - cur_sample.processor.donated_proc_cycles) + cur_sample.processor.idle_proc_cycles) return cur_amount - prev_amount @staticmethod