From 031ba1135764be77e4a2ed3a10cba7d132257bb0 Mon Sep 17 00:00:00 2001 From: tone-zhang Date: Sun, 22 Jan 2017 08:19:55 +0000 Subject: [PATCH] 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 --- swift/common/utils.py | 4 ++- test/unit/common/test_utils.py | 45 +++++++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/swift/common/utils.py b/swift/common/utils.py index 94121e5b4f..4d0e3d3270 100644 --- a/swift/common/utils.py +++ b/swift/common/utils.py @@ -117,9 +117,11 @@ def NR_ioprio_set(): """Give __NR_ioprio_set value for your system.""" architecture = os.uname()[4] 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': return 251 + elif architecture == 'aarch64' and arch_bits == '64bit': + return 30 raise OSError("Swift doesn't support ionice priority for %s %s" % (architecture, arch_bits)) diff --git a/test/unit/common/test_utils.py b/test/unit/common/test_utils.py index d441059783..6ac2f31f0d 100644 --- a/test/unit/common/test_utils.py +++ b/test/unit/common/test_utils.py @@ -25,6 +25,7 @@ import eventlet.event import functools import grp import logging +import platform import os import mock import random @@ -3575,7 +3576,14 @@ cluster_dfw1 = http://dfw1.host/v1/ called = {} # just ionice class uses default priority 0 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 = {} # just ionice priority is ignored utils.modify_priority({'ionice_priority': '4'}, logger) @@ -3590,7 +3598,16 @@ cluster_dfw1 = http://dfw1.host/v1/ 'ionice_class': 'IOPRIO_CLASS_BE', 'ionice_priority': '4', }, 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 = {} # all utils.modify_priority({ @@ -3598,10 +3615,18 @@ cluster_dfw1 = http://dfw1.host/v1/ 'ionice_class': 'IOPRIO_CLASS_IDLE', 'ionice_priority': '6', }, logger) - self.assertEqual(called, { - 'setpriority': (0, pid, -15), - 'syscall': (251, 1, pid, 3 << 13 | 6), - }) + if architecture == 'x86_64' and arch_bits == '64bit': + self.assertEqual(called, { + '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): with patch('os.uname', return_value=('', '', '', '', 'x86_64')), \ @@ -3612,6 +3637,14 @@ cluster_dfw1 = http://dfw1.host/v1/ patch('platform.architecture', return_value=('32bit', '')): 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')), \ patch('platform.architecture', return_value=('64bit', '')): self.assertRaises(OSError, utils.NR_ioprio_set)