IO Priority support on the AArch64 architecture
This patches fixes Swift's IO priority control on the AArch64 architecture by getting the correct __NR_ioprio_set value. Change-Id: Ic93ce80fde223074e7d1a5338c8cf88863c6ddeb Closes-Bug: #1658405
This commit is contained in:
parent
4970277232
commit
031ba11357
@ -117,9 +117,11 @@ def NR_ioprio_set():
|
|||||||
"""Give __NR_ioprio_set value for your system."""
|
"""Give __NR_ioprio_set value for your system."""
|
||||||
architecture = os.uname()[4]
|
architecture = os.uname()[4]
|
||||||
arch_bits = platform.architecture()[0]
|
arch_bits = platform.architecture()[0]
|
||||||
# check if supported system, now support only x86_64
|
# check if supported system, now support x86_64 and AArch64
|
||||||
if architecture == 'x86_64' and arch_bits == '64bit':
|
if architecture == 'x86_64' and arch_bits == '64bit':
|
||||||
return 251
|
return 251
|
||||||
|
elif architecture == 'aarch64' and arch_bits == '64bit':
|
||||||
|
return 30
|
||||||
raise OSError("Swift doesn't support ionice priority for %s %s" %
|
raise OSError("Swift doesn't support ionice priority for %s %s" %
|
||||||
(architecture, arch_bits))
|
(architecture, arch_bits))
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import eventlet.event
|
|||||||
import functools
|
import functools
|
||||||
import grp
|
import grp
|
||||||
import logging
|
import logging
|
||||||
|
import platform
|
||||||
import os
|
import os
|
||||||
import mock
|
import mock
|
||||||
import random
|
import random
|
||||||
@ -3575,7 +3576,14 @@ cluster_dfw1 = http://dfw1.host/v1/
|
|||||||
called = {}
|
called = {}
|
||||||
# just ionice class uses default priority 0
|
# just ionice class uses default priority 0
|
||||||
utils.modify_priority({'ionice_class': 'IOPRIO_CLASS_RT'}, logger)
|
utils.modify_priority({'ionice_class': 'IOPRIO_CLASS_RT'}, logger)
|
||||||
self.assertEqual(called, {'syscall': (251, 1, pid, 1 << 13)})
|
architecture = os.uname()[4]
|
||||||
|
arch_bits = platform.architecture()[0]
|
||||||
|
if architecture == 'x86_64' and arch_bits == '64bit':
|
||||||
|
self.assertEqual(called, {'syscall': (251, 1, pid, 1 << 13)})
|
||||||
|
elif architecture == 'aarch64' and arch_bits == '64bit':
|
||||||
|
self.assertEqual(called, {'syscall': (30, 1, pid, 1 << 13)})
|
||||||
|
else:
|
||||||
|
self.fail("Unexpected call: %r" % called)
|
||||||
called = {}
|
called = {}
|
||||||
# just ionice priority is ignored
|
# just ionice priority is ignored
|
||||||
utils.modify_priority({'ionice_priority': '4'}, logger)
|
utils.modify_priority({'ionice_priority': '4'}, logger)
|
||||||
@ -3590,7 +3598,16 @@ cluster_dfw1 = http://dfw1.host/v1/
|
|||||||
'ionice_class': 'IOPRIO_CLASS_BE',
|
'ionice_class': 'IOPRIO_CLASS_BE',
|
||||||
'ionice_priority': '4',
|
'ionice_priority': '4',
|
||||||
}, logger)
|
}, logger)
|
||||||
self.assertEqual(called, {'syscall': (251, 1, pid, 2 << 13 | 4)})
|
if architecture == 'x86_64' and arch_bits == '64bit':
|
||||||
|
self.assertEqual(called, {
|
||||||
|
'syscall': (251, 1, pid, 2 << 13 | 4)
|
||||||
|
})
|
||||||
|
elif architecture == 'aarch64' and arch_bits == '64bit':
|
||||||
|
self.assertEqual(called, {
|
||||||
|
'syscall': (30, 1, pid, 2 << 13 | 4)
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
self.fail("Unexpected call: %r" % called)
|
||||||
called = {}
|
called = {}
|
||||||
# all
|
# all
|
||||||
utils.modify_priority({
|
utils.modify_priority({
|
||||||
@ -3598,10 +3615,18 @@ cluster_dfw1 = http://dfw1.host/v1/
|
|||||||
'ionice_class': 'IOPRIO_CLASS_IDLE',
|
'ionice_class': 'IOPRIO_CLASS_IDLE',
|
||||||
'ionice_priority': '6',
|
'ionice_priority': '6',
|
||||||
}, logger)
|
}, logger)
|
||||||
self.assertEqual(called, {
|
if architecture == 'x86_64' and arch_bits == '64bit':
|
||||||
'setpriority': (0, pid, -15),
|
self.assertEqual(called, {
|
||||||
'syscall': (251, 1, pid, 3 << 13 | 6),
|
'setpriority': (0, pid, -15),
|
||||||
})
|
'syscall': (251, 1, pid, 3 << 13 | 6),
|
||||||
|
})
|
||||||
|
elif architecture == 'aarch64' and arch_bits == '64bit':
|
||||||
|
self.assertEqual(called, {
|
||||||
|
'setpriority': (0, pid, -15),
|
||||||
|
'syscall': (30, 1, pid, 3 << 13 | 6),
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
self.fail("Unexpected call: %r" % called)
|
||||||
|
|
||||||
def test__NR_ioprio_set(self):
|
def test__NR_ioprio_set(self):
|
||||||
with patch('os.uname', return_value=('', '', '', '', 'x86_64')), \
|
with patch('os.uname', return_value=('', '', '', '', 'x86_64')), \
|
||||||
@ -3612,6 +3637,14 @@ cluster_dfw1 = http://dfw1.host/v1/
|
|||||||
patch('platform.architecture', return_value=('32bit', '')):
|
patch('platform.architecture', return_value=('32bit', '')):
|
||||||
self.assertRaises(OSError, utils.NR_ioprio_set)
|
self.assertRaises(OSError, utils.NR_ioprio_set)
|
||||||
|
|
||||||
|
with patch('os.uname', return_value=('', '', '', '', 'aarch64')), \
|
||||||
|
patch('platform.architecture', return_value=('64bit', '')):
|
||||||
|
self.assertEqual(30, utils.NR_ioprio_set())
|
||||||
|
|
||||||
|
with patch('os.uname', return_value=('', '', '', '', 'aarch64')), \
|
||||||
|
patch('platform.architecture', return_value=('32bit', '')):
|
||||||
|
self.assertRaises(OSError, utils.NR_ioprio_set)
|
||||||
|
|
||||||
with patch('os.uname', return_value=('', '', '', '', 'alpha')), \
|
with patch('os.uname', return_value=('', '', '', '', 'alpha')), \
|
||||||
patch('platform.architecture', return_value=('64bit', '')):
|
patch('platform.architecture', return_value=('64bit', '')):
|
||||||
self.assertRaises(OSError, utils.NR_ioprio_set)
|
self.assertRaises(OSError, utils.NR_ioprio_set)
|
||||||
|
Loading…
Reference in New Issue
Block a user