From patchwork Sat Apr 20 04:24:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 162546 Delivered-To: patches@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp170100jan; Fri, 19 Apr 2019 21:25:07 -0700 (PDT) X-Received: by 2002:a63:c54a:: with SMTP id g10mr7377302pgd.71.1555734307396; Fri, 19 Apr 2019 21:25:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555734307; cv=none; d=google.com; s=arc-20160816; b=vXgFQ5ZhsSCpcfSLyu/TqlBtXCSKNef4YLa5roPvg1Ilq7bw8B0F6O50s3A1/i7fAv /YYadg/GwnBz7qcPTkzVymQrkeijN7AXlVjW8AVbDQat54REG0PigE0pFodt9JuWOoaz CVVMbu97Wxlyy0/TlEz4/ae+KvD7qnvO/8yxaVzLMeO3qVJ6FFS3sGsp5rBlKZOh8exo AbSEn7HB8T9Ql8QQzjASM4FELxcmSwuBzbG3AvQqOg4B9ADowWRYe1Y7WGV+Mude+xDB nGZ7ZAKZQOQBr6eBH23q+k76ph8NHf19y4qQpim4SVmq3gHPsMPsS2Jeiig4jg+cme90 M3yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=O5k3Wm3IwUSsiLjZy8zGeLHsxYBqF2V3pMzYBlwtwzk=; b=pkyAL7oQJxvh3lRisJhXtQFZ5DbuIH4IaNC73ZsGqWcHijv4F0F9PgU0YzuSE4I7KX TQdThv7Im9H6Q71B2QvQpjkOT3rdRc7Bm7wgRkk6UMwU8p24z0+RjECOjP5jkOoUY7S5 gM5Dt5G1mPBTbaJMfuddffcRx1m6i0bl3Tps1OLBXAC3lpAV/G+e5YvPk9KWQcJjamvl P3HhZN0WT0P5nkD+138FJ3oihIJ4voDVIaCMCkm08gP+eL7U0+DjUq73T/wAq1BsT3IE Hf2nzJ9lKZP4uwIBenLdtdjWQtSztr9Str5ObgStpVX4G2Bo1y6fnuTIQoIln9gSfHKA 0++Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="s/ag80O8"; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a12sor7182053pgw.35.2019.04.19.21.25.07 for (Google Transport Security); Fri, 19 Apr 2019 21:25:07 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="s/ag80O8"; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=O5k3Wm3IwUSsiLjZy8zGeLHsxYBqF2V3pMzYBlwtwzk=; b=s/ag80O8omLYdoFpDuV4OtsRmTWhfBqGUE1rrt5WSKubsAptPyLGsF21ISP2Bp+V3g Oh5k0MRjRcAjf3fLCvbpa/KbX5syw03khhvfkSXlvmE1dCh7fFY3jKpSeZh/wxGjR34U qXaY1gebAGXFUW3Bp6N7Uym3VWnA9nC4193b6ZSvE/7sclMSogEh/5lah/aKZ3qLjQCs S2+/+7MZ8jGaIJ2E1Ad/2JAD5oyAP05+CVdzw9Q226n74XctubE9ZAmsRPhBw2GdZ3Q7 2SgYVZwYrrMh8YcyvWCt3hW3QZk2f1r1MLscbRzcnnZ3V2LZ08WVY6khpwWoNjJAfSMU SksQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=O5k3Wm3IwUSsiLjZy8zGeLHsxYBqF2V3pMzYBlwtwzk=; b=Q1Q2A/fGgqcaMpJXY4K03PxeY/dmaLsx/CbTKnqIF9eSP05+qyN5bYSu4q8Gai+5zg sMLJZwXeIfAk/H8htVgej4+VlxJEgqu/09EoH0FSRP3YE8QKdEtCgN9MLDIbOWNBQfSe FdIxopwGI5zCUCVkoWlV/Ge38YvZIRDcfrKeXrawiy2Qe2E/CGdmUZrUhWC/dYYGNZNL SDMeiYNvtqL7cgc4a7B1j7YdY4nQPB41bn/JZxzSBPUNW/MgNUjLNsyJiiKu19chRzY8 7Fmo4U5Y8uNOpRmbnfS/5JAOXCwaLUxkIxZuwqEp3FBWkejx9oQfyb9ZXyD96DTsImbG uTcA== X-Gm-Message-State: APjAAAWzN07Iyi40GzNbqLG0SXwEtCAotSxW9BSuZTFca8heLubKJBSb lnv/isVNmUSQQeYN1vVO8Ig0HOKG X-Google-Smtp-Source: APXvYqxmp4tlwEwD2UHhnCCkSjipGk2Uqo/Mx8LoKXBecfh5u8rWoPjImEpawZFMQua9AhfHeBfxZA== X-Received: by 2002:a65:5941:: with SMTP id g1mr7507570pgu.51.1555734307030; Fri, 19 Apr 2019 21:25:07 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id i1sm15578372pgc.63.2019.04.19.21.25.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 19 Apr 2019 21:25:05 -0700 (PDT) From: John Stultz To: dri-devel Cc: Adrian Salido , Emil Velikov , Sean Paul , Alistair Strachan , Marissa Wall , John Stultz Subject: [RFC][PATCH 4/5] libdrm: reduce number of reallocations in drmModeAtomicAddProperty Date: Fri, 19 Apr 2019 21:24:54 -0700 Message-Id: <1555734295-31015-5-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1555734295-31015-1-git-send-email-john.stultz@linaro.org> References: <1555734295-31015-1-git-send-email-john.stultz@linaro.org> From: Adrian Salido 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. Cc: Emil Velikov Cc: Sean Paul Cc: Alistair Strachan Cc: Marissa Wall Signed-off-by: John Stultz --- xf86drmMode.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 2.7.4 Reviewed-by: Alex Deucher Reviewed-by: Emil Velikov diff --git a/xf86drmMode.c b/xf86drmMode.c index 8f8633e..c878d9e 100644 --- a/xf86drmMode.c +++ b/xf86drmMode.c @@ -1259,7 +1259,7 @@ drm_public drmModeAtomicReqPtr drmModeAtomicDuplicate(drmModeAtomicReqPtr old) return NULL; } memcpy(new->items, old->items, - old->size_items * sizeof(*new->items)); + old->cursor * sizeof(*new->items)); } else { new->items = NULL; } @@ -1322,12 +1322,13 @@ drm_public int drmModeAtomicAddProperty(drmModeAtomicReqPtr req, return -EINVAL; if (req->cursor >= req->size_items) { + const uint32_t item_size_inc = getpagesize() / sizeof(*req->items); drmModeAtomicReqItemPtr new; - req->size_items += 16; + req->size_items += item_size_inc; new = realloc(req->items, req->size_items * sizeof(*req->items)); if (!new) { - req->size_items -= 16; + req->size_items -= item_size_inc; return -ENOMEM; } req->items = new;