From patchwork Thu Nov 23 06:44:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kasireddy, Vivek" X-Patchwork-Id: 13465862 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E2FFEC61D85 for ; Thu, 23 Nov 2023 07:08:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 169FD10E6CE; Thu, 23 Nov 2023 07:08:29 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id B132F10E6CE for ; Thu, 23 Nov 2023 07:08:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700723307; x=1732259307; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=59vrc5NDkw8wvYj2LEIRQerTqRUGFz+PrpmpY5i0pgo=; b=TBcf69CFdM+WL+F4doaC4/04+umemEv/y4wKUnmVsn4udIu39EGvENyX px7e1boFFbRnNyUMmVHo0VqnA6jMD9fHd7AvRtt2FltJj8GBTkMZVCW52 oxE75KO0bAgctE6vrQYgWgNWECLTULNkWbQ8Lph8QdsPNK/mfer6ge6GG XBS3S4rDcZxCpMIFz4+EJLLz9MiKH+YeRsrbZhBnZO4qj6vh5oKVm8eln 41WEQf6/WCfVFvHUGE5vqFWnXMzpoTmo/ziyDd0x2t2XhuAoWmLb4fiij h5LEZ/3mgmwmgNv/51+6H4S0BhkSje1gwhtItZ8hr7ZQxNG9QrZg57AOE A==; X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="382612314" X-IronPort-AV: E=Sophos;i="6.04,220,1695711600"; d="scan'208";a="382612314" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2023 23:08:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,220,1695711600"; d="scan'208";a="8757711" Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2023 23:08:23 -0800 From: Vivek Kasireddy To: dri-devel@lists.freedesktop.org, linux-mm@kvack.org Subject: [PATCH v5 0/5] mm/gup: Introduce pin_user_pages_fd() for pinning shmem/hugetlbfs file pages (v5) Date: Wed, 22 Nov 2023 22:44:38 -0800 Message-Id: <20231123064443.1035709-1-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dongwon Kim , David Hildenbrand , Daniel Vetter , Hugh Dickins , Vivek Kasireddy , Peter Xu , Gerd Hoffmann , Jason Gunthorpe , Junxiao Chang , Mike Kravetz Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The first two patches were previously reviewed but not yet merged. These ones need to be merged first as the fourth patch depends on the changes introduced in them and they also fix bugs seen in very specific scenarios (running Qemu with hugetlb=on, blob=true and rebooting guest VM). The third patch introduces pin_user_pages_fd() API and the fourth patch shows how the udmabuf driver can make use of it to longterm-pin the the pages. The last patch adds two new udmabuf selftests to verify data coherency after potential page migration. v2: - Updated the first patch to include review feedback from David and Jason. The main change in this series is the allocation of page in the case of hugetlbfs if it is not found in the page cache. v3: - Made changes to include review feedback from David to improve the comments and readability of code - Enclosed the hugepage alloc code with #ifdef CONFIG_HUGETLB_PAGE v4: - Augmented the commit message of the udmabuf patch that uses pin_user_pages_fd() - Added previously reviewed but unmerged udmabuf patches to this series v5: - Updated the patch that adds pin_user_pages_fd() to include feedback from David to handle simultaneous users trying to add a huge page to the mapping - Replaced find_get_page_flags() with __filemap_get_folio() in the second and third patches to ensure that we only obtain head pages from the mapping Cc: David Hildenbrand Cc: Daniel Vetter Cc: Mike Kravetz Cc: Hugh Dickins Cc: Peter Xu Cc: Jason Gunthorpe Cc: Gerd Hoffmann Cc: Dongwon Kim Cc: Junxiao Chang Vivek Kasireddy (5): udmabuf: Use vmf_insert_pfn and VM_PFNMAP for handling mmap udmabuf: Add back support for mapping hugetlb pages (v4) mm/gup: Introduce pin_user_pages_fd() for pinning shmem/hugetlbfs file pages (v5) udmabuf: Pin the pages using pin_user_pages_fd() API (v3) selftests/dma-buf/udmabuf: Add tests to verify data after page migration drivers/dma-buf/udmabuf.c | 96 ++++++++--- include/linux/mm.h | 2 + mm/gup.c | 114 +++++++++++++ .../selftests/drivers/dma-buf/udmabuf.c | 151 +++++++++++++++++- 4 files changed, 334 insertions(+), 29 deletions(-)