[PATCH 01/17] block/nvme: Avoid further processing if trace event not enabled

Philippe Mathieu-Daudé posted 17 patches 5 years, 7 months ago
There is a newer version of this series
[PATCH 01/17] block/nvme: Avoid further processing if trace event not enabled
Posted by Philippe Mathieu-Daudé 5 years, 7 months ago
Avoid further processing if TRACE_NVME_SUBMIT_COMMAND_RAW is
not enabled.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 block/nvme.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/block/nvme.c b/block/nvme.c
index eb2f54dd9d..1e5b40f61c 100644
--- a/block/nvme.c
+++ b/block/nvme.c
@@ -367,6 +367,9 @@ static void nvme_trace_command(const NvmeCmd *cmd)
 {
     int i;
 
+    if (!trace_event_get_state_backends(TRACE_NVME_SUBMIT_COMMAND_RAW)) {
+        return;
+    }
     for (i = 0; i < 8; ++i) {
         uint8_t *cmdp = (uint8_t *)cmd + i * 8;
         trace_nvme_submit_command_raw(cmdp[0], cmdp[1], cmdp[2], cmdp[3],
-- 
2.21.3


Re: [PATCH 01/17] block/nvme: Avoid further processing if trace event not enabled
Posted by Stefan Hajnoczi 5 years, 7 months ago
On Thu, Jun 25, 2020 at 08:48:22PM +0200, Philippe Mathieu-Daudé wrote:
> Avoid further processing if TRACE_NVME_SUBMIT_COMMAND_RAW is
> not enabled.

Why?

This saves 8 trace events, each with 8 arguments. I guess the intent is
to improve performance. Did you measure an improvement?
Re: [PATCH 01/17] block/nvme: Avoid further processing if trace event not enabled
Posted by Philippe Mathieu-Daudé 5 years, 7 months ago
On 6/26/20 12:36 PM, Stefan Hajnoczi wrote:
> On Thu, Jun 25, 2020 at 08:48:22PM +0200, Philippe Mathieu-Daudé wrote:
>> Avoid further processing if TRACE_NVME_SUBMIT_COMMAND_RAW is
>> not enabled.
> 
> Why?
> 
> This saves 8 trace events, each with 8 arguments. I guess the intent is
> to improve performance. Did you measure an improvement?

No testing, I just tried to outsmart the compiler :/


Re: [PATCH 01/17] block/nvme: Avoid further processing if trace event not enabled
Posted by Stefan Hajnoczi 5 years, 7 months ago
On Fri, Jun 26, 2020 at 04:02:43PM +0200, Philippe Mathieu-Daudé wrote:
> On 6/26/20 12:36 PM, Stefan Hajnoczi wrote:
> > On Thu, Jun 25, 2020 at 08:48:22PM +0200, Philippe Mathieu-Daudé wrote:
> >> Avoid further processing if TRACE_NVME_SUBMIT_COMMAND_RAW is
> >> not enabled.
> > 
> > Why?
> > 
> > This saves 8 trace events, each with 8 arguments. I guess the intent is
> > to improve performance. Did you measure an improvement?
> 
> No testing, I just tried to outsmart the compiler :/

Usually performance patches are accompanied with benchmark results.
Otherwise it's easy to modify code without making a difference or
accidentally introducing performance regressions. But this is a small
change and I'm not worried.

Please do explicitly state in the commit description that this is
intended as a performance optimization. I wasn't exactly sure about the
reason for this change.

Stefan