From nobody Fri Dec 19 11:14:19 2025 Received: from mta21.hihonor.com (mta21.honor.com [81.70.160.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CF77314A74; Mon, 8 Dec 2025 09:41:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=81.70.160.142 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765186898; cv=none; b=aEPgbRQ4Aijs8qHk0uD6tQn9z3cMC39u73jKF9O/CPXJ9EDHOoPVsY7hmugW3YYT9+4ZtAam4QHCQyMDtQnWmZO6LZiqyxBe8RSerJaULMdt62Q5SHHEoBa/dlhG/ZWyUY1ZkginTP2/wBVj7Xk3XcH5HmWO9jSsxlzPzILIFkI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765186898; c=relaxed/simple; bh=849Oo5alFZyVsC8b8C5uNYB8oJ+zNuEajBlX9I2FgT8=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=o/N7mkM2z3PbiTTv8A7z+piIhWZTIzlNRhlK7+m9hCsWEekUaR+PXLSA46WHe61uiSwRlPe0CIGUM9tzoTWHITAZDgZRkGGO4eYMDhqDSB8OsL/yZg9x8DoLmJa/d56O7PcRCJOCdvj2WS/FrePOg1SKDlmXE6WyYnkoVQnnYpQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=honor.com; spf=pass smtp.mailfrom=honor.com; arc=none smtp.client-ip=81.70.160.142 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=honor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=honor.com Received: from w012.hihonor.com (unknown [10.68.27.189]) by mta21.hihonor.com (SkyGuard) with ESMTPS id 4dPxkp0TvQzYmbLG; Mon, 8 Dec 2025 17:38:58 +0800 (CST) Received: from a009.hihonor.com (10.68.30.244) by w012.hihonor.com (10.68.27.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 8 Dec 2025 17:41:27 +0800 Received: from a008.hihonor.com (10.68.30.56) by a009.hihonor.com (10.68.30.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 8 Dec 2025 17:41:27 +0800 Received: from a008.hihonor.com ([fe80::b6bf:fc6a:207:6851]) by a008.hihonor.com ([fe80::b6bf:fc6a:207:6851%6]) with mapi id 15.02.2562.027; Mon, 8 Dec 2025 17:41:27 +0800 From: gao xu To: "sumit.semwal@linaro.org" CC: Benjamin Gaignard , Brian Starkey , John Stultz , "\"T.J. Mercier\"" , =?utf-8?B?IkNocmlzdGlhbiBLw7ZuaWci?= , "linux-media@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "linaro-mm-sig@lists.linaro.org" , "linux-kernel@vger.kernel.org" , Barry Song <21cnbao@gmail.com>, "surenb@google.com" , zhouxiaolong Subject: [RFC] dma-buf: system_heap: add PTE_CONT for larger contiguous Thread-Topic: [RFC] dma-buf: system_heap: add PTE_CONT for larger contiguous Thread-Index: AdxoJnlSUP8R1FJ1RaylLS1xKeCkOw== Date: Mon, 8 Dec 2025 09:41:27 +0000 Message-ID: <3da6a916cd6d489690b05d2bd64a2b3a@honor.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 commit 04c7adb5871a ("dma-buf: system_heap: use larger contiguous mappings instead of per-page mmap") facilitates the use of PTE_CONT. The system_heap allocates pages of order 4 and 8 that meet the alignment requirements for PTE_CONT. enabling PTE_CONT for larger contiguous mappings. After applying this patch, TLB misses are reduced by approximately 5% when opening the camera on Android systems. Signed-off-by: gao xu --- drivers/dma-buf/heaps/system_heap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/sy= stem_heap.c index 4c782fe33..103b06f89 100644 --- a/drivers/dma-buf/heaps/system_heap.c +++ b/drivers/dma-buf/heaps/system_heap.c @@ -202,12 +202,16 @@ static int system_heap_mmap(struct dma_buf *dmabuf, s= truct vm_area_struct *vma) unsigned long n =3D (sg->length >> PAGE_SHIFT) - pgoff; struct page *page =3D sg_page(sg) + pgoff; unsigned long size =3D n << PAGE_SHIFT; + pgprot_t prot =3D vma->vm_page_prot; =20 if (addr + size > vma->vm_end) size =3D vma->vm_end - addr; =20 + if (((addr | size) & ~CONT_PTE_MASK) =3D=3D 0) + prot =3D __pgprot(pgprot_val(prot) | PTE_CONT); + ret =3D remap_pfn_range(vma, addr, page_to_pfn(page), - size, vma->vm_page_prot); + size, prot); if (ret) return ret; =20 --=20 2.42.0