From: Punit Agrawal <punitagrawal@gmail.com>
To: John Kacur <jkacur@redhat.com>
Cc: linux-rt-users@vger.kernel.org, daniel.sangorrin@toshiba.co.jp,
Punit Agrawal <punit1.agrawal@toshiba.co.jp>,
Suresh Hegde <suresh.c11@toshiba-tsip.com>
Subject: Re: [PATCH v3] rt-tests: hwlatdetect: Gracefully handle lack of /dev/cpu_dma_latency
Date: Thu, 30 Sep 2021 07:28:11 +0900 [thread overview]
Message-ID: <874ka3585g.fsf@stealth> (raw)
In-Reply-To: <8ec5eca-1152-20ab-c25-2625f563773@redhat.com> (John Kacur's message of "Wed, 29 Sep 2021 11:09:57 -0400 (EDT)")
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!
prev parent reply other threads:[~2021-09-29 22:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874ka3585g.fsf@stealth \
--to=punitagrawal@gmail.com \
--cc=daniel.sangorrin@toshiba.co.jp \
--cc=jkacur@redhat.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=punit1.agrawal@toshiba.co.jp \
--cc=suresh.c11@toshiba-tsip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.