Skip to content

Commit 6b770d3

Browse files
committed
drm/v3d: Only use Big/Super Pages if BO >= 512KB
Considering that the Raspberry Pi is an embedded device with limited memory, memory fragmentation is an important aspect for performance. Using Big/Super Pages has clear benefits when it comes to reducing TLB misses, but also has an impact on memory fragmentation as we need to allocate aligned contiguous memory, increasing compaction pressure and memory waste for small BOs. As Big/Super Pages only have benefits for larger BOs, create a minimum BO size to use the THP partition. After testing different thresholds, 512KB provides the most balanced results with clear improvements and no significant regressions. This means that Big/Super Pages will only be used for BOs of at least 512KB. Signed-off-by: Maíra Canal <mcanal@igalia.com>
1 parent 51aeb87 commit 6b770d3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/gpu/drm/v3d/v3d_bo.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ v3d_bo_create_finish(struct drm_gem_object *obj)
116116
align = SZ_4K;
117117
else if (obj->size >= SZ_1M)
118118
align = SZ_1M;
119-
else if (obj->size >= SZ_64K)
119+
else if (obj->size >= SZ_512K)
120120
align = SZ_64K;
121121
else
122122
align = SZ_4K;
@@ -150,10 +150,14 @@ struct v3d_bo *v3d_bo_create(struct drm_device *dev, struct drm_file *file_priv,
150150
struct drm_gem_shmem_object *shmem_obj;
151151
struct v3d_dev *v3d = to_v3d_dev(dev);
152152
struct v3d_bo *bo;
153+
size_t size = PAGE_ALIGN(unaligned_size);
153154
int ret;
154155

155-
shmem_obj = drm_gem_shmem_create_with_mnt(dev, unaligned_size,
156-
v3d->gemfs);
156+
if (size >= SZ_512K)
157+
shmem_obj = drm_gem_shmem_create_with_mnt(dev, size, v3d->gemfs);
158+
else
159+
shmem_obj = drm_gem_shmem_create(dev, size);
160+
157161
if (IS_ERR(shmem_obj))
158162
return ERR_CAST(shmem_obj);
159163
bo = to_v3d_bo(&shmem_obj->base);

0 commit comments

Comments
 (0)