Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp117565pxb; Mon, 8 Feb 2021 17:12:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJx61oTgNkZTg8+QVsYao0PctDLuwo6pxoY+u0QNETHGsSPEUJby7vzhjwTnO5cMxWTO86lr X-Received: by 2002:aa7:d6d4:: with SMTP id x20mr20562126edr.8.1612833170427; Mon, 08 Feb 2021 17:12:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612833170; cv=none; d=google.com; s=arc-20160816; b=UAOz5Lt91+whcENFAa0h9x36prZUTiNYxc/gLPFPEHTpJzg6nua6PpmSNkruFDjioZ g7BDbAJ0n+dDMi4CuvDNNMyx9Ldx7C6hgtZ7HOi7WhCBVYXBHoTyAdveH0jBDV1Ted73 i/AmEp2OJL1qSlPXlKHlhLyq9zm/jESZIhgF5sDY7BJU4GjFzIs2I6n8DT1HKqRI023g aagOZATZMqrN1kYDPhkcpyTJOKFkSkVR0RI2uP3kErPqLebFCiJA1oYYQc8w2STGrL8y 4k3qpzShRpBVOW/RGNoQ/1VDj77dQovlduZFtjwD3UwnXTEng4o215WFd6PGyCowpsHR SXgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=pyZp6/9XNMC0mK0WRRvgfyWXvzV3+8u2/OO5kZH2+Vg=; b=qK8KN/Su3xdxogSv7yo7vkSquIgxceMjyEvbwv0AG9q92PpHen5hPUQegAYgA4kFQr zq2/Ro1j9XGh/Ha4QEdclvzi0ZKyv83WXkTJugISEGtF1/Zxv/7FCGt4Foj54nwhxUQf zCqAG6f5eRSfZIwAI04z7YWT1ojD3T5RQur2Wwra2+QyhAH0MZx/mgDQeu+Dgenl3i8Y X/FW+jN43HmT5OaOf1+eRrOXIHrbzlbXC/lleuRGTqbfGnwMapq28+E0tG8cDZWu2rag Zh83SD6WYmSZPA01MrXOTPOhdVTQkApWWse4VTHhSQMf/Io/XmkYf/d3P9To+pl5IYtp 7X2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=jeZjl3nf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u8si13134790edj.434.2021.02.08.17.12.26; Mon, 08 Feb 2021 17:12:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=jeZjl3nf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230224AbhBIBKe (ORCPT + 99 others); Mon, 8 Feb 2021 20:10:34 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:9755 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230088AbhBIBKO (ORCPT ); Mon, 8 Feb 2021 20:10:14 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Mon, 08 Feb 2021 17:09:34 -0800 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 9 Feb 2021 01:09:34 +0000 Received: from localhost (172.20.145.6) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 9 Feb 2021 01:09:33 +0000 From: Alistair Popple To: , , , CC: , , , , , , , "Alistair Popple" Subject: [PATCH 4/9] Documentation: Add unmap and pin to HMM Date: Tue, 9 Feb 2021 12:07:17 +1100 Message-ID: <20210209010722.13839-5-apopple@nvidia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210209010722.13839-1-apopple@nvidia.com> References: <20210209010722.13839-1-apopple@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To DRHQMAIL107.nvidia.com (10.27.9.16) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1612832974; bh=pyZp6/9XNMC0mK0WRRvgfyWXvzV3+8u2/OO5kZH2+Vg=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:Content-Type: X-Originating-IP:X-ClientProxiedBy; b=jeZjl3nfuSeq3FgFlgTJUt58XPL3emJVARijzZ4vq7ltCLgRVsr0bJW0RX7cLsy4+ 6i2ssucV5jShnIDv0z47fip74hEH6p2G7xEJGuH3szVMZf9TbumLk+9q9cM2uqpJqF zp0STD/loZHiqwCk48WN2CUfYhM/po5OgnEr3p85w9nntk+tBlaEU/GEolQNOEp1iF zEl1WiliIccRiu3A/3Ps6CBlVCYypWGxVgimQYvt7/3b0HLJ79gnhK9hGtXogpZXon 2dFsEzwULBU/1bCkZF5FIg7ycfCM4V4o6iEhQSzOB1i8QXdnME+lFPKBFz1v+szxGz jVlzmZBk+PGQA== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Update the HMM documentation to include information on the unmap and pin operation. Signed-off-by: Alistair Popple --- Documentation/vm/hmm.rst | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Documentation/vm/hmm.rst b/Documentation/vm/hmm.rst index 09e28507f5b2..83234984f656 100644 --- a/Documentation/vm/hmm.rst +++ b/Documentation/vm/hmm.rst @@ -346,7 +346,15 @@ between device driver specific code and shared common = code: from the LRU (if system memory since device private pages are not on the LRU), unmapped from the process, and a special migration PTE is inserted in place of the original PTE. - migrate_vma_setup() also clears the ``args->dst`` array. + + A device driver may also initialise ``src`` entries with the + ``MIGRATE_PFN_PIN`` flag. This allows the device driver to unmap and pi= n + the existing system page in place whilst migrating page metadata to a + device private page. This leaves the page isolated from the LRU and giv= es + the device exclusive access to the page data without the need to migrat= e + data as any CPU access will trigger a fault. The device driver needs to + keep track of the ``src`` page as it effectively becomes the owner of + the page and needs to pass it in when remapping and unpinning the page. =20 3. The device driver allocates destination pages and copies source pages t= o destination pages. @@ -357,8 +365,8 @@ between device driver specific code and shared common c= ode: array for that page. =20 The driver then allocates either a device private struct page or a - system memory page, locks the page with ``lock_page()``, and fills in t= he - ``dst`` array entry with:: + system memory page, locks the page with ``lock_page()``, and fills in + the ``dst`` array entry with:: =20 dst[i] =3D migrate_pfn(page_to_pfn(dpage)) | MIGRATE_PFN_LOCKED; =20 @@ -373,6 +381,14 @@ between device driver specific code and shared common = code: destination or clear the destination device private memory if the point= er is ``NULL`` meaning the source page was not populated in system memory. =20 + Alternatively a driver that is remapping and unpinning a source page + obtained from a ``MIGRATE_PFN_PIN`` operation should lock the original + source page and pass it in along with the ``MIGRATE_PFN_UNPIN`` flag + without any need to copy data:: + + dst[i] =3D migrate_pfn(page_to_pfn(spage)) | MIGRATE_PFN_LOCKED + | MIGRATE_PFN_UNPIN; + 4. ``migrate_vma_pages()`` =20 This step is where the migration is actually "committed". --=20 2.20.1