[PATCH 12/34] drm: kselftest for drm_mm and alignment

Chris Wilson chris at chris-wilson.co.uk
Thu Dec 15 09:21:37 UTC 2016


On Thu, Dec 15, 2016 at 10:59:10AM +0200, Joonas Lahtinen wrote:
> On ma, 2016-12-12 at 11:53 +0000, Chris Wilson wrote:
> > Check that we can request alignment to any power-of-two or prime using a
> > plain drm_mm_node_insert(), and also handle a reasonable selection of
> > primes.
> > 
> > Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> 
> <SNIP>
> 
> > +static int igt_align(void *ignored)
> > +{
> > +	struct drm_mm mm;
> > +	struct drm_mm_node *node, *next;
> > +	int ret = -EINVAL;
> > +	int prime;
> > +
> > +	drm_mm_init(&mm, 1, U64_MAX - 1);
> > +
> > +	drm_for_each_prime(prime, 8192) {
> > +		u64 size;
> > +		int err;
> > +
> > +		node = kzalloc(sizeof(*node), GFP_KERNEL);
> > +		if (!node) {
> > +			ret = -ENOMEM;
> > +			goto out;
> > +		}
> 
> If the amount of primes would be predictable (pun intended), we could
> malloc the nodes at one go.

I think I'll keep a couple of these smaller kzalloc() sites, just to
have some variety in testing. In particular, this coupled with kmemleak
(or slab debug) could catch a leak other tests might miss.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the dri-devel mailing list