[Mesa-dev] [PATCH 2/2] i965: Context aware user space EU control through application
From: "Muthukumar, Aravindan" The Patch here is to give control to user/ application to really decide what's the max GPU load it would put. If that can be known in advance, rpcs can be programmed accordingly. This solution has changes across i915, drm and mesa (not limited only to kernel). Here, we pass gpu_load_type = {high, medium, low} from application while context is created. Default here is 'High' and applications roughly know if they are going to eat up entire GPU. The typical usecase of 'Low' is idle screen or minor mouse movements. Users can read meaning of high/medium/low for their platform & then program contexts accordingly. Here gpu_load_type directly translates to number of shader cores/EUs a particular GPU has. Signed-off-by: Aravindan Muthukumar Signed-off-by: Kedar J Karanje Signed-off-by: Praveen Diwakar Signed-off-by: Yogesh Marathe --- include/drm-uapi/i915_drm.h | 8 src/mesa/drivers/dri/i965/brw_bufmgr.c | 19 +++ src/mesa/drivers/dri/i965/brw_bufmgr.h | 4 src/mesa/drivers/dri/i965/brw_context.c | 8 +++- 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/include/drm-uapi/i915_drm.h b/include/drm-uapi/i915_drm.h index 16e452a..f07c55a 100644 --- a/include/drm-uapi/i915_drm.h +++ b/include/drm-uapi/i915_drm.h @@ -319,6 +319,7 @@ typedef struct _drm_i915_sarea { #define DRM_I915_PERF_ADD_CONFIG 0x37 #define DRM_I915_PERF_REMOVE_CONFIG0x38 #define DRM_I915_QUERY 0x39 +#define DRM_I915_LOAD_TYPE 0x3d #define DRM_IOCTL_I915_INITDRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) @@ -377,6 +378,7 @@ typedef struct _drm_i915_sarea { #define DRM_IOCTL_I915_PERF_ADD_CONFIG DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_ADD_CONFIG, struct drm_i915_perf_oa_config) #define DRM_IOCTL_I915_PERF_REMOVE_CONFIG DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_REMOVE_CONFIG, __u64) #define DRM_IOCTL_I915_QUERY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_QUERY, struct drm_i915_query) +#define DRM_IOCTL_I915_LOAD_TYPEDRM_IOWR (DRM_COMMAND_BASE + DRM_I915_LOAD_TYPE, struct drm_i915_load_type) /* Allow drivers to submit batchbuffers directly to hardware, relying * on the security mechanisms provided by hardware. @@ -1387,6 +1389,12 @@ struct drm_i915_gem_context_create { __u32 pad; }; +/* Dynamic Eu control */ +struct drm_i915_load_type { + __u32 ctx_id; + __u32 load_type; +}; + struct drm_i915_gem_context_destroy { __u32 ctx_id; __u32 pad; diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c b/src/mesa/drivers/dri/i965/brw_bufmgr.c index 8ba915b..ac74dfd 100644 --- a/src/mesa/drivers/dri/i965/brw_bufmgr.c +++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c @@ -1332,6 +1332,25 @@ brw_create_hw_context(struct brw_bufmgr *bufmgr) return create.ctx_id; } +/* DYNAMIC EU CONTROL */ +int +brw_hw_context_load_type(struct brw_bufmgr *bufmgr, +uint32_t ctx_id, +int load_type) +{ + struct drm_i915_load_type type = { + .ctx_id = ctx_id, + .load_type = load_type, + }; + int err; + + err = 0; + if(drmIoctl(bufmgr->fd, DRM_IOCTL_I915_LOAD_TYPE, &type)) + err = -errno; + + return err; +} + int brw_hw_context_set_priority(struct brw_bufmgr *bufmgr, uint32_t ctx_id, diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.h b/src/mesa/drivers/dri/i965/brw_bufmgr.h index 68f5e0c..9e9419b 100644 --- a/src/mesa/drivers/dri/i965/brw_bufmgr.h +++ b/src/mesa/drivers/dri/i965/brw_bufmgr.h @@ -313,6 +313,10 @@ int brw_bo_wait(struct brw_bo *bo, int64_t timeout_ns); uint32_t brw_create_hw_context(struct brw_bufmgr *bufmgr); +int brw_hw_context_load_type(struct brw_bufmgr *bufmgr, + uint32_t ctx_id, + int load_type); + int brw_hw_context_set_priority(struct brw_bufmgr *bufmgr, uint32_t ctx_id, int priority); diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 01a3e16..2ef21b6 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -888,7 +888,8 @@ brwCreateContext(gl_api api, if (ctx_config->attribute_mask & ~(__DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY | - __DRIVER_CONTEXT_ATTRIB_PRIORITY)) { + __DRIVER_CONTEXT_ATTRIB_PRIORITY | + __DRIVER_CONTEXT_ATTRIB_LOAD_TYPE)) { *dri_ctx_error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE; return false; } @@ -1005,6 +1006,11 @@ brwCreateContext(gl_api api, return false; } + if(ctx_config->attribute_mask & __DRIVER_CONTEXT_ATTRIB_LOAD_TYPE) { + brw_hw_contex
Re: [Mesa-dev] [PATCH 2/2] i965: Context aware user space EU control through application
Quoting aravindan.muthuku...@intel.com (2018-07-20 09:32:57) > From: "Muthukumar, Aravindan" > > The Patch here is to give control to user/ application to really > decide what's the max GPU load it would put. If that can be > known in advance, rpcs can be programmed accordingly. > This solution has changes across i915, > drm and mesa (not limited only to kernel). > > Here, we pass gpu_load_type = {high, medium, low} from application > while context is created. Default here is 'High' and applications > roughly know if they are going to eat up entire GPU. The typical > usecase of 'Low' is idle screen or minor mouse movements. Users can > read meaning of high/medium/low for their platform & then program > contexts accordingly. Here gpu_load_type directly translates to > number of shader cores/EUs a particular GPU has. > > Signed-off-by: Aravindan Muthukumar > Signed-off-by: Kedar J Karanje > Signed-off-by: Praveen Diwakar > Signed-off-by: Yogesh Marathe > +/* Dynamic Eu control */ > +struct drm_i915_load_type { > + __u32 ctx_id; > + __u32 load_type; > +}; > + > +/* DYNAMIC EU CONTROL */ > +int > +brw_hw_context_load_type(struct brw_bufmgr *bufmgr, > +uint32_t ctx_id, > +int load_type) > +{ > + struct drm_i915_load_type type = { > + .ctx_id = ctx_id, > + .load_type = load_type, > + }; > + int err; > + > + err = 0; > + if(drmIoctl(bufmgr->fd, DRM_IOCTL_I915_LOAD_TYPE, &type)) > + err = -errno; This went through 4 people and none noticed that there already exists a means to set per-context parameters. And it's even used right next to this function. The word hint needs to be firmly embedded around here. -Chris ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] i965: Context aware user space EU control through application
On 20/07/18 09:47, Chris Wilson wrote: Quoting aravindan.muthuku...@intel.com (2018-07-20 09:32:57) From: "Muthukumar, Aravindan" The Patch here is to give control to user/ application to really decide what's the max GPU load it would put. If that can be known in advance, rpcs can be programmed accordingly. This solution has changes across i915, drm and mesa (not limited only to kernel). Here, we pass gpu_load_type = {high, medium, low} from application while context is created. Default here is 'High' and applications roughly know if they are going to eat up entire GPU. The typical usecase of 'Low' is idle screen or minor mouse movements. Users can read meaning of high/medium/low for their platform & then program contexts accordingly. Here gpu_load_type directly translates to number of shader cores/EUs a particular GPU has. Signed-off-by: Aravindan Muthukumar Signed-off-by: Kedar J Karanje Signed-off-by: Praveen Diwakar Signed-off-by: Yogesh Marathe +/* Dynamic Eu control */ +struct drm_i915_load_type { + __u32 ctx_id; + __u32 load_type; +}; + +/* DYNAMIC EU CONTROL */ +int +brw_hw_context_load_type(struct brw_bufmgr *bufmgr, +uint32_t ctx_id, +int load_type) +{ + struct drm_i915_load_type type = { + .ctx_id = ctx_id, + .load_type = load_type, + }; + int err; + + err = 0; + if(drmIoctl(bufmgr->fd, DRM_IOCTL_I915_LOAD_TYPE, &type)) + err = -errno; This went through 4 people and none noticed that there already exists a means to set per-context parameters. And it's even used right next to this function. The word hint needs to be firmly embedded around here. -Chris __ Yep, Looks like you want to get involved in this discussion : https://patchwork.freedesktop.org/series/42285/ - Lionel ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] i965: Context aware user space EU control through application
> -Original Message- > From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On > Behalf Of Lionel Landwerlin > Sent: Friday, July 20, 2018 3:31 PM > To: Chris Wilson ; Muthukumar, Aravindan > ; mesa-dev@lists.freedesktop.org > Subject: Re: [Mesa-dev] [PATCH 2/2] i965: Context aware user space EU > control through application > > On 20/07/18 09:47, Chris Wilson wrote: > > Quoting aravindan.muthuku...@intel.com (2018-07-20 09:32:57) > >> From: "Muthukumar, Aravindan" > >> > >> The Patch here is to give control to user/ application to really > >> decide what's the max GPU load it would put. If that can be > >> known in advance, rpcs can be programmed accordingly. > >> This solution has changes across i915, > >> drm and mesa (not limited only to kernel). > >> > >> Here, we pass gpu_load_type = {high, medium, low} from application > >> while context is created. Default here is 'High' and applications > >> roughly know if they are going to eat up entire GPU. The typical > >> usecase of 'Low' is idle screen or minor mouse movements. Users can > >> read meaning of high/medium/low for their platform & then program > >> contexts accordingly. Here gpu_load_type directly translates to > >> number of shader cores/EUs a particular GPU has. > >> > >> Signed-off-by: Aravindan Muthukumar > > >> Signed-off-by: Kedar J Karanje > >> Signed-off-by: Praveen Diwakar > >> Signed-off-by: Yogesh Marathe > >> +/* Dynamic Eu control */ > >> +struct drm_i915_load_type { > >> + __u32 ctx_id; > >> + __u32 load_type; > >> +}; > >> + > >> +/* DYNAMIC EU CONTROL */ > >> +int > >> +brw_hw_context_load_type(struct brw_bufmgr *bufmgr, > >> +uint32_t ctx_id, > >> +int load_type) { > >> + struct drm_i915_load_type type = { > >> + .ctx_id = ctx_id, > >> + .load_type = load_type, > >> + }; > >> + int err; > >> + > >> + err = 0; > >> + if(drmIoctl(bufmgr->fd, DRM_IOCTL_I915_LOAD_TYPE, &type)) > >> + err = -errno; > > This went through 4 people and none noticed that there already exists > > a means to set per-context parameters. And it's even used right next > > to this function. We are aware of " DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM" , however the current RFC is an initial plan, we have further plans to enable access to application for the ability to configure sub-architecture level control (GPU) (hence the new ioctl), however we will consider SETPARAM/GETPARAM for our initial plan now, and move to new ioctl when we have considered all the enhancements that it would bring, thank you for the comments. > > > > The word hint needs to be firmly embedded around here. > > -Chris > > __ > > Yep, > > Looks like you want to get involved in this discussion : > https://patchwork.freedesktop.org/series/42285/ Could you please let us know how we can be involved in this ? > > - > Lionel > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] i965: Context aware user space EU control through application
Lionel, Chris, > -Original Message- > From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On Behalf > Of Lionel Landwerlin > Sent: Friday, July 20, 2018 3:31 PM > To: Chris Wilson ; Muthukumar, Aravindan > ; mesa-dev@lists.freedesktop.org > Subject: Re: [Mesa-dev] [PATCH 2/2] i965: Context aware user space EU control > through application > > On 20/07/18 09:47, Chris Wilson wrote: > > Quoting aravindan.muthuku...@intel.com (2018-07-20 09:32:57) > >> From: "Muthukumar, Aravindan" > >> > >> The Patch here is to give control to user/ application to really > >> decide what's the max GPU load it would put. If that can be > >> known in advance, rpcs can be programmed accordingly. > >> This solution has changes across i915, > >> drm and mesa (not limited only to kernel). > >> > >> Here, we pass gpu_load_type = {high, medium, low} from application > >> while context is created. Default here is 'High' and applications > >> roughly know if they are going to eat up entire GPU. The typical > >> usecase of 'Low' is idle screen or minor mouse movements. Users can > >> read meaning of high/medium/low for their platform & then program > >> contexts accordingly. Here gpu_load_type directly translates to > >> number of shader cores/EUs a particular GPU has. > >> > >> Signed-off-by: Aravindan Muthukumar > >> Signed-off-by: Kedar J Karanje > >> Signed-off-by: Praveen Diwakar > >> Signed-off-by: Yogesh Marathe > >> +/* Dynamic Eu control */ > >> +struct drm_i915_load_type { > >> + __u32 ctx_id; > >> + __u32 load_type; > >> +}; > >> + > >> +/* DYNAMIC EU CONTROL */ > >> +int > >> +brw_hw_context_load_type(struct brw_bufmgr *bufmgr, > >> +uint32_t ctx_id, > >> +int load_type) { > >> + struct drm_i915_load_type type = { > >> + .ctx_id = ctx_id, > >> + .load_type = load_type, > >> + }; > >> + int err; > >> + > >> + err = 0; > >> + if(drmIoctl(bufmgr->fd, DRM_IOCTL_I915_LOAD_TYPE, &type)) > >> + err = -errno; > > This went through 4 people and none noticed that there already exists > > a means to set per-context parameters. And it's even used right next > > to this function. > > > > The word hint needs to be firmly embedded around here. > > -Chris > > __ > > Yep, > > Looks like you want to get involved in this discussion : > https://patchwork.freedesktop.org/series/42285/ I understand this is exposing per context eu config through debugfs. That mostly (if not fully) matches the kernel part of what we wanted to achieve. We have additional code in kernel where we categorize based on load type and fix a config per platform. For sure the kernel parts can be merged but the proposal is different here and its specific to adding this capability through mesa. Here we are enabling applications to decide load while creating the context and making it simple for application programmers by abstracting it. Also in these kernel patches, its seems to be exposing the parameters to user space, are we discussing its user space counterpart in mesa or in some other component? If not, I feel this is bit different. Can it be a mesa extension? Then any app / process can do this without having privilege (root). > > - > Lionel > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] i965: Context aware user space EU control through application
On 24/07/18 17:41, Marathe, Yogesh wrote: Lionel, Chris, -Original Message- From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On Behalf Of Lionel Landwerlin Sent: Friday, July 20, 2018 3:31 PM To: Chris Wilson ; Muthukumar, Aravindan ; mesa-dev@lists.freedesktop.org Subject: Re: [Mesa-dev] [PATCH 2/2] i965: Context aware user space EU control through application On 20/07/18 09:47, Chris Wilson wrote: Quoting aravindan.muthuku...@intel.com (2018-07-20 09:32:57) From: "Muthukumar, Aravindan" The Patch here is to give control to user/ application to really decide what's the max GPU load it would put. If that can be known in advance, rpcs can be programmed accordingly. This solution has changes across i915, drm and mesa (not limited only to kernel). Here, we pass gpu_load_type = {high, medium, low} from application while context is created. Default here is 'High' and applications roughly know if they are going to eat up entire GPU. The typical usecase of 'Low' is idle screen or minor mouse movements. Users can read meaning of high/medium/low for their platform & then program contexts accordingly. Here gpu_load_type directly translates to number of shader cores/EUs a particular GPU has. Signed-off-by: Aravindan Muthukumar Signed-off-by: Kedar J Karanje Signed-off-by: Praveen Diwakar Signed-off-by: Yogesh Marathe +/* Dynamic Eu control */ +struct drm_i915_load_type { + __u32 ctx_id; + __u32 load_type; +}; + +/* DYNAMIC EU CONTROL */ +int +brw_hw_context_load_type(struct brw_bufmgr *bufmgr, +uint32_t ctx_id, +int load_type) { + struct drm_i915_load_type type = { + .ctx_id = ctx_id, + .load_type = load_type, + }; + int err; + + err = 0; + if(drmIoctl(bufmgr->fd, DRM_IOCTL_I915_LOAD_TYPE, &type)) + err = -errno; This went through 4 people and none noticed that there already exists a means to set per-context parameters. And it's even used right next to this function. The word hint needs to be firmly embedded around here. -Chris __ Yep, Looks like you want to get involved in this discussion : https://patchwork.freedesktop.org/series/42285/ I understand this is exposing per context eu config through debugfs. That mostly (if not fully) matches the kernel part of what we wanted to achieve. We have additional code in kernel where we categorize based on load type and fix a config per platform. For sure the kernel parts can be merged but the proposal is different here and its specific to adding this capability through mesa. Here we are enabling applications to decide load while creating the context and making it simple for application programmers by abstracting it. Also in these kernel patches, its seems to be exposing the parameters to user space, are we discussing its user space counterpart in mesa or in some other component? If not, I feel this is bit different. Can it be a mesa extension? Then any app / process can do this without having privilege (root). Yes, I was just pointing out that you might want to reuse existing patches for i915 so that we don't end up with 2 similar interfaces there. Obviously your extension would still be needed. - Lionel - Lionel ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] i965: Context aware user space EU control through application
> -Original Message- > From: Landwerlin, Lionel G > Sent: Tuesday, July 24, 2018 10:24 PM > To: Marathe, Yogesh ; Chris Wilson wilson.co.uk>; Muthukumar, Aravindan ; > mesa-dev@lists.freedesktop.org > Cc: Diwakar, Praveen > Subject: Re: [Mesa-dev] [PATCH 2/2] i965: Context aware user space EU control > through application > > On 24/07/18 17:41, Marathe, Yogesh wrote: > > Lionel, Chris, > > > >> -Original Message- > >> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On > >> Behalf Of Lionel Landwerlin > >> Sent: Friday, July 20, 2018 3:31 PM > >> To: Chris Wilson ; Muthukumar, Aravindan > >> ; mesa-dev@lists.freedesktop.org > >> Subject: Re: [Mesa-dev] [PATCH 2/2] i965: Context aware user space EU > >> control through application > >> > >> On 20/07/18 09:47, Chris Wilson wrote: > >>> Quoting aravindan.muthuku...@intel.com (2018-07-20 09:32:57) > >>>> From: "Muthukumar, Aravindan" > >>>> > >>>>The Patch here is to give control to user/ application to really > >>>>decide what's the max GPU load it would put. If that can be > >>>>known in advance, rpcs can be programmed accordingly. > >>>>This solution has changes across i915, > >>>>drm and mesa (not limited only to kernel). > >>>> > >>>>Here, we pass gpu_load_type = {high, medium, low} from application > >>>>while context is created. Default here is 'High' and applications > >>>>roughly know if they are going to eat up entire GPU. The typical > >>>>usecase of 'Low' is idle screen or minor mouse movements. Users can > >>>>read meaning of high/medium/low for their platform & then program > >>>>contexts accordingly. Here gpu_load_type directly translates to > >>>>number of shader cores/EUs a particular GPU has. > >>>> > >>>>Signed-off-by: Aravindan Muthukumar > > >>>>Signed-off-by: Kedar J Karanje > >>>>Signed-off-by: Praveen Diwakar > >>>>Signed-off-by: Yogesh Marathe > >>>> +/* Dynamic Eu control */ > >>>> +struct drm_i915_load_type { > >>>> + __u32 ctx_id; > >>>> + __u32 load_type; > >>>> +}; > >>>> + > >>>> +/* DYNAMIC EU CONTROL */ > >>>> +int > >>>> +brw_hw_context_load_type(struct brw_bufmgr *bufmgr, > >>>> +uint32_t ctx_id, > >>>> +int load_type) { > >>>> + struct drm_i915_load_type type = { > >>>> + .ctx_id = ctx_id, > >>>> + .load_type = load_type, > >>>> + }; > >>>> + int err; > >>>> + > >>>> + err = 0; > >>>> + if(drmIoctl(bufmgr->fd, DRM_IOCTL_I915_LOAD_TYPE, &type)) > >>>> + err = -errno; > >>> This went through 4 people and none noticed that there already > >>> exists a means to set per-context parameters. And it's even used > >>> right next to this function. > >>> > >>> The word hint needs to be firmly embedded around here. > >>> -Chris > >>> __ > >> Yep, > >> > >> Looks like you want to get involved in this discussion : > >> https://patchwork.freedesktop.org/series/42285/ > > I understand this is exposing per context eu config through debugfs. > > That mostly (if not fully) matches the kernel part of what we wanted > > to achieve. We have additional code in kernel where we categorize > > based on load type and fix a config per platform. For sure the kernel > > parts can be merged but the proposal is different here and its specific to > adding this capability through mesa. > > > > Here we are enabling applications to decide load while creating the > > context and making it simple for application programmers by > > abstracting it. Also in these kernel patches, its seems to be > > exposing the parameters to user space, are we discussing its user > > space counterpart in mesa or in some other component? If not, I feel > > this is bit different. Can it be a mesa extension? Then any app / process > > can do > this without having privilege (root). > > Yes, I was just pointing out that you might want to reuse existing patches for > i915 so that we don't end up with 2 similar interfaces there. > Obviously your extension would still be needed. > Thanks, that’s clear now. > - > Lionel > > > > >> - > >> Lionel > >> ___ > >> mesa-dev mailing list > >> mesa-dev@lists.freedesktop.org > >> https://lists.freedesktop.org/mailman/listinfo/mesa-dev > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev