diff options
author | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-05-08 19:13:25 -0400 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2009-05-19 13:07:14 -0400 |
commit | 8e7d2b2c6ecd3c21a54b877eae3d5be48292e6b5 (patch) | |
tree | 704b3affc3b617be2bcd63ddd9865e9adceeb031 /include/drm/drmP.h | |
parent | 1406de8e11eb043681297adf86d6892ff8efc27a (diff) |
drm/i915: allocate large pointer arrays with vmalloc
For awhile now, many of the GEM code paths have allocated page or
object arrays with the slab allocator. This is nice and fast, but
won't work well if memory is fragmented, since the slab allocator works
with physically contiguous memory (i.e. order > 2 allocations are
likely to fail fairly early after booting and doing some work).
This patch works around the issue by falling back to vmalloc for
>PAGE_SIZE allocations. This is ugly, but much less work than chaining
a bunch of pages together by hand (suprisingly there's not a bunch of
generic kernel helpers for this yet afaik). vmalloc space is somewhat
precious on 32 bit kernels, but our allocations shouldn't be big enough
to cause problems, though they're routinely more than a page.
Note that this patch doesn't address the unchecked
alloc-based-on-ioctl-args in GEM; that needs to be fixed in a separate
patch.
Also, I've deliberately ignored the DRM's "area" junk. I don't think
anyone actually uses it anymore and I'm hoping it gets ripped out soon.
[Updated: removed size arg to new free function. We could unify the
free functions as well once the DRM mem tracking is ripped out.]
fd.o bug #20152 (part 1/3)
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'include/drm/drmP.h')
-rw-r--r-- | include/drm/drmP.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index c8c422151431..b84d8ae35e6f 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h | |||
@@ -1519,6 +1519,30 @@ static __inline__ void *drm_calloc(size_t nmemb, size_t size, int area) | |||
1519 | { | 1519 | { |
1520 | return kcalloc(nmemb, size, GFP_KERNEL); | 1520 | return kcalloc(nmemb, size, GFP_KERNEL); |
1521 | } | 1521 | } |
1522 | |||
1523 | static __inline__ void *drm_calloc_large(size_t nmemb, size_t size) | ||
1524 | { | ||
1525 | u8 *addr; | ||
1526 | |||
1527 | if (size <= PAGE_SIZE) | ||
1528 | return kcalloc(nmemb, size, GFP_KERNEL); | ||
1529 | |||
1530 | addr = vmalloc(nmemb * size); | ||
1531 | if (!addr) | ||
1532 | return NULL; | ||
1533 | |||
1534 | memset(addr, 0, nmemb * size); | ||
1535 | |||
1536 | return addr; | ||
1537 | } | ||
1538 | |||
1539 | static __inline void drm_free_large(void *ptr) | ||
1540 | { | ||
1541 | if (!is_vmalloc_addr(ptr)) | ||
1542 | return kfree(ptr); | ||
1543 | |||
1544 | vfree(ptr); | ||
1545 | } | ||
1522 | #else | 1546 | #else |
1523 | extern void *drm_alloc(size_t size, int area); | 1547 | extern void *drm_alloc(size_t size, int area); |
1524 | extern void drm_free(void *pt, size_t size, int area); | 1548 | extern void drm_free(void *pt, size_t size, int area); |