From patchwork Sat Nov 18 06:32:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kasireddy, Vivek" X-Patchwork-Id: 13459885 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5D58C2BB3F for ; Sat, 18 Nov 2023 06:56:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 076056B0149; Sat, 18 Nov 2023 01:56:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 024F46B03DB; Sat, 18 Nov 2023 01:56:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E561C6B0536; Sat, 18 Nov 2023 01:56:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D4C176B0149 for ; Sat, 18 Nov 2023 01:56:11 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A0F70160E3B for ; Sat, 18 Nov 2023 06:56:11 +0000 (UTC) X-FDA: 81470165742.24.F68130A Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by imf19.hostedemail.com (Postfix) with ESMTP id E63AF1A000C for ; Sat, 18 Nov 2023 06:56:08 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=M3gITnW6; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf19.hostedemail.com: domain of vivek.kasireddy@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=vivek.kasireddy@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700290569; a=rsa-sha256; cv=none; b=JhXPouriIvFMDlXu/EYjKUT4SxJmiY2ym6vY4RPGUuExiJqWHlJ4yNPcvJXDJhubaXU1dE 4fZTRwWu5f5dA/z65aA7CaBb0y69+iwxHGLQvsBoL1UArQkPliqtPvsNuAoreSpHdPbJ7F Owb0Sd5Og+7+jB4ZzHcQVdbb/T8MOFQ= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=M3gITnW6; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf19.hostedemail.com: domain of vivek.kasireddy@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=vivek.kasireddy@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700290569; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=SGzmZN9zEqqw22Bz22tNM7axoJKlkq3imIHuGX0T5QU=; b=qL/Vo/EGNn1U3i3dGEH6R7XB7dUhxgEayANUa8dggZ6/aGUsLQ8FKs0qtRb15DxcOWBO87 bi8pEwa0NxMEQJaT6FZry3o0Ac+iCLkhswDKUXd7BSw5NefG305MbqYqby3rkScTP+Lstb jZy9cu0+Sqil3+GZRNPDwfUXBflf66g= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700290569; x=1731826569; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=erO3C/L4XTqWTjYBeWPQmN0O0J5zfZFkCwntSDucTjc=; b=M3gITnW6H5WVXptPMypCyWmR3dCRimAb3qDD/eK8ISJ8y1rMMyb0FW6a klGHqOuF9a0Y/WYm8tIf1N4SDTK/yDRLf/1amgXz5PUKU1nFegyRF37UE w2uxzMa8ElbnrOxeIPF6A5KSsOV+D2C7ug7oXoQqB4R50fXq273JnPZ8A z0JUn10J50QSnCTls72ikCGCb8vaLfESfRPzOhYL10DWz1L9U5OWYuDPj 2dQnEBAJLuwqwZlV/bs6By2WSIMt9qEJp+vmbl4fki2m64LVGHCqtaQQB /6AIpobQKBLhj+EvpSTNlXpkiZrjjddkgop6jwOssYGgIg5PykNrM7j44 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10897"; a="457912350" X-IronPort-AV: E=Sophos;i="6.04,207,1695711600"; d="scan'208";a="457912350" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2023 22:56:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10897"; a="800686571" X-IronPort-AV: E=Sophos;i="6.04,207,1695711600"; d="scan'208";a="800686571" Received: from vkasired-desk2.fm.intel.com ([10.105.128.132]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2023 22:56:06 -0800 From: Vivek Kasireddy To: dri-devel@lists.freedesktop.org, linux-mm@kvack.org Cc: Vivek Kasireddy , David Hildenbrand , Daniel Vetter , Mike Kravetz , Hugh Dickins , Peter Xu , Jason Gunthorpe , Gerd Hoffmann , Dongwon Kim , Junxiao Chang Subject: [PATCH v4 0/5] mm/gup: Introduce pin_user_pages_fd() for pinning shmem/hugetlbfs file pages (v4) Date: Fri, 17 Nov 2023 22:32:28 -0800 Message-Id: <20231118063233.733523-1-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E63AF1A000C X-Stat-Signature: nd537csk7ooh756jmqp4fi8s6ta395pr X-HE-Tag: 1700290568-976527 X-HE-Meta: U2FsdGVkX19p4m03vIi7xG3S4bqhVNNAstkPa4VbLdTP44Gs9HGWzbZ7dWfPTBnhS/nXtqXUfof0mlAl+1NFCc7WYJqA+WSELO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Jg8L0MOGfP/PhoSJobH/RT+bW6O27x0jm2P2iKBMU9EFxGoeS+ZYZvhu/PYP0TcAdGtjeFxLJ6IeNWQQ/HPRE9T2gktCDW9ZbgvG4wPftjKp4sFhShoX/oUk4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 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 (v3) mm/gup: Introduce pin_user_pages_fd() for pinning shmem/hugetlbfs file pages (v4) 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 | 108 +++++++++++++ .../selftests/drivers/dma-buf/udmabuf.c | 151 +++++++++++++++++- 4 files changed, 328 insertions(+), 29 deletions(-)