@@ -3749,10 +3749,13 @@ def test_get_pinning_host_siblings_large_instance_odd_fit(self):
3749
3749
got_topo = objects .VirtCPUTopology (sockets = 1 , cores = 5 , threads = 1 )
3750
3750
self .assertEqualTopology (got_topo , inst_pin .cpu_topology )
3751
3751
3752
+ # TODO(stephenfin): Remove when we drop support for vcpu_pin_set
3752
3753
def test_get_pinning_isolate_policy_too_few_fully_free_cores (self ):
3753
3754
host_pin = objects .NUMACell (
3754
3755
id = 0 ,
3755
- cpuset = set (),
3756
+ # Simulate a legacy host with vcpu_pin_set configuration,
3757
+ # meaning cpuset == pcpuset
3758
+ cpuset = set ([0 , 1 , 2 , 3 ]),
3756
3759
pcpuset = set ([0 , 1 , 2 , 3 ]),
3757
3760
memory = 4096 ,
3758
3761
memory_usage = 0 ,
@@ -3774,10 +3777,13 @@ def test_get_pinning_isolate_policy_too_few_fully_free_cores(self):
3774
3777
3775
3778
self .assertIsNone (inst_pin )
3776
3779
3780
+ # TODO(stephenfin): Remove when we drop support for vcpu_pin_set
3777
3781
def test_get_pinning_isolate_policy_no_fully_free_cores (self ):
3778
3782
host_pin = objects .NUMACell (
3779
3783
id = 0 ,
3780
- cpuset = set (),
3784
+ # Simulate a legacy host with vcpu_pin_set configuration,
3785
+ # meaning cpuset == pcpuset
3786
+ cpuset = set ([0 , 1 , 2 , 3 ]),
3781
3787
pcpuset = set ([0 , 1 , 2 , 3 ]),
3782
3788
memory = 4096 ,
3783
3789
memory_usage = 0 ,
@@ -3799,10 +3805,13 @@ def test_get_pinning_isolate_policy_no_fully_free_cores(self):
3799
3805
3800
3806
self .assertIsNone (inst_pin )
3801
3807
3808
+ # TODO(stephenfin): Remove when we drop support for vcpu_pin_set
3802
3809
def test_get_pinning_isolate_policy_fits (self ):
3803
3810
host_pin = objects .NUMACell (
3804
3811
id = 0 ,
3805
- cpuset = set (),
3812
+ # Simulate a legacy host with vcpu_pin_set configuration,
3813
+ # meaning cpuset == pcpuset
3814
+ cpuset = set ([0 , 1 , 2 , 3 ]),
3806
3815
pcpuset = set ([0 , 1 , 2 , 3 ]),
3807
3816
memory = 4096 ,
3808
3817
memory_usage = 0 ,
@@ -3825,10 +3834,13 @@ def test_get_pinning_isolate_policy_fits(self):
3825
3834
got_topo = objects .VirtCPUTopology (sockets = 1 , cores = 2 , threads = 1 )
3826
3835
self .assertEqualTopology (got_topo , inst_pin .cpu_topology )
3827
3836
3837
+ # TODO(stephenfin): Remove when we drop support for vcpu_pin_set
3828
3838
def test_get_pinning_isolate_policy_fits_ht_host (self ):
3829
3839
host_pin = objects .NUMACell (
3830
3840
id = 0 ,
3831
- cpuset = set (),
3841
+ # Simulate a legacy host with vcpu_pin_set configuration,
3842
+ # meaning cpuset == pcpuset
3843
+ cpuset = set ([0 , 1 , 2 , 3 ]),
3832
3844
pcpuset = set ([0 , 1 , 2 , 3 ]),
3833
3845
memory = 4096 ,
3834
3846
memory_usage = 0 ,
@@ -3852,10 +3864,13 @@ def test_get_pinning_isolate_policy_fits_ht_host(self):
3852
3864
got_topo = objects .VirtCPUTopology (sockets = 1 , cores = 2 , threads = 1 )
3853
3865
self .assertEqualTopology (got_topo , inst_pin .cpu_topology )
3854
3866
3867
+ # TODO(stephenfin): Remove when we drop support for vcpu_pin_set
3855
3868
def test_get_pinning_isolate_policy_fits_w_usage (self ):
3856
3869
host_pin = objects .NUMACell (
3857
3870
id = 0 ,
3858
- cpuset = set (),
3871
+ # Simulate a legacy host with vcpu_pin_set configuration,
3872
+ # meaning cpuset == pcpuset
3873
+ cpuset = set ([0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ]),
3859
3874
pcpuset = set ([0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ]),
3860
3875
memory = 4096 ,
3861
3876
memory_usage = 0 ,
@@ -3879,6 +3894,38 @@ def test_get_pinning_isolate_policy_fits_w_usage(self):
3879
3894
got_topo = objects .VirtCPUTopology (sockets = 1 , cores = 2 , threads = 1 )
3880
3895
self .assertEqualTopology (got_topo , inst_pin .cpu_topology )
3881
3896
3897
+ # TODO(stephenfin): Remove when we drop support for vcpu_pin_set
3898
+ @mock .patch .object (hw , 'LOG' )
3899
+ def test_get_pinning_isolate_policy_bug_1889633 (self , mock_log ):
3900
+ host_pin = objects .NUMACell (
3901
+ id = 0 ,
3902
+ cpuset = {0 , 1 , 4 , 5 },
3903
+ pcpuset = {2 , 3 , 6 , 7 },
3904
+ memory = 4096 ,
3905
+ memory_usage = 0 ,
3906
+ pinned_cpus = set (),
3907
+ siblings = [{0 , 4 }, {1 , 5 }, {2 , 6 }, {3 , 7 }],
3908
+ mempages = [],
3909
+ )
3910
+ inst_pin = objects .InstanceNUMACell (
3911
+ cpuset = set (),
3912
+ pcpuset = {0 , 1 },
3913
+ memory = 2048 ,
3914
+ cpu_policy = fields .CPUAllocationPolicy .DEDICATED ,
3915
+ cpu_thread_policy = fields .CPUThreadAllocationPolicy .ISOLATE ,
3916
+ )
3917
+ limits = objects .NUMATopologyLimits (
3918
+ cpu_allocation_ratio = 2 , ram_allocation_ratio = 2 ,
3919
+ )
3920
+
3921
+ # host has hyperthreads, which means no NUMA topology should be built
3922
+ inst_topo = hw ._numa_fit_instance_cell (host_pin , inst_pin , limits )
3923
+ self .assertIsNone (inst_topo )
3924
+ self .assertIn (
3925
+ 'Host supports hyperthreads, but instance requested no' ,
3926
+ mock_log .warning .call_args [0 ][0 ],
3927
+ )
3928
+
3882
3929
3883
3930
class CPUPinningTestCase (test .NoDBTestCase , _CPUPinningTestCaseBase ):
3884
3931
def test_host_numa_fit_instance_to_host_single_cell (self ):
@@ -4898,11 +4945,14 @@ def test_isolate_full_usage(self):
4898
4945
4899
4946
self .assertEqual (set ([0 , 1 ]), host_topo .cells [0 ].pinned_cpus )
4900
4947
4948
+ # TODO(stephenfin): Remove when we drop support for vcpu_pin_set
4901
4949
def test_isolate_w_isolate_thread_alloc (self ):
4902
4950
host_topo = objects .NUMATopology (cells = [
4903
4951
objects .NUMACell (
4904
4952
id = 0 ,
4905
- cpuset = set (),
4953
+ # Simulate a legacy host with vcpu_pin_set configuration,
4954
+ # meaning cpuset == pcpuset
4955
+ cpuset = set ([0 , 1 , 2 , 3 , 4 , 5 ]),
4906
4956
pcpuset = set ([0 , 1 , 2 , 3 , 4 , 5 ]),
4907
4957
memory = 2048 ,
4908
4958
cpu_usage = 0 ,
@@ -4925,11 +4975,14 @@ def test_isolate_w_isolate_thread_alloc(self):
4925
4975
self .assertEqual ({0 : 0 , 1 : 2 }, inst_topo .cells [0 ].cpu_pinning )
4926
4976
self .assertEqual (set ([4 ]), inst_topo .cells [0 ].cpuset_reserved )
4927
4977
4978
+ # TODO(stephenfin): Remove when we drop support for vcpu_pin_set
4928
4979
def test_isolate_w_isolate_thread_alloc_usage (self ):
4929
4980
host_topo = objects .NUMATopology (cells = [
4930
4981
objects .NUMACell (
4931
4982
id = 0 ,
4932
- cpuset = set (),
4983
+ # Simulate a legacy host with vcpu_pin_set configuration,
4984
+ # meaning cpuset == pcpuset
4985
+ cpuset = set ([0 , 1 , 2 , 3 , 4 , 5 ]),
4933
4986
pcpuset = set ([0 , 1 , 2 , 3 , 4 , 5 ]),
4934
4987
memory = 2048 ,
4935
4988
cpu_usage = 0 ,
@@ -5038,11 +5091,14 @@ def test_asymmetric_host(self):
5038
5091
self .assertEqual ({0 : 2 , 1 : 3 }, inst_topo .cells [0 ].cpu_pinning )
5039
5092
self .assertEqual (set ([1 ]), inst_topo .cells [0 ].cpuset_reserved )
5040
5093
5094
+ # TODO(stephenfin): Remove when we drop support for vcpu_pin_set
5041
5095
def test_asymmetric_host_w_isolate_thread_alloc (self ):
5042
5096
host_topo = objects .NUMATopology (cells = [
5043
5097
objects .NUMACell (
5044
5098
id = 0 ,
5045
- cpuset = set (),
5099
+ # Simulate a legacy host with vcpu_pin_set configuration,
5100
+ # meaning cpuset == pcpuset
5101
+ cpuset = set ([1 , 2 , 3 , 4 , 5 ]),
5046
5102
pcpuset = set ([1 , 2 , 3 , 4 , 5 ]),
5047
5103
memory = 2048 ,
5048
5104
cpu_usage = 0 ,
@@ -5052,8 +5108,7 @@ def test_asymmetric_host_w_isolate_thread_alloc(self):
5052
5108
mempages = [objects .NUMAPagesTopology (
5053
5109
size_kb = 4 , total = 524288 , used = 0 )])])
5054
5110
inst_topo = objects .InstanceNUMATopology (
5055
- emulator_threads_policy = (
5056
- fields .CPUEmulatorThreadsPolicy .ISOLATE ),
5111
+ emulator_threads_policy = fields .CPUEmulatorThreadsPolicy .ISOLATE ,
5057
5112
cells = [objects .InstanceNUMACell (
5058
5113
id = 0 ,
5059
5114
cpuset = set (), pcpuset = set ([0 , 1 ]), memory = 2048 ,
0 commit comments