Re: [PATCH v6 18/37] tracing: Add simple expression support to hist triggers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Tom,

On Fri, Nov 17, 2017 at 02:32:57PM -0600, Tom Zanussi wrote:
> Add support for simple addition, subtraction, and unary expressions
> (-(expr) and expr, where expr = b-a, a+b, a+b+c) to hist triggers, in
> order to support a minimal set of useful inter-event calculations.
> 
> These operations are needed for calculating latencies between events
> (timestamp1-timestamp0) and for combined latencies (latencies over 3
> or more events).
> 
> In the process, factor out some common code from key and value
> parsing.
> 
> Signed-off-by: Tom Zanussi <tom.zanussi@xxxxxxxxxxxxxxx>
> ---

[SNIP]
> +static char *expr_str(struct hist_field *field, unsigned int level)
> +{
> +	char *expr;
> +
> +	if (level > 1)
> +		return NULL;
> +
> +	expr = kzalloc(MAX_FILTER_STR_VAL, GFP_KERNEL);
> +	if (!expr)
> +		return NULL;
> +
> +	if (field->operator == FIELD_OP_UNARY_MINUS) {
> +		char *subexpr;
> +
> +		strcat(expr, "-(");
> +		subexpr = expr_str(field->operands[0], ++level);
> +		if (!subexpr) {
> +			kfree(expr);
> +			return NULL;
> +		}
> +		strcat(expr, subexpr);
> +		strcat(expr, ")");
> +
> +		return expr;

The subexpr was leaked.

Thanks,
Namhyung


> +	}
> +
> +	strcat(expr, hist_field_name(field->operands[0], 0));
> +	if (field->operands[0]->flags) {
> +		const char *flags_str = get_hist_field_flags(field->operands[0]);
> +
> +		if (flags_str) {
> +			strcat(expr, ".");
> +			strcat(expr, flags_str);
> +		}
> +	}
> +
> +	switch (field->operator) {
> +	case FIELD_OP_MINUS:
> +		strcat(expr, "-");
> +		break;
> +	case FIELD_OP_PLUS:
> +		strcat(expr, "+");
> +		break;
> +	default:
> +		kfree(expr);
> +		return NULL;
> +	}
> +
> +	strcat(expr, hist_field_name(field->operands[1], 0));
> +	if (field->operands[1]->flags) {
> +		const char *flags_str = get_hist_field_flags(field->operands[1]);
> +
> +		if (flags_str) {
> +			strcat(expr, ".");
> +			strcat(expr, flags_str);
> +		}
> +	}
> +
> +	return expr;
> +}
--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux