diff mbox

[i-g-t,4/7] tests/gem_mmap_gtt: Make the small-bo tiling tests work on old platforms

Message ID 1450124156-12679-4-git-send-email-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ville Syrjala Dec. 14, 2015, 8:15 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Several factors conspire against us when trying to execute
the tiled small-bo tests:
- pre-gen4 require power of two fences, with natural alignment
- the entire gtt may be mappable
- we put a guard page at the end of gtt

What all that means is that when we try to use a tiled object half
the size of the mappable area, we can only fit it in the first half
of the gtt. That leads to a SIGBUS when we try to fault in the
object when there's already something (eg. fbdev) occupying the
first half of gtt.

So in order to make the tests run on old machines, let's further
halve the object size when things look too tight.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tests/gem_mmap_gtt.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Chris Wilson Dec. 14, 2015, 8:49 p.m. UTC | #1
On Mon, Dec 14, 2015 at 10:15:53PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Several factors conspire against us when trying to execute
> the tiled small-bo tests:
> - pre-gen4 require power of two fences, with natural alignment
> - the entire gtt may be mappable
> - we put a guard page at the end of gtt
> 
> What all that means is that when we try to use a tiled object half
> the size of the mappable area, we can only fit it in the first half
> of the gtt. That leads to a SIGBUS when we try to fault in the
> object when there's already something (eg. fbdev) occupying the
> first half of gtt.
> 
> So in order to make the tests run on old machines, let's further
> halve the object size when things look too tight.

That defeats the point of the test. The idea is to have the two objects
that just don't fit, but only just.
-Chris
Chris Wilson Dec. 14, 2015, 8:54 p.m. UTC | #2
On Mon, Dec 14, 2015 at 08:49:38PM +0000, Chris Wilson wrote:
> On Mon, Dec 14, 2015 at 10:15:53PM +0200, ville.syrjala@linux.intel.com wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Several factors conspire against us when trying to execute
> > the tiled small-bo tests:
> > - pre-gen4 require power of two fences, with natural alignment
> > - the entire gtt may be mappable
> > - we put a guard page at the end of gtt
> > 
> > What all that means is that when we try to use a tiled object half
> > the size of the mappable area, we can only fit it in the first half
> > of the gtt. That leads to a SIGBUS when we try to fault in the
> > object when there's already something (eg. fbdev) occupying the
> > first half of gtt.
> > 
> > So in order to make the tests run on old machines, let's further
> > halve the object size when things look too tight.
> 
> That defeats the point of the test. The idea is to have the two objects
> that just don't fit, but only just.

i.e. the test is meant to show that the kernel heuristics for using
partial vma do not prevent the page-fault-of-doom.
-Chris
Ville Syrjala Dec. 15, 2015, 9:41 a.m. UTC | #3
On Mon, Dec 14, 2015 at 08:54:35PM +0000, Chris Wilson wrote:
> On Mon, Dec 14, 2015 at 08:49:38PM +0000, Chris Wilson wrote:
> > On Mon, Dec 14, 2015 at 10:15:53PM +0200, ville.syrjala@linux.intel.com wrote:
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > 
> > > Several factors conspire against us when trying to execute
> > > the tiled small-bo tests:
> > > - pre-gen4 require power of two fences, with natural alignment
> > > - the entire gtt may be mappable
> > > - we put a guard page at the end of gtt
> > > 
> > > What all that means is that when we try to use a tiled object half
> > > the size of the mappable area, we can only fit it in the first half
> > > of the gtt. That leads to a SIGBUS when we try to fault in the
> > > object when there's already something (eg. fbdev) occupying the
> > > first half of gtt.
> > > 
> > > So in order to make the tests run on old machines, let's further
> > > halve the object size when things look too tight.
> > 
> > That defeats the point of the test. The idea is to have the two objects
> > that just don't fit, but only just.
> 
> i.e. the test is meant to show that the kernel heuristics for using
> partial vma do not prevent the page-fault-of-doom.

So just skip then?
Chris Wilson Dec. 15, 2015, 9:57 a.m. UTC | #4
On Tue, Dec 15, 2015 at 11:41:44AM +0200, Ville Syrjälä wrote:
> On Mon, Dec 14, 2015 at 08:54:35PM +0000, Chris Wilson wrote:
> > On Mon, Dec 14, 2015 at 08:49:38PM +0000, Chris Wilson wrote:
> > > On Mon, Dec 14, 2015 at 10:15:53PM +0200, ville.syrjala@linux.intel.com wrote:
> > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > 
> > > > Several factors conspire against us when trying to execute
> > > > the tiled small-bo tests:
> > > > - pre-gen4 require power of two fences, with natural alignment
> > > > - the entire gtt may be mappable
> > > > - we put a guard page at the end of gtt
> > > > 
> > > > What all that means is that when we try to use a tiled object half
> > > > the size of the mappable area, we can only fit it in the first half
> > > > of the gtt. That leads to a SIGBUS when we try to fault in the
> > > > object when there's already something (eg. fbdev) occupying the
> > > > first half of gtt.
> > > > 
> > > > So in order to make the tests run on old machines, let's further
> > > > halve the object size when things look too tight.
> > > 
> > > That defeats the point of the test. The idea is to have the two objects
> > > that just don't fit, but only just.
> > 
> > i.e. the test is meant to show that the kernel heuristics for using
> > partial vma do not prevent the page-fault-of-doom.
> 
> So just skip then?

The kernel has a bug that partial vma was supposed to address. In theory
it can strike at any time (although userspace has a similar approach to
try and not tempt fate). And other than a getparm "bug fixed", there
won't be an ABI change for userspace to take note of.

I have ~237 patches ahead of my "make partial-vma actually work" fix. :|
-Chris
Ville Syrjala Dec. 15, 2015, 10:57 a.m. UTC | #5
On Tue, Dec 15, 2015 at 09:57:22AM +0000, Chris Wilson wrote:
> On Tue, Dec 15, 2015 at 11:41:44AM +0200, Ville Syrjälä wrote:
> > On Mon, Dec 14, 2015 at 08:54:35PM +0000, Chris Wilson wrote:
> > > On Mon, Dec 14, 2015 at 08:49:38PM +0000, Chris Wilson wrote:
> > > > On Mon, Dec 14, 2015 at 10:15:53PM +0200, ville.syrjala@linux.intel.com wrote:
> > > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > 
> > > > > Several factors conspire against us when trying to execute
> > > > > the tiled small-bo tests:
> > > > > - pre-gen4 require power of two fences, with natural alignment
> > > > > - the entire gtt may be mappable
> > > > > - we put a guard page at the end of gtt
> > > > > 
> > > > > What all that means is that when we try to use a tiled object half
> > > > > the size of the mappable area, we can only fit it in the first half
> > > > > of the gtt. That leads to a SIGBUS when we try to fault in the
> > > > > object when there's already something (eg. fbdev) occupying the
> > > > > first half of gtt.
> > > > > 
> > > > > So in order to make the tests run on old machines, let's further
> > > > > halve the object size when things look too tight.
> > > > 
> > > > That defeats the point of the test. The idea is to have the two objects
> > > > that just don't fit, but only just.
> > > 
> > > i.e. the test is meant to show that the kernel heuristics for using
> > > partial vma do not prevent the page-fault-of-doom.
> > 
> > So just skip then?
> 
> The kernel has a bug that partial vma was supposed to address.

I'm not sure partial vma has any benefit in this case. Sure, you could
them mmap the thing but unless we teach the GPU to also use partial
mappings it won't do any good since we just can't fit the thing into
the gtt.

> In theory
> it can strike at any time (although userspace has a similar approach to
> try and not tempt fate). And other than a getparm "bug fixed", there
> won't be an ABI change for userspace to take note of.
> 
> I have ~237 patches ahead of my "make partial-vma actually work" fix. :|
> -Chris
> 
> -- 
> Chris Wilson, Intel Open Source Technology Centre
Chris Wilson Dec. 15, 2015, 11:16 a.m. UTC | #6
On Tue, Dec 15, 2015 at 12:57:15PM +0200, Ville Syrjälä wrote:
> On Tue, Dec 15, 2015 at 09:57:22AM +0000, Chris Wilson wrote:
> > On Tue, Dec 15, 2015 at 11:41:44AM +0200, Ville Syrjälä wrote:
> > > On Mon, Dec 14, 2015 at 08:54:35PM +0000, Chris Wilson wrote:
> > > > On Mon, Dec 14, 2015 at 08:49:38PM +0000, Chris Wilson wrote:
> > > > > On Mon, Dec 14, 2015 at 10:15:53PM +0200, ville.syrjala@linux.intel.com wrote:
> > > > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > > 
> > > > > > Several factors conspire against us when trying to execute
> > > > > > the tiled small-bo tests:
> > > > > > - pre-gen4 require power of two fences, with natural alignment
> > > > > > - the entire gtt may be mappable
> > > > > > - we put a guard page at the end of gtt
> > > > > > 
> > > > > > What all that means is that when we try to use a tiled object half
> > > > > > the size of the mappable area, we can only fit it in the first half
> > > > > > of the gtt. That leads to a SIGBUS when we try to fault in the
> > > > > > object when there's already something (eg. fbdev) occupying the
> > > > > > first half of gtt.
> > > > > > 
> > > > > > So in order to make the tests run on old machines, let's further
> > > > > > halve the object size when things look too tight.
> > > > > 
> > > > > That defeats the point of the test. The idea is to have the two objects
> > > > > that just don't fit, but only just.
> > > > 
> > > > i.e. the test is meant to show that the kernel heuristics for using
> > > > partial vma do not prevent the page-fault-of-doom.
> > > 
> > > So just skip then?
> > 
> > The kernel has a bug that partial vma was supposed to address.
> 
> I'm not sure partial vma has any benefit in this case. Sure, you could
> them mmap the thing but unless we teach the GPU to also use partial
> mappings it won't do any good since we just can't fit the thing into
> the gtt.

For gen2, not being able to fit into mappable is an issue for the GPU as
well, sure. But for userspace being oblivious and *always* being able to
use mmaping of a bo, it is a big deal. (Being oblivious helps with
robustness in the stack, X/display-server-de-jour should not die just
because of a resource conflict - now X should catch the fault and handle
it, give or take bugs, avoiding that error path entirely is even better.)

Using "sparse" resources so that we can arbitrary sized objects is
something I'd like. But we have so much "whole-object-at-once" baked
into the code, it will be a challenge.
-Chris
Ville Syrjala Dec. 15, 2015, 11:29 a.m. UTC | #7
On Tue, Dec 15, 2015 at 11:16:52AM +0000, Chris Wilson wrote:
> On Tue, Dec 15, 2015 at 12:57:15PM +0200, Ville Syrjälä wrote:
> > On Tue, Dec 15, 2015 at 09:57:22AM +0000, Chris Wilson wrote:
> > > On Tue, Dec 15, 2015 at 11:41:44AM +0200, Ville Syrjälä wrote:
> > > > On Mon, Dec 14, 2015 at 08:54:35PM +0000, Chris Wilson wrote:
> > > > > On Mon, Dec 14, 2015 at 08:49:38PM +0000, Chris Wilson wrote:
> > > > > > On Mon, Dec 14, 2015 at 10:15:53PM +0200, ville.syrjala@linux.intel.com wrote:
> > > > > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > > > 
> > > > > > > Several factors conspire against us when trying to execute
> > > > > > > the tiled small-bo tests:
> > > > > > > - pre-gen4 require power of two fences, with natural alignment
> > > > > > > - the entire gtt may be mappable
> > > > > > > - we put a guard page at the end of gtt
> > > > > > > 
> > > > > > > What all that means is that when we try to use a tiled object half
> > > > > > > the size of the mappable area, we can only fit it in the first half
> > > > > > > of the gtt. That leads to a SIGBUS when we try to fault in the
> > > > > > > object when there's already something (eg. fbdev) occupying the
> > > > > > > first half of gtt.
> > > > > > > 
> > > > > > > So in order to make the tests run on old machines, let's further
> > > > > > > halve the object size when things look too tight.
> > > > > > 
> > > > > > That defeats the point of the test. The idea is to have the two objects
> > > > > > that just don't fit, but only just.
> > > > > 
> > > > > i.e. the test is meant to show that the kernel heuristics for using
> > > > > partial vma do not prevent the page-fault-of-doom.
> > > > 
> > > > So just skip then?
> > > 
> > > The kernel has a bug that partial vma was supposed to address.
> > 
> > I'm not sure partial vma has any benefit in this case. Sure, you could
> > them mmap the thing but unless we teach the GPU to also use partial
> > mappings it won't do any good since we just can't fit the thing into
> > the gtt.
> 
> For gen2, not being able to fit into mappable is an issue for the GPU as
> well, sure. But for userspace being oblivious and *always* being able to
> use mmaping of a bo, it is a big deal. (Being oblivious helps with
> robustness in the stack, X/display-server-de-jour should not die just
> because of a resource conflict - now X should catch the fault and handle
> it, give or take bugs, avoiding that error path entirely is even better.)

Yeah, I suppose it would be nice not to SIGBUS even if userspace is
trying something a bit crazy. It would just get an error later from
execbuf when trying to use the bo with the GPU. So I guess the right
fix would be to fall back to partial vma if we fail to bind the full
vma.

> 
> Using "sparse" resources so that we can arbitrary sized objects is
> something I'd like. But we have so much "whole-object-at-once" baked
> into the code, it will be a challenge.
> -Chris
> 
> -- 
> Chris Wilson, Intel Open Source Technology Centre
Ville Syrjala Dec. 15, 2015, 12:01 p.m. UTC | #8
On Tue, Dec 15, 2015 at 01:29:59PM +0200, Ville Syrjälä wrote:
> On Tue, Dec 15, 2015 at 11:16:52AM +0000, Chris Wilson wrote:
> > On Tue, Dec 15, 2015 at 12:57:15PM +0200, Ville Syrjälä wrote:
> > > On Tue, Dec 15, 2015 at 09:57:22AM +0000, Chris Wilson wrote:
> > > > On Tue, Dec 15, 2015 at 11:41:44AM +0200, Ville Syrjälä wrote:
> > > > > On Mon, Dec 14, 2015 at 08:54:35PM +0000, Chris Wilson wrote:
> > > > > > On Mon, Dec 14, 2015 at 08:49:38PM +0000, Chris Wilson wrote:
> > > > > > > On Mon, Dec 14, 2015 at 10:15:53PM +0200, ville.syrjala@linux.intel.com wrote:
> > > > > > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > > > > 
> > > > > > > > Several factors conspire against us when trying to execute
> > > > > > > > the tiled small-bo tests:
> > > > > > > > - pre-gen4 require power of two fences, with natural alignment
> > > > > > > > - the entire gtt may be mappable
> > > > > > > > - we put a guard page at the end of gtt
> > > > > > > > 
> > > > > > > > What all that means is that when we try to use a tiled object half
> > > > > > > > the size of the mappable area, we can only fit it in the first half
> > > > > > > > of the gtt. That leads to a SIGBUS when we try to fault in the
> > > > > > > > object when there's already something (eg. fbdev) occupying the
> > > > > > > > first half of gtt.
> > > > > > > > 
> > > > > > > > So in order to make the tests run on old machines, let's further
> > > > > > > > halve the object size when things look too tight.
> > > > > > > 
> > > > > > > That defeats the point of the test. The idea is to have the two objects
> > > > > > > that just don't fit, but only just.
> > > > > > 
> > > > > > i.e. the test is meant to show that the kernel heuristics for using
> > > > > > partial vma do not prevent the page-fault-of-doom.
> > > > > 
> > > > > So just skip then?
> > > > 
> > > > The kernel has a bug that partial vma was supposed to address.
> > > 
> > > I'm not sure partial vma has any benefit in this case. Sure, you could
> > > them mmap the thing but unless we teach the GPU to also use partial
> > > mappings it won't do any good since we just can't fit the thing into
> > > the gtt.
> > 
> > For gen2, not being able to fit into mappable is an issue for the GPU as
> > well, sure. But for userspace being oblivious and *always* being able to
> > use mmaping of a bo, it is a big deal. (Being oblivious helps with
> > robustness in the stack, X/display-server-de-jour should not die just
> > because of a resource conflict - now X should catch the fault and handle
> > it, give or take bugs, avoiding that error path entirely is even better.)
> 
> Yeah, I suppose it would be nice not to SIGBUS even if userspace is
> trying something a bit crazy. It would just get an error later from
> execbuf when trying to use the bo with the GPU. So I guess the right
> fix would be to fall back to partial vma if we fail to bind the full
> vma.

Hmm, actaully no. This was about tiled objects, and we don't do
tiled+partial at all currently. Would need to teach the code to do that
first.

> 
> > 
> > Using "sparse" resources so that we can arbitrary sized objects is
> > something I'd like. But we have so much "whole-object-at-once" baked
> > into the code, it will be a challenge.
> > -Chris
> > 
> > -- 
> > Chris Wilson, Intel Open Source Technology Centre
> 
> -- 
> Ville Syrjälä
> Intel OTC
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Chris Wilson Dec. 15, 2015, 12:30 p.m. UTC | #9
On Tue, Dec 15, 2015 at 02:01:24PM +0200, Ville Syrjälä wrote:
> On Tue, Dec 15, 2015 at 01:29:59PM +0200, Ville Syrjälä wrote:
> > On Tue, Dec 15, 2015 at 11:16:52AM +0000, Chris Wilson wrote:
> > > On Tue, Dec 15, 2015 at 12:57:15PM +0200, Ville Syrjälä wrote:
> > > > On Tue, Dec 15, 2015 at 09:57:22AM +0000, Chris Wilson wrote:
> > > > > On Tue, Dec 15, 2015 at 11:41:44AM +0200, Ville Syrjälä wrote:
> > > > > > On Mon, Dec 14, 2015 at 08:54:35PM +0000, Chris Wilson wrote:
> > > > > > > On Mon, Dec 14, 2015 at 08:49:38PM +0000, Chris Wilson wrote:
> > > > > > > > On Mon, Dec 14, 2015 at 10:15:53PM +0200, ville.syrjala@linux.intel.com wrote:
> > > > > > > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > > > > > 
> > > > > > > > > Several factors conspire against us when trying to execute
> > > > > > > > > the tiled small-bo tests:
> > > > > > > > > - pre-gen4 require power of two fences, with natural alignment
> > > > > > > > > - the entire gtt may be mappable
> > > > > > > > > - we put a guard page at the end of gtt
> > > > > > > > > 
> > > > > > > > > What all that means is that when we try to use a tiled object half
> > > > > > > > > the size of the mappable area, we can only fit it in the first half
> > > > > > > > > of the gtt. That leads to a SIGBUS when we try to fault in the
> > > > > > > > > object when there's already something (eg. fbdev) occupying the
> > > > > > > > > first half of gtt.
> > > > > > > > > 
> > > > > > > > > So in order to make the tests run on old machines, let's further
> > > > > > > > > halve the object size when things look too tight.
> > > > > > > > 
> > > > > > > > That defeats the point of the test. The idea is to have the two objects
> > > > > > > > that just don't fit, but only just.
> > > > > > > 
> > > > > > > i.e. the test is meant to show that the kernel heuristics for using
> > > > > > > partial vma do not prevent the page-fault-of-doom.
> > > > > > 
> > > > > > So just skip then?
> > > > > 
> > > > > The kernel has a bug that partial vma was supposed to address.
> > > > 
> > > > I'm not sure partial vma has any benefit in this case. Sure, you could
> > > > them mmap the thing but unless we teach the GPU to also use partial
> > > > mappings it won't do any good since we just can't fit the thing into
> > > > the gtt.
> > > 
> > > For gen2, not being able to fit into mappable is an issue for the GPU as
> > > well, sure. But for userspace being oblivious and *always* being able to
> > > use mmaping of a bo, it is a big deal. (Being oblivious helps with
> > > robustness in the stack, X/display-server-de-jour should not die just
> > > because of a resource conflict - now X should catch the fault and handle
> > > it, give or take bugs, avoiding that error path entirely is even better.)
> > 
> > Yeah, I suppose it would be nice not to SIGBUS even if userspace is
> > trying something a bit crazy. It would just get an error later from
> > execbuf when trying to use the bo with the GPU. So I guess the right
> > fix would be to fall back to partial vma if we fail to bind the full
> > vma.
> 
> Hmm, actaully no. This was about tiled objects, and we don't do
> tiled+partial at all currently. Would need to teach the code to do that
> first.

It's is one and the same fix ;) (Ok, same patchset!)
-Chris
Daniel Vetter Dec. 16, 2015, 10:46 a.m. UTC | #10
On Tue, Dec 15, 2015 at 12:30:54PM +0000, Chris Wilson wrote:
> On Tue, Dec 15, 2015 at 02:01:24PM +0200, Ville Syrjälä wrote:
> > On Tue, Dec 15, 2015 at 01:29:59PM +0200, Ville Syrjälä wrote:
> > > On Tue, Dec 15, 2015 at 11:16:52AM +0000, Chris Wilson wrote:
> > > > On Tue, Dec 15, 2015 at 12:57:15PM +0200, Ville Syrjälä wrote:
> > > > > On Tue, Dec 15, 2015 at 09:57:22AM +0000, Chris Wilson wrote:
> > > > > > On Tue, Dec 15, 2015 at 11:41:44AM +0200, Ville Syrjälä wrote:
> > > > > > > On Mon, Dec 14, 2015 at 08:54:35PM +0000, Chris Wilson wrote:
> > > > > > > > On Mon, Dec 14, 2015 at 08:49:38PM +0000, Chris Wilson wrote:
> > > > > > > > > On Mon, Dec 14, 2015 at 10:15:53PM +0200, ville.syrjala@linux.intel.com wrote:
> > > > > > > > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > > > > > > 
> > > > > > > > > > Several factors conspire against us when trying to execute
> > > > > > > > > > the tiled small-bo tests:
> > > > > > > > > > - pre-gen4 require power of two fences, with natural alignment
> > > > > > > > > > - the entire gtt may be mappable
> > > > > > > > > > - we put a guard page at the end of gtt
> > > > > > > > > > 
> > > > > > > > > > What all that means is that when we try to use a tiled object half
> > > > > > > > > > the size of the mappable area, we can only fit it in the first half
> > > > > > > > > > of the gtt. That leads to a SIGBUS when we try to fault in the
> > > > > > > > > > object when there's already something (eg. fbdev) occupying the
> > > > > > > > > > first half of gtt.
> > > > > > > > > > 
> > > > > > > > > > So in order to make the tests run on old machines, let's further
> > > > > > > > > > halve the object size when things look too tight.
> > > > > > > > > 
> > > > > > > > > That defeats the point of the test. The idea is to have the two objects
> > > > > > > > > that just don't fit, but only just.
> > > > > > > > 
> > > > > > > > i.e. the test is meant to show that the kernel heuristics for using
> > > > > > > > partial vma do not prevent the page-fault-of-doom.
> > > > > > > 
> > > > > > > So just skip then?
> > > > > > 
> > > > > > The kernel has a bug that partial vma was supposed to address.
> > > > > 
> > > > > I'm not sure partial vma has any benefit in this case. Sure, you could
> > > > > them mmap the thing but unless we teach the GPU to also use partial
> > > > > mappings it won't do any good since we just can't fit the thing into
> > > > > the gtt.
> > > > 
> > > > For gen2, not being able to fit into mappable is an issue for the GPU as
> > > > well, sure. But for userspace being oblivious and *always* being able to
> > > > use mmaping of a bo, it is a big deal. (Being oblivious helps with
> > > > robustness in the stack, X/display-server-de-jour should not die just
> > > > because of a resource conflict - now X should catch the fault and handle
> > > > it, give or take bugs, avoiding that error path entirely is even better.)
> > > 
> > > Yeah, I suppose it would be nice not to SIGBUS even if userspace is
> > > trying something a bit crazy. It would just get an error later from
> > > execbuf when trying to use the bo with the GPU. So I guess the right
> > > fix would be to fall back to partial vma if we fail to bind the full
> > > vma.
> > 
> > Hmm, actaully no. This was about tiled objects, and we don't do
> > tiled+partial at all currently. Would need to teach the code to do that
> > first.
> 
> It's is one and the same fix ;) (Ok, same patchset!)

Yeah the problem is that partial views are stuck half-implemented, and
seem to not move forward.

I'd just skip on gen2/3 tbh.
-Daniel
Chris Wilson Dec. 16, 2015, 11:11 a.m. UTC | #11
On Wed, Dec 16, 2015 at 11:46:50AM +0100, Daniel Vetter wrote:
> On Tue, Dec 15, 2015 at 12:30:54PM +0000, Chris Wilson wrote:
> > On Tue, Dec 15, 2015 at 02:01:24PM +0200, Ville Syrjälä wrote:
> > > On Tue, Dec 15, 2015 at 01:29:59PM +0200, Ville Syrjälä wrote:
> > > > On Tue, Dec 15, 2015 at 11:16:52AM +0000, Chris Wilson wrote:
> > > > > On Tue, Dec 15, 2015 at 12:57:15PM +0200, Ville Syrjälä wrote:
> > > > > > On Tue, Dec 15, 2015 at 09:57:22AM +0000, Chris Wilson wrote:
> > > > > > > On Tue, Dec 15, 2015 at 11:41:44AM +0200, Ville Syrjälä wrote:
> > > > > > > > On Mon, Dec 14, 2015 at 08:54:35PM +0000, Chris Wilson wrote:
> > > > > > > > > On Mon, Dec 14, 2015 at 08:49:38PM +0000, Chris Wilson wrote:
> > > > > > > > > > On Mon, Dec 14, 2015 at 10:15:53PM +0200, ville.syrjala@linux.intel.com wrote:
> > > > > > > > > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > > > > > > > 
> > > > > > > > > > > Several factors conspire against us when trying to execute
> > > > > > > > > > > the tiled small-bo tests:
> > > > > > > > > > > - pre-gen4 require power of two fences, with natural alignment
> > > > > > > > > > > - the entire gtt may be mappable
> > > > > > > > > > > - we put a guard page at the end of gtt
> > > > > > > > > > > 
> > > > > > > > > > > What all that means is that when we try to use a tiled object half
> > > > > > > > > > > the size of the mappable area, we can only fit it in the first half
> > > > > > > > > > > of the gtt. That leads to a SIGBUS when we try to fault in the
> > > > > > > > > > > object when there's already something (eg. fbdev) occupying the
> > > > > > > > > > > first half of gtt.
> > > > > > > > > > > 
> > > > > > > > > > > So in order to make the tests run on old machines, let's further
> > > > > > > > > > > halve the object size when things look too tight.
> > > > > > > > > > 
> > > > > > > > > > That defeats the point of the test. The idea is to have the two objects
> > > > > > > > > > that just don't fit, but only just.
> > > > > > > > > 
> > > > > > > > > i.e. the test is meant to show that the kernel heuristics for using
> > > > > > > > > partial vma do not prevent the page-fault-of-doom.
> > > > > > > > 
> > > > > > > > So just skip then?
> > > > > > > 
> > > > > > > The kernel has a bug that partial vma was supposed to address.
> > > > > > 
> > > > > > I'm not sure partial vma has any benefit in this case. Sure, you could
> > > > > > them mmap the thing but unless we teach the GPU to also use partial
> > > > > > mappings it won't do any good since we just can't fit the thing into
> > > > > > the gtt.
> > > > > 
> > > > > For gen2, not being able to fit into mappable is an issue for the GPU as
> > > > > well, sure. But for userspace being oblivious and *always* being able to
> > > > > use mmaping of a bo, it is a big deal. (Being oblivious helps with
> > > > > robustness in the stack, X/display-server-de-jour should not die just
> > > > > because of a resource conflict - now X should catch the fault and handle
> > > > > it, give or take bugs, avoiding that error path entirely is even better.)
> > > > 
> > > > Yeah, I suppose it would be nice not to SIGBUS even if userspace is
> > > > trying something a bit crazy. It would just get an error later from
> > > > execbuf when trying to use the bo with the GPU. So I guess the right
> > > > fix would be to fall back to partial vma if we fail to bind the full
> > > > vma.
> > > 
> > > Hmm, actaully no. This was about tiled objects, and we don't do
> > > tiled+partial at all currently. Would need to teach the code to do that
> > > first.
> > 
> > It's is one and the same fix ;) (Ok, same patchset!)
> 
> Yeah the problem is that partial views are stuck half-implemented, and
> seem to not move forward.
> 
> I'd just skip on gen2/3 tbh.

Oh, this is small-bo. Sorry for the digression. medium-bo is to exploit
the page-fault-of-doom.  small-bo is the one that is meant to always
work.

In that context, reducing the size of the small bo (just not to a single
page!) would be fine. And tiny-bo can be one page!
-Chris
diff mbox

Patch

diff --git a/tests/gem_mmap_gtt.c b/tests/gem_mmap_gtt.c
index 3a64a6fdc342..5c3bafcc38ba 100644
--- a/tests/gem_mmap_gtt.c
+++ b/tests/gem_mmap_gtt.c
@@ -280,6 +280,18 @@  test_huge_bo(int fd, int huge, int tiling)
 	switch (huge) {
 	case -1:
 		size = gem_mappable_aperture_size() / 2;
+
+		/* Power of two fence size, natural fence
+		 * alignment, and the guard page at the end
+		 * gtt means that if the entire gtt is
+		 * mappable, we can't usually fit in a tiled
+		 * object half the size of the gtt. Let's use
+		 * a quarter size one instead.
+		 */
+		if (tiling &&
+		    intel_gen(intel_get_drm_devid(fd)) < 4 &&
+		    size >= gem_aperture_size(fd) / 2)
+			size /= 2;
 		break;
 	case 0:
 		size = gem_mappable_aperture_size() + PAGE_SIZE;