[PATCH] rt-tests: hwlatdetect: Gracefully handle lack of /dev/cpu_dma_latency

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Punit Agrawal <punit1.agrawal@xxxxxxxxxxxxx>

On systems where cpu idle is disabled to reduce latencies,
"/dev/cpu_dma_latency" does not exist and leads to the following
exception report from python when using hwlatdetect.py -

    FileNotFoundError: [Errno 2] No such file or directory: '/dev/cpu_dma_latency

Update hwlatdetect to check whether the file exists before attemping
to write values to it.

Reported-by: Suresh Hegde <suresh1.hegde@xxxxxxxxxxxxx>
Signed-off-by: Punit Agrawal <punit1.agrawal@xxxxxxxxxxxxx>
---
 src/hwlatdetect/hwlatdetect.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
index 12228f45f852..89537a6e371f 100755
--- a/src/hwlatdetect/hwlatdetect.py
+++ b/src/hwlatdetect/hwlatdetect.py
@@ -216,8 +216,11 @@ class Detector(object):
     # use c_states_on() to close the file descriptor and re-enable c-states
     #
     def c_states_off(self):
-        self.dma_latency_handle = os.open("/dev/cpu_dma_latency", os.O_WRONLY)
-        os.write(self.dma_latency_handle, b'\x00\x00\x00\x00')
+        if os.path.exists("/dev/cpu_dma_latency"):
+            self.dma_latency_handle = os.open("/dev/cpu_dma_latency", os.O_WRONLY)
+            os.write(self.dma_latency_handle, b'\x00\x00\x00\x00')
+        else:
+            self.dma_latency_handle = None
         debug("c-states disabled")
 
     def c_states_on(self):
-- 
2.32.0




[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux