Dynamic EU configuration of Slice/Sub-slice/EU
Subsystems (2)
v6 cover Dynamic EU configuration of Slice/Sub-slice/EU
drm/i915: Context aware user agnostic EU/Slice/Sub-slice control within kernel
This patch sets improves GPU power consumption on Linux kernel based OS such as Chromium OS, Ubuntu, etc. Following are the power savings.
Power savings on GLK-GT1 Bobba platform running on Chrome OS.
-----------------------------------------------| App /KPI | % Power Benefit (mW) | ------------------------|----------------------| Hangout Call- 20 minute | 1.8% | Youtube 4K VPB | 14.13% | WebGL Aquarium | 13.76% | Unity3D | 6.78% | | | ------------------------|----------------------| Chrome PLT | BatteryLife Improves | | by ~45 minute | -----------------------------------------------|
Power savings on KBL-GT3 running on Android and Ubuntu (Linux). -----------------------------------------------|
App /KPI | % Power Benefit (mW) |
|----------------------| | Android | Ubuntu | ------------------------|----------|-----------| 3D Mark (Ice storm) | 2.30% | N.A. | TRex On screen | 2.49% | 2.97% | Manhattan On screen | 3.11% | 4.90% | Carchase On Screen | N.A. | 5.06% | AnTuTu 6.1.4 | 3.42% | N.A. | SynMark2 | N.A. | 1.7% | -----------------------------------------------|
We have also observed GPU core residencies improves by 1.035%.
Technical Insights of the patch:
Current GPU configuration code for i915 does not allow us to change EU/Slice/Sub-slice configuration dynamically. Its done only once while context is created.
While particular graphics application is running, if we examine the command requests from user space, we observe that command density is not consistent. It means there is scope to change the graphics configuration dynamically even while context is running actively. This patch series proposes the solution to find the active pending load for all active context at given time and based on that, dynamically perform graphics configuration for each context.
We use a hr (high resolution) timer with i915 driver in kernel to get a callback every few milliseconds (this timer value can be configured through debugfs, default is '0' indicating timer is in disabled state i.e. original system without any intervention).In the timer callback, we examine pending commands for a context in the queue, essentially, we intercept them before they are executed by GPU and we update context with required number of EUs.
Two questions, how did we arrive at right timer value? and what's the right number of EUs? For the prior one, empirical data to achieve best performance in least power was considered. For the later one, we roughly categorized number of EUs logically based on platform. Now we compare number of pending commands with a particular threshold and then set number of EUs accordingly with update context. That threshold is also based on experiments & findings. If GPU is able to catch up with CPU, typically there are no pending commands, the EU config would remain unchanged there. In case there are more pending commands we reprogram context with higher number of EUs. Please note, here we are changing EUs even while context is running by examining pending commands every 'x' milliseconds.
Ankit Navik (3):
drm/i915: Get active pending request for given context drm/i915: set optimum eu/slice/sub-slice configuration based on load
type
drm/i915: Predictive governor to control slice/subslice/eu
drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/gem/i915_gem_context.c | 20 +++++ drivers/gpu/drm/i915/gem/i915_gem_context.h | 2 + drivers/gpu/drm/i915/gem/i915_gem_context_types.h | 37 ++++++++ drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 2 + drivers/gpu/drm/i915/gt/intel_deu.c | 105 ++++++++++++++++++++++ drivers/gpu/drm/i915/gt/intel_deu.h | 8 ++ drivers/gpu/drm/i915/gt/intel_lrc.c | 45 +++++++++- drivers/gpu/drm/i915/i915_drv.h | 9 ++ drivers/gpu/drm/i915/i915_gem.c | 4 + drivers/gpu/drm/i915/i915_params.c | 4 + drivers/gpu/drm/i915/i915_params.h | 1 + drivers/gpu/drm/i915/intel_device_info.c | 58 +++++++++++- 13 files changed, 292 insertions(+), 4 deletions(-) create mode 100644 drivers/gpu/drm/i915/gt/intel_deu.c create mode 100644 drivers/gpu/drm/i915/gt/intel_deu.h
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v6 1/3 drm/i915: Get active pending request for given context
This patch gives us the active pending request count which is yet to be submitted to the GPU.
V2:
* Change 64-bit to atomic for request count. (Tvrtko Ursulin)
V3:
* Remove mutex for request count.
* Rebase.
* Fixes hitting underflow for predictive request. (Tvrtko Ursulin)
V4:
* Rebase.
V5:
* Rebase.
V6
* Rebase.
--- drivers/gpu/drm/i915/gem/i915_gem_context.c | 1 + drivers/gpu/drm/i915/gem/i915_gem_context_types.h | 5 +++++ drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 2 ++ drivers/gpu/drm/i915/gt/intel_lrc.c | 3 +++ 4 files changed, 11 insertions(+)
drivers/gpu/drm/i915/gem/i915_gem_context.c +1 -0
@@ -711,6 +711,7 @@ i915_gem_create_context(struct drm_i915_private *i915, unsigned int flags) }trace_i915_context_create (ctx); +atomic_set (&ctx->req_cnt,0 );return ctx; }
drivers/gpu/drm/i915/gem/i915_gem_context_types.h +5 -0
@@ -168,6 +168,11 @@ struct i915_gem_context {*/ struct radix_tree_root handles_vma; +/** req_cnt: tracks the pending commands, based on which we decide to +* go for low/medium/high load configuration of the GPU. +*/ +atomic_t req_cnt; +/** jump_whitelist: Bit array for tracking cmds during cmdparsing * Guarded by struct_mutex */
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +2 -0
@@ -2700,6 +2700,8 @@ i915_gem_do_execbuffer(struct drm_device *dev,if (eb.batch->private)intel_engine_pool_mark_active (eb.batch->private, eb.request); +atomic_inc (&eb.gem_context->req_cnt); +trace_i915_request_queue (eb.request, eb.batch_flags); err =eb_submit (&eb); err_request:
drivers/gpu/drm/i915/gt/intel_lrc.c +3 -0
@@ -1947,6 +1947,9 @@ static void execlists_dequeue(struct intel_engine_cs *engine) submit = true; last = rq; + +if (atomic_read (&rq->gem_context->req_cnt) >0 ) +atomic_dec (&rq->gem_context->req_cnt); } }
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v6 2/3 drm/i915: set optimum eu/slice/sub-slice configuration based on load type
In reply to Ankit NavikThis patch will select optimum eu/slice/sub-slice configuration based on type of load (low, medium, high) as input.
Based on our readings and experiments we have predefined set of optimum configuration for each platform(CHT, KBL). i915_gem_context_set_load_type will select optimum configuration from pre-defined optimum configuration table(opt_config).
It also introduce flag update_render_config which can set by any governor.
v2:
* Move static optimum_config to device init time.
* Rename function to appropriate name, fix data types and patch ordering.
* Rename prev_load_type to pending_load_type. (Tvrtko Ursulin)
v3:
* Add safe guard check in i915_gem_context_set_load_type.
* Rename struct from optimum_config to i915_sseu_optimum_config to avoid namespace clashes.
* Reduces memcpy for space efficient.
* Rebase.
* Improved commit message. (Tvrtko Ursulin)
v4:
* Move optimum config table to file scope. (Tvrtko Ursulin)
v5:
* Adds optimal table of slice/sub-slice/EU for Gen 9 GT1.
* Rebase.
v6:
* Rebase.
--- drivers/gpu/drm/i915/gem/i915_gem_context.c | 19 ++++++++ drivers/gpu/drm/i915/gem/i915_gem_context.h | 2 + drivers/gpu/drm/i915/gem/i915_gem_context_types.h | 32 +++++++++++++ drivers/gpu/drm/i915/gt/intel_lrc.c | 42 +++++++++++++++- drivers/gpu/drm/i915/i915_drv.h | 5 ++ drivers/gpu/drm/i915/intel_device_info.c | 58 ++++++++++++++++++++++- 6 files changed, 154 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_context.c +19 -0
@@ -712,10 +712,29 @@ i915_gem_create_context(struct drm_i915_private *i915, unsigned int flags)trace_i915_context_create (ctx);atomic_set (&ctx->req_cnt,0 ); + ctx->slice_cnt =hweight8 (RUNTIME_INFO (i915)->sseu.slice_mask); + ctx->subslice_cnt =hweight8 ( +RUNTIME_INFO (i915)->sseu.subslice_mask[0 ]); + ctx->eu_cnt =RUNTIME_INFO (i915)->sseu.eu_per_subslice;return ctx; } +void i915_gem_context_set_load_type (struct i915_gem_context *ctx, +enum gem_load_type type) +{ +struct drm_i915_private *dev_priv = ctx->i915; + +if (GEM_WARN_ON (type >LOAD_TYPE_LAST )) +return ; + +/* Call opt_config to get correct configuration for eu,slice,subslice */ + ctx->slice_cnt = dev_priv->opt_config[type].slice; + ctx->subslice_cnt = dev_priv->opt_config[type].subslice; + ctx->eu_cnt = dev_priv->opt_config[type].eu; + ctx->pending_load_type = type; +} +static void destroy_kernel_context (struct i915_gem_context **ctxp) {
drivers/gpu/drm/i915/gem/i915_gem_context.h +2 -0
@@ -177,6 +177,8 @@ int i915_gem_context_setparam_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);int i915_gem_context_reset_stats_ioctl (struct drm_device *dev,void *data,struct drm_file *file); +void i915_gem_context_set_load_type (struct i915_gem_context *ctx, +enum gem_load_type type);struct i915_gem_context *i915_gem_context_create_kernel (struct drm_i915_private *i915,int prio);
drivers/gpu/drm/i915/gem/i915_gem_context_types.h +32 -0
@@ -40,6 +40,19 @@ struct i915_gem_engines_iter {const struct i915_gem_engines *engines; }; +enum gem_load_type { +LOAD_TYPE_LOW , +LOAD_TYPE_MEDIUM , +LOAD_TYPE_HIGH , +LOAD_TYPE_LAST +}; + +struct i915_sseu_optimum_config { +u8 slice; +u8 subslice; +u8 eu; +}; +/** * struct i915_gem_context - client state *
@@ -173,6 +186,25 @@ struct i915_gem_context {*/ atomic_t req_cnt; +/** slice_cnt: used to set the # of slices to be enabled. */ +u8 slice_cnt; + +/** subslice_cnt: used to set the # of subslices to be enabled. */ +u8 subslice_cnt; + +/** eu_cnt: used to set the # of eu to be enabled. */ +u8 eu_cnt; + +/** load_type: The designated load_type (high/medium/low) for a given +* number of pending commands in the command queue. +*/ +enum gem_load_type load_type; + +/** pending_load_type: The earlier load type that the GPU was configured +* for (high/medium/low). +*/ +enum gem_load_type pending_load_type; +/** jump_whitelist: Bit array for tracking cmds during cmdparsing * Guarded by struct_mutex */
drivers/gpu/drm/i915/gt/intel_lrc.c +40 -2
60 lines not on this page · raw message
drivers/gpu/drm/i915/i915_drv.h +5 -0
@@ -999,6 +999,11 @@ struct drm_i915_private {/* protects panel power sequencer state */ struct mutex pps_mutex; +/* optimal slice/subslice/EU configration state */ +struct i915_sseu_optimum_config *opt_config; + +int predictive_load_enable; +unsigned int fsb_freq, mem_freq, is_ddr3;unsigned int skl_preferred_vco_freq;unsigned int max_cdclk_freq;
drivers/gpu/drm/i915/intel_device_info.c +56 -2
86 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v6 3/3 drm/i915: Predictive governor to control slice/subslice/eu
In reply to Ankit NavikHigh resolution timer is used for predictive governor to control eu/slice/subslice based on workloads.
param is provided to enable/disable/update timer configuration
V2:
* Fix code style.
* Move predictive_load_timer into a drm_i915_private structure.
* Make generic function to set optimum config. (Tvrtko Ursulin)
V3:
* Rebase.
* Fix race condition for predictive load set.
* Add slack to start hrtimer for more power efficient. (Tvrtko Ursulin)
V4:
* Fix data type and initialization of mutex to protect predictive load state.
* Move predictive timer init to i915_gem_init_early. (Tvrtko Ursulin)
* Move debugfs to kernel parameter.
V5:
* Rebase.
* Remove mutex for pred_timer
V6:
* Rebase.
--- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/gt/intel_deu.c | 105 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/gt/intel_deu.h | 8 +++ drivers/gpu/drm/i915/i915_drv.h | 4 ++ drivers/gpu/drm/i915/i915_gem.c | 4 ++ drivers/gpu/drm/i915/i915_params.c | 4 ++ drivers/gpu/drm/i915/i915_params.h | 1 + 7 files changed, 127 insertions(+) create mode 100644 drivers/gpu/drm/i915/gt/intel_deu.c create mode 100644 drivers/gpu/drm/i915/gt/intel_deu.h
drivers/gpu/drm/i915/Makefile +1 -0
@@ -77,6 +77,7 @@ obj-y += gt/ gt-y += \ gt/intel_breadcrumbs.o \ gt/intel_context.o \ + gt/intel_deu.o \ gt/intel_engine_cs.o \ gt/intel_engine_heartbeat.o \ gt/intel_engine_pm.o \
drivers/gpu/drm/i915/gt/intel_deu.c new file +105 -0
105 lines not on this page · raw message
drivers/gpu/drm/i915/gt/intel_deu.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef __INTEL_DEU_H__ +#define __INTEL_DEU_H__ + +struct drm_i915_private ; + +void intel_deu_init (struct drm_i915_private *dev_priv); + +#endif /* __INTEL_DEU_H__ */
drivers/gpu/drm/i915/i915_drv.h +4 -0
@@ -1002,6 +1002,8 @@ struct drm_i915_private {/* optimal slice/subslice/EU configration state */ struct i915_sseu_optimum_config *opt_config; +/* protects predictive load state */ +struct hrtimer pred_timer;int predictive_load_enable;unsigned int fsb_freq, mem_freq, is_ddr3;
@@ -1768,6 +1770,8 @@ long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);#endif extern const struct dev_pm_ops i915_pm_ops; +extern enum hrtimer_restart predictive_load_cb (struct hrtimer *hrtimer); +int i915_driver_probe (struct pci_dev *pdev,const struct pci_device_id *ent);void i915_driver_remove (struct drm_i915_private *i915);
drivers/gpu/drm/i915/i915_gem.c +4 -0
@@ -45,6 +45,7 @@#include "gem/i915_gem_context.h" #include "gem/i915_gem_ioctls.h" #include "gem/i915_gem_pm.h" +#include "gt/intel_deu.h" #include "gt/intel_context.h" #include "gt/intel_engine_user.h" #include "gt/intel_gt.h"
@@ -1416,6 +1417,9 @@ void i915_gem_init_early(struct drm_i915_private *dev_priv)i915_gem_init__mm (dev_priv);spin_lock_init (&dev_priv->fb_tracking.lock); + +/* Dynamic EU timer initialization for predictive load */ +intel_deu_init (dev_priv); }void i915_gem_cleanup_early (struct drm_i915_private *dev_priv)
drivers/gpu/drm/i915/i915_params.c +4 -0
@@ -101,6 +101,10 @@ i915_param_named_unsafe(disable_power_well, int, 0400,i915_param_named_unsafe (enable_ips, int,0600 ,"Enable IPS (default: true)" ); +i915_param_named_unsafe (deu_enable, int,0600 , +"Enable dynamic EU control for power savings " +"(0=disable deu predictive timer [default], 150=optimal deu predictive timer)" ); +i915_param_named (fastboot, int,0600 ,"Try to skip unnecessary mode sets at boot time " "(0=disabled, 1=enabled) "
drivers/gpu/drm/i915/i915_params.h +1 -0
@@ -54,6 +54,7 @@ struct drm_printer; param(int, disable_power_well, -1) \ param(int, enable_ips, 1) \ param(int, invert_brightness, 0) \ + param(int, deu_enable, 0) \ param(int, enable_guc, 0) \ param(int, guc_log_level, -1) \ param(char *, guc_firmware_path, NULL) \
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BUILD: failure for Dynamic EU configuration of Slice/Sub-slice/EU (rev2)
In reply to Ankit Navik== Series Details ==
== Series Details ==
Series: Dynamic EU configuration of Slice/Sub-slice/EU (rev2)
URL : https://patchwork.freedesktop.org/series/69980/
State : failure
== Summary ==
CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool
CHK include/generated/compile.h
AR drivers/gpu/drm/i915/built-in.a
CC [M] drivers/gpu/drm/i915/intel_device_info.o
drivers/gpu/drm/i915/intel_device_info.c: In function ‘intel_device_info_runtime_init’:
drivers/gpu/drm/i915/intel_device_info.c:1033:14: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
opt_config = chv_config;
^
drivers/gpu/drm/i915/intel_device_info.c:1044:15: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
opt_config = glk_gt1_config;
^
drivers/gpu/drm/i915/intel_device_info.c:1048:15: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
opt_config = kbl_gt2_config;
^
drivers/gpu/drm/i915/intel_device_info.c:1053:15: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
opt_config = kbl_gt3_config;
^
In file included from ./include/drm/drm_print.h:29:0,
from drivers/gpu/drm/i915/intel_device_info.c:25:
./include/linux/compiler.h:328:5: error: this statement may fall through [-Werror=implicit-fallthrough=]
do { \
^./include/linux/compiler.h:338:2: note: in expansion of macro ‘__compiletime_assert’
__compiletime_assert(condition, msg, prefix, suffix) ^~~~~~~~~~~~~~~~~~~~./include/linux/compiler.h:350:2: note: in expansion of macro ‘_compiletime_assert’
_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) ^~~~~~~~~~~~~~~~~~~./include/linux/build_bug.h:39:37: note: in expansion of macro ‘compiletime_assert’
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^~~~~~~~~~~~~~~~~~./include/linux/build_bug.h:50:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) ^~~~~~~~~~~~~~~~drivers/gpu/drm/i915/intel_device_info.c:1045:4: note: in expansion of macro ‘BUILD_BUG_ON’
BUILD_BUG_ON(ARRAY_SIZE(glk_gt1_config)
^~~~~~~~~~~~drivers/gpu/drm/i915/intel_device_info.c:1047:3: note: here
case 2:
^~~~
cc1: all warnings being treated as errorsscripts/Makefile.build:265: recipe for target 'drivers/gpu/drm/i915/intel_device_info.o' failed make[4]: *** [drivers/gpu/drm/i915/intel_device_info.o] Error 1 scripts/Makefile.build:509: recipe for target 'drivers/gpu/drm/i915' failed make[3]: *** [drivers/gpu/drm/i915] Error 2scripts/Makefile.build:509: recipe for target 'drivers/gpu/drm' failed
make[2]: *** [drivers/gpu/drm] Error 2scripts/Makefile.build:509: recipe for target 'drivers/gpu' failed
make[1]: *** [drivers/gpu] Error 2
Makefile:1652: recipe for target 'drivers' failed
make: *** [drivers] Error 2
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx