From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.62 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796145404; b=bVN9Fq+H5fHesj2u/omdAFv/TFVRCu37rG03Bm91jSLVydicPl2Se36NP/RUFqpJyOTz mgVNOQpaZp6GHZKEBg/gchxg+fjWr3F6Uvue6Yh2qxGjQG7NA/cQXNL00RXvgoO7NzVrB jQf/QglAqsoFknsntGIZ1nbRkg1gAajpEtp5oZT0c1NpCM17U2RE2UH+0iDp+XgkY+oXn GK27To/QhI1834FsDFHVGcx0Z2VfcmVRTfIsC/+2YVdwXqCUEYy7Xz+Lr/5KmRbXjs6jl 0vUmkMHFWLGV6Yzz9M6hmvn9r3PMPmDHn6OPneKUvwHqT3uPfCEm3V7+ffjPdbB/dbA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796145404; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer; bh=QKRZb0CtS3VfuBUFxFCSPqiUG41AsnZBOUI7vZVpe90=; b=OG4+YKXSuI8LgZS8V/ypBXEuNRYbw/aMYhQ/wLoi4lm6ywjmJ32Q9ynYxc2o7bVcowKo 1uSLTpgmPMnwYgUtSOcRsPssNIjtpxFecSuZ1H2dF89SLmeGC52sLtWJF/nLZ5VuEIKB5 6TH2hdvZ4JryNqRkESDfh9ZQNcfC6wOUanQtsiqGK3Jlr3l406A+Pq/nQKkJ+KIkHRtBy mOWTEvBzreTVCG74UbtInemVshqYX4QCrs/DmBuzohh0vIQYJs0B6GEG3xnanQUrkFVyx DLJHr9v3Hdu3ICioB8+cCVZsCgNQtyYW/BEsqrL3b04bSN9vqUXbcTe/xQoRu8VyfNA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=tegyKK7e; arc=none smtp.remote-ip=95.215.58.62 Received: from mta1.migadu.com (out-62.mta1.migadu.com [95.215.58.62]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02ADF606A322 for ; Tue, 1 Dec 2026 17:16:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 02ADF606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=tegyKK7e X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=UpvmOX6EFKlzxamPB54cGsg3Jd81xo4cgjAtG2ND8Ss=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796145400; v=1; x=1796750200; b=tegyKK7en+yqyouwUkTCFfhQr+faqXr5jG4kAhHkwIyZDSx63xQYB9d25h9qF3U/fq5Z5jgO hGL92cGRAR3Y3+ZJbXGonXjV2g+2463jz3zWRnKbB2LBN5AhAH7GlbpJFiR+LRUeySMK2ZBXxjY MbcZD404+aQC8oA5csj6Z3Mc= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 4cf38a889e8eb841; Tue, 01 Dec 2026 17:16:40 +0000 X-Mizu-Trace-ID: 4cf38a889e8eb841 X-Migadu-Flow: FLOW_OUT From: Qiliang Yuan Date: Tue, 01 Dec 2026 12:16:20 -0500 Subject: [PATCH v3 1/3] dma-buf: align large mappings to PMD boundaries X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20261201-feat-udmabuf-huge-pfnmap-v3-1-144cc7a48f09@linux.dev> References: <20261201-feat-udmabuf-huge-pfnmap-v3-0-144cc7a48f09@linux.dev> In-Reply-To: <20261201-feat-udmabuf-huge-pfnmap-v3-0-144cc7a48f09@linux.dev> To: Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Philipp Stanner , Gerd Hoffmann , Vivek Kasireddy , Shuah Khan Cc: =?utf-8?q?Thomas_Hellstr=C3=B6m?= , "T.J. Mercier" , Philip Yang , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Qiliang Yuan , Natalie Vock X-Mailer: b4 0.13.0 A dma-buf exporter whose buffer is backed by physically contiguous memory can map it with PMDs from a ->huge_fault() handler, which only works where the user address and the buffer offset are aligned alike to PMD_SIZE. dma_buf_fops has no ->get_unmapped_area(), so mmap() places a dma-buf at whatever page aligned address the default allocator returns. A 4 GiB udmabuf, for one, lands 616 KiB past a 2 MiB boundary, and then none of its PMD-sized ranges can be mapped with a PMD. Use thp_get_unmapped_area(), as filesystems that support huge mappings do. It aligns a mapping that covers at least one whole PMD to the buffer offset and leaves smaller mappings where they would be placed anyway. Signed-off-by: Qiliang Yuan Reviewed-by: Christian König Reviewed-by: T.J. Mercier --- drivers/dma-buf/dma-buf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index c81c0e2ed4f87..2db3059824c71 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -608,6 +608,7 @@ static void dma_buf_show_fdinfo(struct seq_file *m, struct file *file) static const struct file_operations dma_buf_fops = { .release = dma_buf_file_release, .mmap = dma_buf_mmap_internal, + .get_unmapped_area = thp_get_unmapped_area, .llseek = dma_buf_llseek, .poll = dma_buf_poll, .unlocked_ioctl = dma_buf_ioctl, -- 2.43.0