Skip to content

Commit

Permalink
Fixed Bug #178: Changes to lscpu breaks parsing of cache info
Browse files Browse the repository at this point in the history
  • Loading branch information
workhorsy committed Sep 7, 2022
1 parent 54e62b7 commit a93e04d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
* Release 8.1.0
* Fixed Bug #178: Changes to lscpu breaks parsing of cache info
* Fixed Bug #177: Officially drop support for Python 2
* Fixed Bug #171: Replace Python 3.11 deprecated unittest.makeSuite
* Fixed Bug #173: Fix lgtm.com alerts
Expand Down
4 changes: 4 additions & 0 deletions cpuinfo/cpuinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1894,18 +1894,22 @@ def _get_cpu_info_from_lscpu():

l1_data_cache_size = _get_field(False, output, None, None, 'L1d cache')
if l1_data_cache_size:
l1_data_cache_size = l1_data_cache_size.split('(')[0].strip()
info['l1_data_cache_size'] = _friendly_bytes_to_int(l1_data_cache_size)

l1_instruction_cache_size = _get_field(False, output, None, None, 'L1i cache')
if l1_instruction_cache_size:
l1_instruction_cache_size = l1_instruction_cache_size.split('(')[0].strip()
info['l1_instruction_cache_size'] = _friendly_bytes_to_int(l1_instruction_cache_size)

l2_cache_size = _get_field(False, output, None, None, 'L2 cache', 'L2d cache')
if l2_cache_size:
l2_cache_size = l2_cache_size.split('(')[0].strip()
info['l2_cache_size'] = _friendly_bytes_to_int(l2_cache_size)

l3_cache_size = _get_field(False, output, None, None, 'L3 cache')
if l3_cache_size:
l3_cache_size = l3_cache_size.split('(')[0].strip()
info['l3_cache_size'] = _friendly_bytes_to_int(l3_cache_size)

# Flags
Expand Down
2 changes: 1 addition & 1 deletion tests/test_linux_ubuntu_22_04_x86_64.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ def test_get_cpu_info_from_lscpu(self):
self.assertEqual(512 * 1024, info['l1_instruction_cache_size'])
self.assertEqual(256 * 1024, info['l1_data_cache_size'])
self.assertEqual(4 * 1024 * 1024, info['l2_cache_size'])
self.assertEqual(512 * 1024, info['l3_cache_size'])
self.assertEqual(16 * 1024 * 1024, info['l3_cache_size'])
self.assertEqual(
['3dnowprefetch', 'abm', 'adx', 'aes', 'aperfmperf', 'apic', 'arat',
'avic', 'avx', 'avx2', 'bmi1', 'bmi2', 'bpext', 'clflush',
Expand Down

0 comments on commit a93e04d

Please sign in to comment.