[Intel-gfx] [PATCH 1/6] drm/i915: Eliminate vmap overhead for cmd parser

Ville Syrjälä ville.syrjala at linux.intel.com
Thu Oct 1 06:29:48 PDT 2015


On Thu, Oct 01, 2015 at 02:24:53PM +0100, Chris Wilson wrote:
> On Thu, Oct 01, 2015 at 03:37:21PM +0300, Ville Syrjälä wrote:
> > On Thu, Oct 01, 2015 at 12:57:10PM +0100, Chris Wilson wrote:
> > > -	while (cmd < batch_end) {
> > > -		const struct drm_i915_cmd_descriptor *desc;
> > > -		u32 length;
> > > +			k = i;
> > > +			if (k > PAGE_SIZE - out)
> > > +				k = PAGE_SIZE - out;
> > > +			if (k == PAGE_SIZE)
> > > +				copy_page(dst, src);
> > > +			else
> > > +				memcpy(dst + out, src + j, k);
> > > +
> > > +			out += k;
> > > +			j += k;
> > > +			i -= k;
> > > +		} while (i);
> > > +
> > > +		cmd = src + in;
> > 
> > So you're now checking the src batch? What prevents userspace from
> > overwriting it with eg. NOPS between the time you copied it and the
> > time you check it?
> 
> Zilch. I picked src as it was already in the CPU cache, whereas dst will
> be WC later. To satisfy you and byt, I need to stage the copy into a
> temporary page, scan it, then copy into dst.
> 
> The silver lining is that it does remove some lines of code. I'm pretty
> confident that the double copy should not be noticed if I remember about
> the cache-trashing of kunmap and carefully manage that.

Yeah, I was thinking that optimally we'd do the copy+scan in cacheline
units, but maybe that's too small to make it actually efficient?

-- 
Ville Syrjälä
Intel OTC


More information about the Intel-gfx mailing list