From: John Kacur <jkacur@redhat.com>
To: Clark Williams <williams@redhat.com>
Cc: rt-users <linux-rt-users@vger.kernel.org>
Subject: Re: [PATCH] hwlatdetect: disable/enable c-state transitions during detection
Date: Thu, 9 May 2019 16:14:29 +0200 (CEST) [thread overview]
Message-ID: <alpine.LFD.2.21.1905091612180.13440@planxty> (raw)
In-Reply-To: <20190506194046.13144-1-williams@redhat.com>
On Mon, 6 May 2019, Clark Williams wrote:
> Recent performance tuning problems led me to realize that just running
> at fifo:99 and turning off interrupts isn't enough while looking for
> BIOS induced latencies. Power savings logic is built into most modern
> cpus and so must be disabled while looking for BIOS induced (SMI/NMI)
> latencies.
>
> Use the /dev/cpu_dma_latency mechanism to disable c-state transitions
> while running the hardware latency detector. Open the file
> /dev/cpu_dma_latency and write a 32-bit zero to it, which will prevent
> c-state transitions while the file is open.
>
> Signed-off-by: Clark Williams <williams@redhat.com>
> ---
> src/hwlatdetect/hwlatdetect.py | 20 +++++++++++++++++++-
> 1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
> index 2c8f9f160419..368079a158b1 100755
> --- a/src/hwlatdetect/hwlatdetect.py
> +++ b/src/hwlatdetect/hwlatdetect.py
> @@ -1,6 +1,6 @@
> #!/usr/bin/python3
>
> -# (C) 2018 Clark Williams <williams@redhat.com>
> +# (C) 2018,2019 Clark Williams <williams@redhat.com>
> # (C) 2015,2016 Clark Williams <williams@redhat.com>
> # (C) 2009 Clark Williams <williams@redhat.com>
> #
> @@ -213,6 +213,22 @@ watch = False
> counts = [ int(x.strip()) for x in p.stdout.readlines()]
> 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.
> + # 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")
> +
> + def c_states_on(self):
> + if self.dma_latency_handle:
> + os.close(self.dma_latency_handle)
> + debug("c-states enabled")
> +
> def cleanup(self):
> raise RuntimeError("must override base method 'cleanup'!")
>
> @@ -235,6 +251,7 @@ watch = False
> def start(self):
> count = 0
> threshold = int(self.get("threshold"))
> + self.c_states_off()
> debug("enabling detector module (threshold: %d)" % threshold)
> self.set("enable", 1)
> while self.get("enable") == 0:
> @@ -258,6 +275,7 @@ watch = False
> time.sleep(0.1)
> debug("retrying disable of detector module(%d)" % count)
> self.set("enable", 0)
> + self.c_states_on()
> debug("detector module disabled")
>
> def detect(self):
> --
> 2.21.0
>
>
Signed-off-by: John Kacur <jkacur@redhat.com>
parent reply other threads:[~2019-05-09 14:14 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20190506194046.13144-1-williams@redhat.com>]
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=alpine.LFD.2.21.1905091612180.13440@planxty \
--to=jkacur@redhat.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=williams@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox