diff options
Diffstat (limited to 'tools/perf/util/expr.c')
| -rw-r--r-- | tools/perf/util/expr.c | 40 | 
1 files changed, 19 insertions, 21 deletions
diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c index c15a9852fa41..aaacf514dc09 100644 --- a/tools/perf/util/expr.c +++ b/tools/perf/util/expr.c @@ -182,7 +182,7 @@ int expr__add_ref(struct expr_parse_ctx *ctx, struct metric_ref *ref)  {  	struct expr_id_data *data_ptr = NULL, *old_data = NULL;  	char *old_key = NULL; -	char *name, *p; +	char *name;  	int ret;  	data_ptr = zalloc(sizeof(*data_ptr)); @@ -196,15 +196,6 @@ int expr__add_ref(struct expr_parse_ctx *ctx, struct metric_ref *ref)  	}  	/* -	 * The jevents tool converts all metric expressions -	 * to lowercase, including metric references, hence -	 * we need to add lowercase name for metric, so it's -	 * properly found. -	 */ -	for (p = name; *p; p++) -		*p = tolower(*p); - -	/*  	 * Intentionally passing just const char pointers,  	 * originally from 'struct pmu_event' object.  	 * We don't need to change them, so there's no @@ -310,7 +301,9 @@ struct expr_parse_ctx *expr__ctx_new(void)  		free(ctx);  		return NULL;  	} -	ctx->runtime = 0; +	ctx->sctx.user_requested_cpu_list = NULL; +	ctx->sctx.runtime = 0; +	ctx->sctx.system_wide = false;  	return ctx;  } @@ -332,6 +325,10 @@ void expr__ctx_free(struct expr_parse_ctx *ctx)  	struct hashmap_entry *cur;  	size_t bkt; +	if (!ctx) +		return; + +	free(ctx->sctx.user_requested_cpu_list);  	hashmap__for_each_entry(ctx->ids, cur, bkt) {  		free((char *)cur->key);  		free(cur->value); @@ -344,16 +341,13 @@ static int  __expr__parse(double *val, struct expr_parse_ctx *ctx, const char *expr,  	      bool compute_ids)  { -	struct expr_scanner_ctx scanner_ctx = { -		.runtime = ctx->runtime, -	};  	YY_BUFFER_STATE buffer;  	void *scanner;  	int ret;  	pr_debug2("parsing metric: %s\n", expr); -	ret = expr_lex_init_extra(&scanner_ctx, &scanner); +	ret = expr_lex_init_extra(&ctx->sctx, &scanner);  	if (ret)  		return ret; @@ -410,16 +404,11 @@ double arch_get_tsc_freq(void)  }  #endif -double expr__get_literal(const char *literal) +double expr__get_literal(const char *literal, const struct expr_scanner_ctx *ctx)  {  	static struct cpu_topology *topology;  	double result = NAN; -	if (!strcasecmp("#smt_on", literal)) { -		result = smt_on() > 0 ? 1.0 : 0.0; -		goto out; -	} -  	if (!strcmp("#num_cpus", literal)) {  		result = cpu__max_present_cpu().cpu;  		goto out; @@ -443,6 +432,15 @@ double expr__get_literal(const char *literal)  			goto out;  		}  	} +	if (!strcasecmp("#smt_on", literal)) { +		result = smt_on(topology) ? 1.0 : 0.0; +		goto out; +	} +	if (!strcmp("#core_wide", literal)) { +		result = core_wide(ctx->system_wide, ctx->user_requested_cpu_list, topology) +			? 1.0 : 0.0; +		goto out; +	}  	if (!strcmp("#num_packages", literal)) {  		result = topology->package_cpus_lists;  		goto out;  | 
