* [PATCH v3] rt-tests: hwlatdetect: Gracefully handle lack of /dev/cpu_dma_latency
@ 2021-09-29 0:37 Punit Agrawal
2021-09-29 15:09 ` John Kacur
0 siblings, 1 reply; 3+ messages in thread
From: Punit Agrawal @ 2021-09-29 0:37 UTC (permalink / raw)
To: jkacur; +Cc: linux-rt-users, daniel.sangorrin, Punit Agrawal, Suresh Hegde
From: Punit Agrawal <punit1.agrawal@toshiba.co.jp>
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. Also, make the related debug output conditional
to c-states support being enabled in the kernel.
While we are touching this part of the code, also address a couple of
minor issues in the code such as -
* correct typos
* reflow comment to fit 80-char column limit
Reported-by: Suresh Hegde <suresh.c11@toshiba-tsip.com>
Signed-off-by: Punit Agrawal <punit1.agrawal@toshiba.co.jp>
---
v2 -> v3:
* Address issues in comment
* Initialise self.dma_latency_handle in init()
* Make debug() statements conditional to /dev/cpu_dma_latency
---
src/hwlatdetect/hwlatdetect.py | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
index 12228f45f852..56fd2af8641d 100755
--- a/src/hwlatdetect/hwlatdetect.py
+++ b/src/hwlatdetect/hwlatdetect.py
@@ -200,6 +200,7 @@ class Detector(object):
if os.path.exists('/usr/sbin/rdmsr'):
self.have_msr = True
self.initsmi = self.getsmicounts()
+ self.dma_latency_handle = None
def getsmicounts(self):
counts = []
@@ -210,20 +211,23 @@ class Detector(object):
return counts
# methods for preventing/enabling c-state transitions
- # openinging /dev/cpu_dma_latency and writeing a 32-bit zero to that file will prevent
- # c-state transitions while the file descriptor is open.
+ #
+ # opening /dev/cpu_dma_latency and writing a 32-bit zero to that file will
+ # prevent c-state transitions while the file descriptor is open.
+ #
# use c_states_off() to disable c-state transitions
# 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')
- debug("c-states disabled")
+ 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')
+ debug("c-states disabled")
def c_states_on(self):
if self.dma_latency_handle:
os.close(self.dma_latency_handle)
- debug("c-states enabled")
+ debug("c-states enabled")
def cleanup(self):
raise RuntimeError("must override base method 'cleanup'!")
--
2.32.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3] rt-tests: hwlatdetect: Gracefully handle lack of /dev/cpu_dma_latency
2021-09-29 0:37 [PATCH v3] rt-tests: hwlatdetect: Gracefully handle lack of /dev/cpu_dma_latency Punit Agrawal
@ 2021-09-29 15:09 ` John Kacur
2021-09-29 22:28 ` Punit Agrawal
0 siblings, 1 reply; 3+ messages in thread
From: John Kacur @ 2021-09-29 15:09 UTC (permalink / raw)
To: Punit Agrawal
Cc: linux-rt-users, daniel.sangorrin, Punit Agrawal, Suresh Hegde
On Wed, 29 Sep 2021, Punit Agrawal wrote:
> From: Punit Agrawal <punit1.agrawal@toshiba.co.jp>
>
> 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. Also, make the related debug output conditional
> to c-states support being enabled in the kernel.
>
> While we are touching this part of the code, also address a couple of
> minor issues in the code such as -
> * correct typos
> * reflow comment to fit 80-char column limit
>
> Reported-by: Suresh Hegde <suresh.c11@toshiba-tsip.com>
> Signed-off-by: Punit Agrawal <punit1.agrawal@toshiba.co.jp>
> ---
> v2 -> v3:
> * Address issues in comment
> * Initialise self.dma_latency_handle in init()
> * Make debug() statements conditional to /dev/cpu_dma_latency
> ---
> src/hwlatdetect/hwlatdetect.py | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
> index 12228f45f852..56fd2af8641d 100755
> --- a/src/hwlatdetect/hwlatdetect.py
> +++ b/src/hwlatdetect/hwlatdetect.py
> @@ -200,6 +200,7 @@ class Detector(object):
> if os.path.exists('/usr/sbin/rdmsr'):
> self.have_msr = True
> self.initsmi = self.getsmicounts()
> + self.dma_latency_handle = None
>
> def getsmicounts(self):
> counts = []
> @@ -210,20 +211,23 @@ class Detector(object):
> return counts
>
> # methods for preventing/enabling c-state transitions
> - # openinging /dev/cpu_dma_latency and writeing a 32-bit zero to that file will prevent
> - # c-state transitions while the file descriptor is open.
> + #
> + # opening /dev/cpu_dma_latency and writing a 32-bit zero to that file will
> + # prevent c-state transitions while the file descriptor is open.
> + #
> # use c_states_off() to disable c-state transitions
> # 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')
> - debug("c-states disabled")
> + 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')
> + debug("c-states disabled")
>
> def c_states_on(self):
> if self.dma_latency_handle:
> os.close(self.dma_latency_handle)
> - debug("c-states enabled")
> + debug("c-states enabled")
>
> def cleanup(self):
> raise RuntimeError("must override base method 'cleanup'!")
> --
> 2.32.0
>
>
Signed-off-by: John Kacur <jkacur@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] rt-tests: hwlatdetect: Gracefully handle lack of /dev/cpu_dma_latency
2021-09-29 15:09 ` John Kacur
@ 2021-09-29 22:28 ` Punit Agrawal
0 siblings, 0 replies; 3+ messages in thread
From: Punit Agrawal @ 2021-09-29 22:28 UTC (permalink / raw)
To: John Kacur; +Cc: linux-rt-users, daniel.sangorrin, Punit Agrawal, Suresh Hegde
John Kacur <jkacur@redhat.com> writes:
> On Wed, 29 Sep 2021, Punit Agrawal wrote:
>
>> From: Punit Agrawal <punit1.agrawal@toshiba.co.jp>
>>
>> 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. Also, make the related debug output conditional
>> to c-states support being enabled in the kernel.
>>
>> While we are touching this part of the code, also address a couple of
>> minor issues in the code such as -
>> * correct typos
>> * reflow comment to fit 80-char column limit
>>
>> Reported-by: Suresh Hegde <suresh.c11@toshiba-tsip.com>
>> Signed-off-by: Punit Agrawal <punit1.agrawal@toshiba.co.jp>
>> ---
>> v2 -> v3:
>> * Address issues in comment
>> * Initialise self.dma_latency_handle in init()
>> * Make debug() statements conditional to /dev/cpu_dma_latency
>> ---
>> src/hwlatdetect/hwlatdetect.py | 16 ++++++++++------
>> 1 file changed, 10 insertions(+), 6 deletions(-)
>>
>> diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
>> index 12228f45f852..56fd2af8641d 100755
>> --- a/src/hwlatdetect/hwlatdetect.py
>> +++ b/src/hwlatdetect/hwlatdetect.py
>> @@ -200,6 +200,7 @@ class Detector(object):
>> if os.path.exists('/usr/sbin/rdmsr'):
>> self.have_msr = True
>> self.initsmi = self.getsmicounts()
>> + self.dma_latency_handle = None
>>
>> def getsmicounts(self):
>> counts = []
>> @@ -210,20 +211,23 @@ class Detector(object):
>> return counts
>>
>> # methods for preventing/enabling c-state transitions
>> - # openinging /dev/cpu_dma_latency and writeing a 32-bit zero to that file will prevent
>> - # c-state transitions while the file descriptor is open.
>> + #
>> + # opening /dev/cpu_dma_latency and writing a 32-bit zero to that file will
>> + # prevent c-state transitions while the file descriptor is open.
>> + #
>> # use c_states_off() to disable c-state transitions
>> # 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')
>> - debug("c-states disabled")
>> + 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')
>> + debug("c-states disabled")
>>
>> def c_states_on(self):
>> if self.dma_latency_handle:
>> os.close(self.dma_latency_handle)
>> - debug("c-states enabled")
>> + debug("c-states enabled")
>>
>> def cleanup(self):
>> raise RuntimeError("must override base method 'cleanup'!")
>> --
>> 2.32.0
>>
>>
>
> Signed-off-by: John Kacur <jkacur@redhat.com>
Thanks for applying the patch!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-29 22:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-29 0:37 [PATCH v3] rt-tests: hwlatdetect: Gracefully handle lack of /dev/cpu_dma_latency Punit Agrawal
2021-09-29 15:09 ` John Kacur
2021-09-29 22:28 ` Punit Agrawal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox