]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/seastar/scripts/perftune.py
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / seastar / scripts / perftune.py
index e92fadef0a3f455b89272b7e360a00c0a4a4e21a..516cd3ef84be434625789d7c0ed785a7b17ee814 100755 (executable)
@@ -501,6 +501,10 @@ class NetPerfTuner(PerfTunerBase):
     def nic(self):
         return self.args.nic
 
+    @property
+    def nic_exists(self):
+        return self.__iface_exists(self.nic)
+
     @property
     def nic_is_hw_iface(self):
         return self.__dev_is_hw_iface(self.nic)
@@ -537,6 +541,8 @@ class NetPerfTuner(PerfTunerBase):
         """
         Checks that self.nic is a supported interface
         """
+        if not self.nic_exists:
+            raise Exception("Device {} does not exist".format(self.nic))
         if not self.nic_is_hw_iface and not self.nic_is_bond_iface:
             raise Exception("Not supported virtual device {}".format(self.nic))
 
@@ -591,6 +597,11 @@ class NetPerfTuner(PerfTunerBase):
         for i, mask in enumerate(masks):
             set_one_mask(xps_cpus_list[i], mask)
 
+    def __iface_exists(self, iface):
+        if len(iface) == 0:
+            return False
+        return os.path.exists("/sys/class/net/{}".format(iface))
+
     def __dev_is_hw_iface(self, iface):
         return os.path.exists("/sys/class/net/{}/device".format(iface))
 
@@ -778,11 +789,11 @@ class ClocksourceManager:
 
     def __init__(self, args):
         self.__args = args
-        self._preferred = {"x86_64": "tsc"}
-        self._arch = platform.machine()
+        self._preferred = {"x86_64": "tsc", "kvm": "kvm-clock"}
+        self._arch = self._get_arch()
         self._available_clocksources_file = "/sys/devices/system/clocksource/clocksource0/available_clocksource"
         self._current_clocksource_file = "/sys/devices/system/clocksource/clocksource0/current_clocksource"
-        self._recommendation_if_unavailable = { "x86_64": "The tsc clocksource is not available. Consider using a hardware platform where the tsc clocksource is available, or try forcing it withe the tsc=reliable boot option" }
+        self._recommendation_if_unavailable = { "x86_64": "The tsc clocksource is not available. Consider using a hardware platform where the tsc clocksource is available, or try forcing it withe the tsc=reliable boot option", "kvm": "kvm-clock is not available" }
 
     def _available_clocksources(self):
         return open(self._available_clocksources_file).readline().split()
@@ -790,6 +801,15 @@ class ClocksourceManager:
     def _current_clocksource(self):
         return open(self._current_clocksource_file).readline().strip()
 
+    def _get_arch(self):
+        try:
+            virt = run_read_only_command(['systemd-detect-virt']).strip()
+            if virt == "kvm":
+                return virt
+        except:
+            pass
+        return platform.machine()
+
     def enforce_preferred_clocksource(self):
         fwriteln(self._current_clocksource_file, self._preferred[self._arch], "Setting clocksource to {}".format(self._preferred[self._arch]))