From patchwork Thu Oct 1 01:21:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 313913 Delivered-To: patches@linaro.org Received: by 2002:a05:6e02:1081:0:0:0:0 with SMTP id r1csp108980ilj; Wed, 30 Sep 2020 18:21:55 -0700 (PDT) X-Received: by 2002:aa7:9602:0:b029:142:2501:39df with SMTP id q2-20020aa796020000b0290142250139dfmr4838775pfg.46.1601515315654; Wed, 30 Sep 2020 18:21:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601515315; cv=none; d=google.com; s=arc-20160816; b=yhpN9dmwnCGJAdq1uU05r05Curtaq7+ItZljMW+6WiqU98k2jcwHcuYVKBx17fp/Lz CZQN1bOnZ8UJ3UfOZHNCaItG1z1NN74b2l8lrn6HKtaV3h9waNK45cGxCltFcvw6iPJE hU9ruUtPwDMjDP3WfTCFKqwUtY2fWR3beNYutqNeOK6RWylABV90oubO4sWBaULpECrw 2YAV8J5yhrD05RQCPOsN/t9vqAa787zO6Myl9blX0JA+I8DuhDs9HBR9oS8FJFCPRUVw SgiVWSebNACNYUvMSYtGEIsN1nmfBJqMmRLseMyGk4oRtkHSXNLYIQ0e/zefJsVWc1cn c+6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=fvY55OKvdBQuZcw5ImE/AN2tBcW6EILZrL1RIyXg90E=; b=gHRK7w0hYdOYcxbOkPmKDKIQjQq1jjB/oTyDA2Y++4Zy9zT2YUCaqSWDGL4sg+GNao gEmNxqNw4cPnaStyJDhdzfW27LqGqDIA8JrWkTuEO5CHMTzMOrbWQotdpj7eubB9P6Qb tBJneOqBFHvasYmkOTs1TVZoa+GH/jHsO5HuGVuoFxjred5wj2Wp+e0pW5gIjHsGnPuC Wb52Bpoec8grmg6HN6vVqHZLsxQCHGGrAy1WccvwldS5DyqV5mMVM9NQwDYPhf4HgDQy Zhscqb2TjVYCSPoyYawaaEMEIhwTzdd5YTSPU8/BIaB0ttSbdj5+n7pZHjfcWhjdIiB4 EELQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b7EY98on; 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 81sor1875453pfw.42.2020.09.30.18.21.55 for (Google Transport Security); Wed, 30 Sep 2020 18:21:55 -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=b7EY98on; 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:mime-version :content-transfer-encoding; bh=fvY55OKvdBQuZcw5ImE/AN2tBcW6EILZrL1RIyXg90E=; b=b7EY98onG6qWo1zxpcIa1WXVRCHcZZvWrwT6452qabZ8yWmguH1x4Px6q+6NsmdHyj owqPUCFI4SjLTAX2FsL59orOOEgACCwFoe1I3VVFqgSzfMw4i04YEn6BTwqFwL6SUaJP MBgVjf+YW0zCPsGcxND0z7bldFNESSs+iNRyWFiPCCsEGFNZBdeDfIlvXTKDnfdkhzFI UcZi4HTOWf4l4/O7IN7Jf3xd7Rijuxy089ScscjJfiqTojcdjC+WjwCfJoJTqzjx4cp0 sIMtEv2c29Nu7sVd/MKo7e0B0IoP5t7BIMra0+twOu1UBhZNDTdDIjJr2UJy+Rz0cAZK rmxQ== 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:mime-version :content-transfer-encoding; bh=fvY55OKvdBQuZcw5ImE/AN2tBcW6EILZrL1RIyXg90E=; b=jVJcfLFnNAC1LTPkTeZ5yeLQPOIYtaXJcbb/wM60xJq30yZJf1wezml3/5QpVkW07R XOcRbB5f3VtXQKzCR7s2IVj8T4cAGD9rpxVs6ifXySdIPFds7ovYFhXk7qbKAE7V4XUy tZJ73Nxy4cKdiS81gkiBLk9R6ynrif0Ko/OhcXYD1OzLPxLrzgRO6t+UBh690T41xGnK 7TFXNE82hrhVjbx99cb5ef14fNZzRJn9hoet6kqL/U1YfInMmCyf94HUH8SOVKs/74JA fD9hY40fH7c8SaJFxJwSLRgRse+TPWKloS1NGKNCgyUuZ3uJ48Ez8q3XeHX13DK/Fxln Royg== X-Gm-Message-State: AOAM532ZwC1GUoCj6MLdMBJCJqCx0f6RJYBK0yKWhf8I4RxUslvioKx4 Yqi54hDX3HKbMdZgZeiYg1Bg5/zV X-Google-Smtp-Source: ABdhPJxM/aCR52AHNBDdjEC2YIKRegJP/yr49/KVMHTHHeY78lQHqaRradU2OZgQ2PcioJvZKdDoFQ== X-Received: by 2002:a62:3605:0:b029:151:ee7f:d910 with SMTP id d5-20020a6236050000b0290151ee7fd910mr355682pfa.49.1601515315070; Wed, 30 Sep 2020 18:21:55 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id s187sm4229372pfc.134.2020.09.30.18.21.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2020 18:21:54 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Sumit Semwal , Liam Mark , Laura Abbott , Brian Starkey , Hridya Valsaraju , Suren Baghdasaryan , Sandeep Patil , =?utf-8?q?=C3=98rjan_Eide?= , Robin Murphy , Ezequiel Garcia , Simon Ser , James Jones , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH v2 0/6] dma-buf: Performance improvements for system heap Date: Thu, 1 Oct 2020 01:21:45 +0000 Message-Id: <20201001012151.21149-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Hey All, So this patch series contains a series of performance optimizations to the dma-buf system heap. Unfortunately, in working these up, I realized the heap-helpers infrastructure we tried to add to miniimize code duplication is not as generic as we intended. For some heaps it makes sense to deal with page lists, for other heaps it makes more sense to track things with sgtables. So this series reworks the system heap to use sgtables, and then consolidates the pagelist method from the heap-helpers into the CMA heap. After which the heap-helpers logic is removed (as it is unused). I'd still like to find a better way to avoid some of the logic duplication in implementing the entire dma_buf_ops handlers per heap. But unfortunately that code is tied somewhat to how the buffer's memory is tracked. After this, the series introduces two optimizations to the the system heap, utilizing large order pages, and adding a page-pool (maybe abusing the pagepool logic from the network code, but it seems silly to reimplement it). I implemented a simple allocation microbenchmark to compare dmabuf heaps vs ion: https://git.linaro.org/people/john.stultz/android-dev.git/commit/?h=dev/dma-buf-heap-perf&id=24c723fb41c7a9cb5cf9b2412722866cba3a1417 With these changes, the allocation path is *much* improved, performing better then ION (though to be fair, the repeated allocating and freeing of the same size buffer is the ideal case for the pagepool logic, so don't read too much into it). I charted some datapoints from the microbenchmark with each of the patches should folks be interested. https://docs.google.com/spreadsheets/d/1-1C8ZQpmkl_0DISkI6z4xelE08MlNAN7oEu34AnO4Ao/edit#gid=0 Finally, a port of a patch that Ørjan Eide implemented for ION that avoids calling sync on attachments that don't have a mapping. Feedback on these would be great! thanks -john New in v2: * Fix unused return value and locking issue Reported-by: kernel test robot Julia Lawall * Make system_heap_buf_ops static Reported-by: kernel test robot * Make cma_heap_buf_ops static suggested by kernel test robot * Fix uninitialized return in cma Reported-by: kernel test robot * Minor cleanups Cc: Sumit Semwal Cc: Liam Mark Cc: Laura Abbott Cc: Brian Starkey Cc: Hridya Valsaraju Cc: Suren Baghdasaryan Cc: Sandeep Patil Cc: Ørjan Eide Cc: Robin Murphy Cc: Ezequiel Garcia Cc: Simon Ser Cc: James Jones Cc: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org John Stultz (6): dma-buf: system_heap: Rework system heap to use sgtables instead of pagelists dma-buf: heaps: Move heap-helper logic into the cma_heap implementation dma-buf: heaps: Remove heap-helpers code dma-buf: system_heap: Allocate higher order pages if available dma-buf: system_heap: Add pagepool support to system heap dma-buf: heaps: Skip sync if not mapped drivers/dma-buf/heaps/Kconfig | 1 + drivers/dma-buf/heaps/Makefile | 1 - drivers/dma-buf/heaps/cma_heap.c | 328 ++++++++++++++++---- drivers/dma-buf/heaps/heap-helpers.c | 271 ----------------- drivers/dma-buf/heaps/heap-helpers.h | 53 ---- drivers/dma-buf/heaps/system_heap.c | 427 ++++++++++++++++++++++++--- 6 files changed, 659 insertions(+), 422 deletions(-) delete mode 100644 drivers/dma-buf/heaps/heap-helpers.c delete mode 100644 drivers/dma-buf/heaps/heap-helpers.h -- 2.17.1