From patchwork Sat Oct 17 01:32:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 317836 Delivered-To: patches@linaro.org Received: by 2002:a92:d603:0:0:0:0:0 with SMTP id w3csp1946869ilm; Fri, 16 Oct 2020 18:33:04 -0700 (PDT) X-Received: by 2002:a17:902:7e82:b029:d3:f3b5:d99a with SMTP id z2-20020a1709027e82b02900d3f3b5d99amr6542584pla.7.1602898384488; Fri, 16 Oct 2020 18:33:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602898384; cv=none; d=google.com; s=arc-20160816; b=vJtn73QgrEAgPup8xQTbF0fjwluhX6LpHV+fypV2tnAnbTWTkOqryhWY7tutG8w2yx cl0ZQQr6KVg8pLVhXEZJZZp0T71gxSvlENBGbvpeRT0OOqQ/5c4VIEAXqY65qafdnytw oID7NPnC/ZOE9Ag26JvmLvJSkKDbaYiDYn+f3zC7g3PIjc5p6AgFSOs3xCA5zcoAptCn fIuA/UUJNcEBNPTwq2BZX3g/ILnedOeqnjdTT77SkzbM0u8XINWCGUCAVK6RmEThJO4x 9Ti2h7MT8Y1YkQGqzG/IUQAjd3Ul7Yk2lOcWJ+6yrKpE8DiSzmnbitzQTC8JPTlVQIrE hNKw== 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=C5OysJtvM42BExDrSWPepk1+ntovtD7pOwO/xcdChaw=; b=FVFQkQDv1Nl4W2use20zRS8pJ/jvrFfCZ4AGx2eHb21pQnmlsKf8ywxIXNRT2adhAh F9K7p71aEbUqxBgIZ0E7oTd4ft5vrCJ1Uio7neOIYd9Tnv565hDDbGHwdwzmcxpX1pq6 GIq2R9wPu+8etMoqK50xBRzG0VtNajTXFitlsXYCdL5as6ZNHN+AM6v9ywKFqkuGZAE7 PIIdIpa5xwN0Z73ttSfsk/+Q9ql8GY+VHZZLUHlej6tTEtiDT6n01jGvshZY1exS1P74 cq4yd5RhliS5IAyQtJNbd1aAUi9d8pvh3Jku2lra5JlVUKwS0XU4a2waL6CPK7lDCaLq 3wGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BGY23IMQ; 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 z6sor2190747pln.27.2020.10.16.18.33.02 for (Google Transport Security); Fri, 16 Oct 2020 18:33:04 -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=BGY23IMQ; 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=C5OysJtvM42BExDrSWPepk1+ntovtD7pOwO/xcdChaw=; b=BGY23IMQRW0yl9F0jX0ao1lYRZTCAEgSrhcam5pGSwwBp0okWk+jVwa9eE2JYEObKD TsKP5vCtq0XeXWIsl8EF7en+vJ96qBGaRGyGS/sBNu7Cn3G0qLnJhsIIfJ0hODOD+x1G IWh+t//F12zX9gFDr9pJaxHGXIvAECOcSuKr1aVEhzQ7o3JU7JTi4cNqnAwUDV7CEcM0 MBD3RflPojsg3nphAfPmG1ex0B8G5rezL4jWclRFgINVtkc1yZfGerA/eBJWgwj/fXwc gWBK7YerfQ0X/3X6o/xS+8FfUTNj/jeBheSJYLo3UZXYq6YQwTx3GX6EDpXobV03Kt+H vj2g== 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=C5OysJtvM42BExDrSWPepk1+ntovtD7pOwO/xcdChaw=; b=ZPuZ7PF+IRMLR28SlfVqW7X4MRATHoFZjz2D3pzc1xYPjxmUYAy6CUr+i9C8Q5avJt 0NxtLu2GbxWnN3xplULcTDb4PWNMCzmEGzbUGJ3tS3s/DPvQ85bYq1RjSSks8EeuEFTd tLczmiB3NLXnakFK34fjUrr7dUXtoKhfJ0mt+H6TR0drD45odD4mUH4I7ApsW0F2kBZD QC51G0hB/ITjOQRLOSEqBdxOttEaUcwHhKJRylrGNwOCzpCOmvaxJcjN45d4iwbtu/Ol wOpqKOTmXO6xkDNa0AYAHODeHX/IpWDG8197yQQULmes/w5VevS9XXucn/t/Ioz6rKXu WxIg== X-Gm-Message-State: AOAM533kpKt7lhwMF+ldkiQ1/EQUb59eo4lveKTNI8PewlJFZZxiCrWp +AwWfqNlFmwO1x3gHzKczauoUPHV X-Google-Smtp-Source: ABdhPJwHJlZeqN6N0aXNECfz8P9EDG08ntt+PJs7x5uLqu0m/hGKeYlTAa5AxHxGx7pS07nW5P3kOw== X-Received: by 2002:a17:902:7c14:b029:d4:d894:7eed with SMTP id x20-20020a1709027c14b02900d4d8947eedmr6994979pll.81.1602898382292; Fri, 16 Oct 2020 18:33:02 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id e186sm4222122pfh.60.2020.10.16.18.32.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Oct 2020 18:33:01 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Sumit Semwal , Liam Mark , Laura Abbott , Brian Starkey , Hridya Valsaraju , Suren Baghdasaryan , Sandeep Patil , Daniel Mentz , Chris Goldsworthy , =?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 v4 0/7] dma-buf: Performance improvements for system heap & a system-uncached implementation Date: Sat, 17 Oct 2020 01:32:48 +0000 Message-Id: <20201017013255.43568-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Hey All, So this is another revision of my patch series to performance optimizations to the dma-buf system heap. 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 an optimization that Ørjan Eide implemented for ION that avoids calling sync on attachments that don't have a mapping. Next, an optimization to use larger order pages for the system heap. This change brings us closer to the current performance of the ION allocation code (though there still is a gap due to ION using a mix of deferred-freeing and page pools, I'll be looking at integrating those eventually). Finally, a reworked version of my uncached system heap implementation I was submitting a few weeks back. Since it duplicated a lot of the now reworked system heap code, I realized it would be much simpler to add the functionality to the system_heap implementaiton itself. While not improving the core allocation performance, the uncached heap allocations do result in *much* improved performance on HiKey960 as it avoids a lot of flushing and invalidating buffers that the cpu doesn't touch often. Feedback on these would be great! thanks -john New in v4: * Make sys_heap static (indirectly) Reported-by: kernel test robot * Spelling fixes suggested by BrianS * Make sys_uncached_heap static, as Reported-by: kernel test robot * Fix wrong return value, caught by smatch Reported-by: kernel test robot Reported-by: Dan Carpenter * Ensure we call flush/invalidate_kernel_vmap_range() in the uncached cases to try to address feedback about VIVT caches from Christoph * Reorder a few lines as suggested by BrianS * Avoid holding the initial mapping for the lifetime of the buffer as suggested by BrianS * Fix a unlikely race between allocate and updating the dma_mask that BrianS noticed. Cc: Sumit Semwal Cc: Liam Mark Cc: Laura Abbott Cc: Brian Starkey Cc: Hridya Valsaraju Cc: Suren Baghdasaryan Cc: Sandeep Patil Cc: Daniel Mentz Cc: Chris Goldsworthy 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 (7): 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: heaps: Skip sync if not mapped dma-buf: system_heap: Allocate higher order pages if available dma-buf: dma-heap: Keep track of the heap device struct dma-buf: system_heap: Add a system-uncached heap re-using the system heap drivers/dma-buf/dma-heap.c | 33 +- drivers/dma-buf/heaps/Makefile | 1 - drivers/dma-buf/heaps/cma_heap.c | 327 +++++++++++++++--- drivers/dma-buf/heaps/heap-helpers.c | 270 --------------- drivers/dma-buf/heaps/heap-helpers.h | 53 --- drivers/dma-buf/heaps/system_heap.c | 488 ++++++++++++++++++++++++--- include/linux/dma-heap.h | 9 + 7 files changed, 749 insertions(+), 432 deletions(-) delete mode 100644 drivers/dma-buf/heaps/heap-helpers.c delete mode 100644 drivers/dma-buf/heaps/heap-helpers.h -- 2.17.1