lkml.org 
[lkml]   [2021]   [Oct]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/5] tracing: Add division and multiplication support for hist triggers
On Wed, 15 Sep 2021 19:52:46 +0000
Kalesh Singh <kaleshsingh@google.com> wrote:

> +static u64 hist_field_div(struct hist_field *hist_field,
> + struct tracing_map_elt *elt,
> + struct trace_buffer *buffer,
> + struct ring_buffer_event *rbe,
> + void *event)
> +{
> + struct hist_field *operand1 = hist_field->operands[0];
> + struct hist_field *operand2 = hist_field->operands[1];
> +
> + u64 val1 = operand1->fn(operand1, elt, buffer, rbe, event);
> + u64 val2 = operand2->fn(operand2, elt, buffer, rbe, event);
> +
> + /* Return -1 for the undefined case */
> + if (!val2)
> + return -1;
> +
> + return val1 / val2;

This wont work on x86 32 bit machines, as u64 division will trigger
floating point arithmetic by the compiler, and cause a fault.

You'll need to use one of the div64() helpers.

-- Steve


> +}
> +

\
 
 \ /
  Last update: 2021-10-19 22:47    [W:0.145 / U:0.436 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site