From patchwork Mon Nov 6 06:15: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: 13446261 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 D70E4C4332F for ; Mon, 6 Nov 2023 06:17:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 723856B01A3; Mon, 6 Nov 2023 01:17:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D39A6B01A4; Mon, 6 Nov 2023 01:17:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5753D6B01A5; Mon, 6 Nov 2023 01:17:43 -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 43DE46B01A3 for ; Mon, 6 Nov 2023 01:17:43 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 12AF540664 for ; Mon, 6 Nov 2023 06:17:43 +0000 (UTC) X-FDA: 81426523206.21.A113653 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by imf27.hostedemail.com (Postfix) with ESMTP id 1F1D940002 for ; Mon, 6 Nov 2023 06:17:40 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="XHB/Cgjs"; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf27.hostedemail.com: domain of vivek.kasireddy@intel.com designates 134.134.136.65 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=1699251461; 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=fglb7MPubkHhPQ1w+ncYWplblMvkY5mw51UC7sa1ugI=; b=BZsDJr0tj3F/YwGqm3Jrkhhtyxybai0QJjbkbnfElyjjrTtWxoKYah0Wox4Dt0csDh4mBd DceMNS36UIJoegnaI2hoBC1dKaumuMEjOb55mM9HeSxXW06I4Bjszn5inZdvos2w+gEkSc P5YGDnTQc9MpgXyBsOuw5Hw2/Oa6lNs= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="XHB/Cgjs"; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf27.hostedemail.com: domain of vivek.kasireddy@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=vivek.kasireddy@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699251461; a=rsa-sha256; cv=none; b=Mu+EJzio0UOvxwsuWsATBhttCL23A2trn8BePBQpKEtynImkEXh/6Z0F+U1UPS6dqTkAoT FNv1Sv8qRhjMogYY2py+OB1ZD3h1JsLJ3W1zdl3Jc/3WjzvtqJBX3qOyzD9TFBV0qORwIS bU53pFgIzqYIuV8hVo9veAfAc89v3dc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699251461; x=1730787461; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=CQNkmJJjkw/nbxkIqmxjq5ajXGh14LTXmVuOwmXIlwU=; b=XHB/CgjsLQ8shCr7LFEyRmoSevfC9VSmxIbIqy2A65nmawBWrj10HftF hfcsBDplLkEG4pvtzwuxfuc1lDzkMFaGq/MYBz8+cOlSM4GSBYJVnFVwh ragfx97cEA8Dr8RPXzMPN8nVOz12eCVckdHX4tt8Zcqgo/ZF0vFhsQWz7 n1eJK614KyU//5qXDYx1OXHfp3KZD/HbPkSDhB+Xw7LeqC3tNTbPSlfT4 NBddLACRJSy64GVyRqj/WSbfSK9mmfWYQdg+BP7lTqmR7US5NostOlt4U DzifC5Su0q+U4jvHZoSw3gW4nWkVBcYm5uv03wihaT2QMRbucC6hAE7S4 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10885"; a="393113907" X-IronPort-AV: E=Sophos;i="6.03,280,1694761200"; d="scan'208";a="393113907" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2023 22:17:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10885"; a="797213043" X-IronPort-AV: E=Sophos;i="6.03,280,1694761200"; d="scan'208";a="797213043" Received: from vkasired-desk2.fm.intel.com ([10.105.128.7]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2023 22:17:34 -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 v2 0/3] mm/gup: Introduce pin_user_pages_fd() for pinning shmem/hugetlbfs file pages (v2) Date: Sun, 5 Nov 2023 22:15:38 -0800 Message-Id: <20231106061541.507116-1-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 1F1D940002 X-Stat-Signature: ycj1d35y69pf4h35cc7rskzx33y15hwz X-Rspam-User: X-HE-Tag: 1699251460-521702 X-HE-Meta: U2FsdGVkX1/l880tWCMkV0T6mPx7HhNXm3i044yDBCnHupnA1tMCiXUOw7PWet6uRj8ustLKSleuHs1oHPiwcLDQLC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gzlFQeuQfLlFVyupq883MXA9YCG4TqJw6vuhzA+PuHIR6G/JsBSav6V/yNfgKeICC1SYF4K9mCAkqpQtyt0tDreXRMPYmGNz0T+Q4v3oqo1tNQ= 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 patch introduces pin_user_pages_fd() API and the second patch shows how the udmabuf driver can use it to longterm-pin the the pages. The last patch adds two new udmabuf selftests to verify data coherency after 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. 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 (3): mm/gup: Introduce pin_user_pages_fd() for pinning shmem/hugetlbfs file pages (v2) udmabuf: Pin the pages using pin_user_pages_fd() API (v2) selftests/dma-buf/udmabuf: Add tests to verify data after page migration drivers/dma-buf/udmabuf.c | 81 +++++++--- include/linux/mm.h | 2 + mm/gup.c | 99 ++++++++++++ .../selftests/drivers/dma-buf/udmabuf.c | 151 +++++++++++++++++- 4 files changed, 308 insertions(+), 25 deletions(-)