From patchwork Thu Aug 22 08:43:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Huan Yang X-Patchwork-Id: 99174 Received: from sv.mirrors.kernel.org ([139.178.88.99]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sh3RJ-0003Bv-2G for patchwork@linuxtv.org; Thu, 22 Aug 2024 08:45:08 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7BB92284E83 for ; Thu, 22 Aug 2024 08:45:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F045176FCF; Thu, 22 Aug 2024 08:44:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="UK0CVOd4" X-Original-To: linux-media@vger.kernel.org Received: from HK2PR02CU002.outbound.protection.outlook.com (mail-eastasiaazon11010011.outbound.protection.outlook.com [52.101.128.11]) (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 1B06C13C3CD; Thu, 22 Aug 2024 08:44:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.128.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724316289; cv=fail; b=ApMpZ1WfAMx5lHyNNxxR3EUZu1WAG6LEKRLA5bYclGZzxGCuYj1USdP6u3dp1iLGkJUJb/gkSgPsIEJjYxwWZsaYZ7L5p0QgqMf3Re9rp4ZODn3ZVEg+0eMt+UQaHMqEwvr1cuzCXM4n6e3oUc4oRyc1ZDyNNQ3Z/aguYhSAnaY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724316289; c=relaxed/simple; bh=1ngaa7T81IuqmgUkef3xxyfviFhn4Af4kOmGNvnQBqs=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=lElQ64T6ZUkPMEsiGIOyrFQeeA8L6rWLOJs7Ik+VHI7os4s9yPsaDRDEuY2cQ/nARQ1+xMn03LvkE1pz2Y4gKoCzriPuhzMskucKkwLxBfFubv61/Hnbn577QY51ukmY/cpkMtf5rWNYkee9B6GTEmEyqLqfi6pNhyKO2DibRG4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com; spf=pass smtp.mailfrom=vivo.com; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b=UK0CVOd4; arc=fail smtp.client-ip=52.101.128.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vivo.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=W/A1lMIXSdpE1nzP3Z6exExAQ0f+T56TIQOVPnah5oeesiWafXwJh+pkK0wr5PjRAs944UE3sflfagjR4aKyEsnaZkzy79Vrn0ScEW0mj0GvjxrEwhB6ZgPAM7ljXlR4iQFZV3qG1pujm1muJYwhHcxwBcppF0Z1i8TKpO5FPnfPOs0QfaXr07tyHDjc4dAr2zHB/ELNlgyqBnu5/lO0/bQdtJx9uNMPkuo6nDWED3m0wk0AX1mhC/qxP3Q8Aaehjsjob2saVHz3cswOJ7fA32t9zzsE6Q3Zxr0vrrJS/a8jKdJ7eyF0sivacK068lVs5FizO9LGn0sk40s106yTBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cZ0EDg7J5xF9Ken8evvZ/Cghi/i1KIkpLvh/LrUwe24=; b=rK6khwUwBswDh9QlB1G7UwTmUCnRByS1KrRJujAjT2EBgZM3JDx4gkHzBx23JEvHKX4h5wffhFS0Kk/6UDVs9T6ALHCe/TxwDFAMt7sfzm5eWQIuVm7P9M0ib3JDkswnpuudqNZJ/URu5WA9YMz/SoGm1P10ug7sVNpR4puIEAdnfqTDrJCspLAQ+J8zwhp4Lo3DYDOov5NXxQuQbufz5kqDpR4FaRgrBUL39/ykyiyxgxk9f1A2sGvMm3qOs29h5HuLK0jDARbV8WMHdhl32yU8+IRLMddDiScivF8zl7GqSrTkwO+GIFt44QWbFdCRsOdM8HQkIXFCxzoW/0YnjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cZ0EDg7J5xF9Ken8evvZ/Cghi/i1KIkpLvh/LrUwe24=; b=UK0CVOd4wkB2q16jEEyQvy6/dnboFj2MOeiQoEWNxzulNz2n5B3eqTjnzkQzUDlTcR2DU3iqeLtA8sfuHGghzTlvmZ6cU9guClkaCwr9k/jFBvGrrbXroZiaXrbuluustLjvs84FMDby0B3G4EuW/KSUmlb7RwgoBc12KAd9k9t52Xq9t6XaIsP588dUU/Mh/BFJGnRpoYRRWG1NqZOYu505Q5QC2j5X1nHsoUSpJP2sccVSSPg+XrvKBD7s5REm+Ow5YEdMsEqWU0MXwrFu1n3eBIVYbWfUKvP8pGwvebQRN/6YoO+yuI2daLxmix77G3izMcY+MxjaJrLv4rbG+A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from PUZPR06MB5676.apcprd06.prod.outlook.com (2603:1096:301:f8::10) by SEYPR06MB5400.apcprd06.prod.outlook.com (2603:1096:101:8d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Thu, 22 Aug 2024 08:44:39 +0000 Received: from PUZPR06MB5676.apcprd06.prod.outlook.com ([fe80::a00b:f422:ac44:636f]) by PUZPR06MB5676.apcprd06.prod.outlook.com ([fe80::a00b:f422:ac44:636f%5]) with mapi id 15.20.7875.019; Thu, 22 Aug 2024 08:44:39 +0000 From: Huan Yang To: Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Gerd Hoffmann , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, Huan Yang Subject: [PATCH v4 0/5] udmbuf bug fix and some improvements Date: Thu, 22 Aug 2024 16:43:32 +0800 Message-ID: <20240822084342.1574914-1-link@vivo.com> X-Mailer: git-send-email 2.45.2 X-ClientProxiedBy: SI1PR02CA0059.apcprd02.prod.outlook.com (2603:1096:4:1f5::19) To PUZPR06MB5676.apcprd06.prod.outlook.com (2603:1096:301:f8::10) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PUZPR06MB5676:EE_|SEYPR06MB5400:EE_ X-MS-Office365-Filtering-Correlation-Id: 2ec5d0e5-0118-4742-48d9-08dcc286a887 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?pHSpT50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KPVBqIjLDy2H59lueawMXVg3g7uaGoJntOqEIZGc?= =?utf-8?q?RlD+UCx2nR18eAiHlJAiI021VTEA5fnVCxHplfiQuAWRyYVGldMYFtRgJf08W9Sk+?= =?utf-8?q?ZDkdZ607fJGrXEA0EGh24X4Qn7aDhQNlIrHzsXPJvdkOZs6Q63qlbqA3bpapFfw0g?= =?utf-8?q?kUobbF6zPxeBhpYVyX9REu/mCXIc63cxc1CC0akL53sYJxcAfp0CMdlByE+7Yi3jP?= =?utf-8?q?ftKPF3P3Oo1EEcD6768GUocqLcftvZCzEc2IB48JlbL6tYpOyFuieORilWXiaZIvV?= =?utf-8?q?/Y/PISuOD2UcrNs3VlD0fIT8livPlWOx0tSJ2ZBNPEOy9JB8dcthd4wDO4G+1TfKX?= =?utf-8?q?wSqq+W6b4Mfq+bYIiyc7307Mf4cRD2g6OeL9qR+Pxif0/yTsjF38gtcV/oVnqlgyo?= =?utf-8?q?YzYcqNX42eIN6dZZ9+Vy2WwISWE+hrae3XCvdS61IL3JTPG4X0XnK20blGMrVtcCw?= =?utf-8?q?QoAyJa1MA/Ko6myLC/TJb/KBxa4O1fK65Q=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR06MB5676.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?lwhFuPEF6+2aA6u9tG2IWj5iIM5A?= =?utf-8?q?Be1Tt1W+R6QSbeXIv7XOhT2ZSPc88ezwKfuhpp3GnviG9279MITi2ybCjHk2+5O1o?= =?utf-8?q?JDf5PueA1X88vaaf8vFffV2H7Wc6YKC61HjD/cbaO+o6t7Mihiz83NrKpQgglbNCe?= =?utf-8?q?tOiITX9HkDo4Amp4ZG2rLec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eSv/errn05VPhtouNBK/0wzGGeNWc/rdW2xuQt?= =?utf-8?q?njhjFhlbjY7ps/qEveI2WqBNez7Yeti1+p7pFm+iv8skpW+NiTNn8r7ZX9MoTADn2?= =?utf-8?q?9s3vhF7/Re5Wr369TQ6tavglbUGE0tUqA3qpA9X+qPR5Wcv5oPnT7sfPXIWJvblOG?= =?utf-8?q?snojE6CFpj4agfyHXkBdSD2QrPr4gqupIhHuhBThMJ1mAMi943Ti2DZk8KKD/ih/E?= =?utf-8?q?NSKO+Ym8TBWm1kLNQZeiaBYejVUEbwK4aPSFvxZ7N5JM++ZiWKJO2MVC7AD1vmemL?= =?utf-8?q?u8AJuMCjP2MTofBZ4BKtp12/4Ta1YewHZ/zAR5h/0EuSjil4Wcy5Zq2XkaZfB8to/?= =?utf-8?q?4p+FBh4FlBs10SZnw0ucopZXJk/rwJqg0w7M9HktaUmvhGejjEsxid7WrwcXP1ANh?= =?utf-8?q?I902SQlb6lgOACCeqDPyfnUVTAPHrdNpSkPfeIc6+1XtpsqQWhITQG2ozKHTYNS8c?= =?utf-8?q?56C7yFNBgxmx?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2ec5d0e5-0118-4742-48d9-08dcc286a887 X-MS-Exchange-CrossTenant-AuthSource: PUZPR06MB5676.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 08:44:39.0299 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mvXDUSv5y5yCsXum1OMeh5kQ/C00g5ta22F0x60S7J61JINUYsEIiXi57vAK2x3djDsLfE+hf2Nyw8NzHC6DWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB5400 X-LSpam-Score: -8.6 (--------) X-LSpam-Report: No, score=-8.6 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DMARC_PASS=-0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no This patchset attempts to fix some errors in udmabuf and remove the upin_list structure. Some of this fix just gather the patches which I upload before. Patch 1,2,4,5 has passed the udmabuf self-test suite's tests. Suggested by Kasireddy, Vivek Patch5 modified the unpin function, therefore running the udmabuf self-test program in a loop did not reveal any memory leaks. Notice: Test item 6 maybe requires running the command: echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages Patch1 === mmap just pre-fault when the first access test this by look run create udmabuf size 3GB, then only record the "mmap -> memset"'s time. This average show 1.2s cost compare to direct map when mmap, this also show 1.2s cost. environment: archlinux, linux-next, 16G, 4 core. Patch2 === This is the same to patch: https://lore.kernel.org/all/20240725021349.580574-1-link@vivo.com/ Patch3 === fix current implementation of udmabuf's vmap issues, use pfn. Patch4 === Change codestyle and fix a potential bug. Patch5 === Attempt to remove unpin_list and other related data structures. Changelog === v4 -> v3: Patch1 fill vma area with pfn only when true access. Patch2 no change Patch3 select VMAP_PFN Patch4 use function pin each item. Patch5 use pinned folio array instead udmabuf_folio struct. v2 -> v3: Patch1, avoid use page, instead, use pfn, and use vmf_insert_pfn map suggested-by Kasireddy, Vivek Patch2, update acked-by Kasireddy, Vivek And keep the kvcalloc on the same line. Patch3, avoid use page, instead, use pfn, then use vmap_pfn map Patch4, split v2 patch4, single update codestyle to keep review easy. Patch5, another way to remove udmabuf_folio --- v1 -> v2: Patch1, 3 Rectify the improper use of the sg table. suggested-by Christian König Patch2 add acked-by Christian K�nig which marked in v1 Patch4 Modify the data structure to restore the use of pages and correct the misunderstanding of loop conditions such as "pgcnt". make sure pass self test. remove v1's patch4 v3 https://lore.kernel.org/all/20240813090518.3252469-1-link@vivo.com/ v2 https://lore.kernel.org/all/20240805032550.3912454-1-link@vivo.com/ v1 https://lore.kernel.org/all/20240801104512.4056860-1-link@vivo.com/ Huan Yang (5): udmabuf: direct map pfn when first page fault udmabuf: change folios array from kmalloc to kvmalloc udmabuf: fix vmap_udmabuf error page set udmabuf: udmabuf_create codestyle cleanup udmabuf: remove udmabuf_folio drivers/dma-buf/Kconfig | 1 + drivers/dma-buf/udmabuf.c | 281 +++++++++++++++++++++++--------------- 2 files changed, 172 insertions(+), 110 deletions(-) base-commit: 6a7917c89f219f09b1d88d09f376000914a52763