aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Salido2018-07-09 15:31:11 -0500
committerAdrian Salido2018-07-09 18:28:12 -0500
commitc5371788edf2e8d8cea7365475ce89ed786c6320 (patch)
tree913e1b5b348ceba02989eae9bc6d8dac5334ecd4 /xf86drmMode.c
parent8965152a5b26a0063c9070d42f95769ddc5b97c3 (diff)
downloadexternal-libdrm-c5371788edf2e8d8cea7365475ce89ed786c6320.tar.gz
external-libdrm-c5371788edf2e8d8cea7365475ce89ed786c6320.tar.xz
external-libdrm-c5371788edf2e8d8cea7365475ce89ed786c6320.zip
libdrm: reduce number of reallocations in drmModeAtomicAddProperty
When calling drmModeAtomicAddProperty allocation of memory happens as needed in increments of 16 elements. This can be very slow if there are multiple properties to be updated in an Atomic Commit call. Increase this to as many as can fit in a memory PAGE to avoid having to reallocate memory too often. Bug: 111047515 Change-Id: I043db1e7608b0a606adf1a6e468c90734372f363
Diffstat (limited to 'xf86drmMode.c')
-rw-r--r--xf86drmMode.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/xf86drmMode.c b/xf86drmMode.c
index e1c99742..2876b422 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -1507,7 +1507,7 @@ drmModeAtomicReqPtr drmModeAtomicDuplicate(drmModeAtomicReqPtr old)
1507 return NULL; 1507 return NULL;
1508 } 1508 }
1509 memcpy(new->items, old->items, 1509 memcpy(new->items, old->items,
1510 old->size_items * sizeof(*new->items)); 1510 old->cursor * sizeof(*new->items));
1511 } else { 1511 } else {
1512 new->items = NULL; 1512 new->items = NULL;
1513 } 1513 }
@@ -1566,12 +1566,13 @@ int drmModeAtomicAddProperty(drmModeAtomicReqPtr req,
1566 return -EINVAL; 1566 return -EINVAL;
1567 1567
1568 if (req->cursor >= req->size_items) { 1568 if (req->cursor >= req->size_items) {
1569 const uint32_t item_size_inc = getpagesize() / sizeof(*req->items);
1569 drmModeAtomicReqItemPtr new; 1570 drmModeAtomicReqItemPtr new;
1570 1571
1571 req->size_items += 16; 1572 req->size_items += item_size_inc;
1572 new = realloc(req->items, req->size_items * sizeof(*req->items)); 1573 new = realloc(req->items, req->size_items * sizeof(*req->items));
1573 if (!new) { 1574 if (!new) {
1574 req->size_items -= 16; 1575 req->size_items -= item_size_inc;
1575 return -ENOMEM; 1576 return -ENOMEM;
1576 } 1577 }
1577 req->items = new; 1578 req->items = new;