intel/perf: Move perf query register programming to static tables.

And now that they're static tables, we don't need to ralloc a copy in
non-shared memory.

Saves ~210k in the built intel drivers.

Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1048434
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5829>
This commit is contained in:
Eric Anholt
2020-07-09 09:41:45 -07:00
committed by Marge Bot
parent d4e56930c2
commit d735f075a6
4 changed files with 21 additions and 12 deletions

View File

@@ -328,13 +328,13 @@ i915_add_config(struct gen_perf_config *perf, int fd,
memcpy(i915_config.uuid, guid, sizeof(i915_config.uuid)); memcpy(i915_config.uuid, guid, sizeof(i915_config.uuid));
i915_config.n_mux_regs = config->n_mux_regs; i915_config.n_mux_regs = config->n_mux_regs;
i915_config.mux_regs_ptr = to_user_pointer(config->mux_regs); i915_config.mux_regs_ptr = to_const_user_pointer(config->mux_regs);
i915_config.n_boolean_regs = config->n_b_counter_regs; i915_config.n_boolean_regs = config->n_b_counter_regs;
i915_config.boolean_regs_ptr = to_user_pointer(config->b_counter_regs); i915_config.boolean_regs_ptr = to_const_user_pointer(config->b_counter_regs);
i915_config.n_flex_regs = config->n_flex_regs; i915_config.n_flex_regs = config->n_flex_regs;
i915_config.flex_regs_ptr = to_user_pointer(config->flex_regs); i915_config.flex_regs_ptr = to_const_user_pointer(config->flex_regs);
int ret = gen_ioctl(fd, DRM_IOCTL_I915_PERF_ADD_CONFIG, &i915_config); int ret = gen_ioctl(fd, DRM_IOCTL_I915_PERF_ADD_CONFIG, &i915_config);
return ret > 0 ? ret : 0; return ret > 0 ? ret : 0;
@@ -748,9 +748,9 @@ gen_perf_load_configuration(struct gen_perf_config *perf_cfg, int fd, const char
* struct gen_perf_query_register_prog maps exactly to the tuple of * struct gen_perf_query_register_prog maps exactly to the tuple of
* (register offset, register value) returned by the i915. * (register offset, register value) returned by the i915.
*/ */
i915_config.flex_regs_ptr = to_user_pointer(config->flex_regs); i915_config.flex_regs_ptr = to_const_user_pointer(config->flex_regs);
i915_config.mux_regs_ptr = to_user_pointer(config->mux_regs); i915_config.mux_regs_ptr = to_const_user_pointer(config->mux_regs);
i915_config.boolean_regs_ptr = to_user_pointer(config->b_counter_regs); i915_config.boolean_regs_ptr = to_const_user_pointer(config->b_counter_regs);
if (!i915_query_perf_config_data(perf_cfg, fd, guid, &i915_config)) { if (!i915_query_perf_config_data(perf_cfg, fd, guid, &i915_config)) {
ralloc_free(config); ralloc_free(config);
return NULL; return NULL;

View File

@@ -190,13 +190,13 @@ struct gen_perf_query_register_prog {
/* Register programming for a given query */ /* Register programming for a given query */
struct gen_perf_registers { struct gen_perf_registers {
struct gen_perf_query_register_prog *flex_regs; const struct gen_perf_query_register_prog *flex_regs;
uint32_t n_flex_regs; uint32_t n_flex_regs;
struct gen_perf_query_register_prog *mux_regs; const struct gen_perf_query_register_prog *mux_regs;
uint32_t n_mux_regs; uint32_t n_mux_regs;
struct gen_perf_query_register_prog *b_counter_regs; const struct gen_perf_query_register_prog *b_counter_regs;
uint32_t n_b_counter_regs; uint32_t n_b_counter_regs;
}; };

View File

@@ -430,10 +430,14 @@ def generate_register_configs(set):
c_indent(3) c_indent(3)
registers = register_config.findall('register') registers = register_config.findall('register')
c("query->config.%s = rzalloc_array(query, struct gen_perf_query_register_prog, %d);" % (t, len(registers))) c("static const struct gen_perf_query_register_prog %s[] = {" % t)
c_indent(3)
for register in registers: for register in registers:
c("query->config.%s[query->config.n_%s++] = (struct gen_perf_query_register_prog) { .reg = %s, .val = %s };" % c("{ .reg = %s, .val = %s }," % (register.get('address'), register.get('value')))
(t, t, register.get('address'), register.get('value'))) c_outdent(3)
c("};")
c("query->config.%s = %s;" % (t, t))
c("query->config.n_%s = ARRAY_SIZE(%s);" % (t, t))
if availability: if availability:
c_outdent(3) c_outdent(3)

View File

@@ -31,6 +31,11 @@ static inline uint64_t to_user_pointer(void *ptr)
return (uintptr_t) ptr; return (uintptr_t) ptr;
} }
static inline uint64_t to_const_user_pointer(const void *ptr)
{
return (uintptr_t) ptr;
}
static inline void static inline void
gen_perf_query_add_stat_reg(struct gen_perf_query_info *query, uint32_t reg, gen_perf_query_add_stat_reg(struct gen_perf_query_info *query, uint32_t reg,
uint32_t numerator, uint32_t denominator, uint32_t numerator, uint32_t denominator,