From patchwork Thu Mar 9 13:57:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Usama Anjum X-Patchwork-Id: 13167461 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 0A4B3C64EC4 for ; Thu, 9 Mar 2023 13:58:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9DE86280002; Thu, 9 Mar 2023 08:58:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 968E56B0078; Thu, 9 Mar 2023 08:58:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E142280002; Thu, 9 Mar 2023 08:58:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6C8D16B0074 for ; Thu, 9 Mar 2023 08:58:00 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4894B80BC4 for ; Thu, 9 Mar 2023 13:58:00 +0000 (UTC) X-FDA: 80549513520.20.1AC85F4 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by imf29.hostedemail.com (Postfix) with ESMTP id 68553120013 for ; Thu, 9 Mar 2023 13:57:58 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=h6tj2UNo; spf=pass (imf29.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.172 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass (policy=quarantine) header.from=collabora.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678370278; a=rsa-sha256; cv=none; b=KQcT+diWQLhJ9WsijtVP7FFzOgwVRKeTqGFdiOCuQNvSPBBWP2bDWUcwNiPpagxp3HZ2Db a8fOf43e39zlR/mvqjk8XNCchIs9MCMuvlCS83EfjUsg+tF+FbVyt2a1lw16BKyCP6+0L4 wZCAedXRtGUzZqlUAcGGDzNqHCEo/Yo= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=h6tj2UNo; spf=pass (imf29.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.172 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass (policy=quarantine) header.from=collabora.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678370278; 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:in-reply-to:references:references:dkim-signature; bh=9cigTUCM+RyjxOi6+D6ZOK5PAgtwRmf3H8JA6FTzanM=; b=XtRRbtylGglTCXAvFTeEKa08uZSSsJUCjcwJWOSAk1/JZsi4YfsI24pFYpgwmVgbrPn7KR QKmz5TQJ6UIELOJP5gkvvv7gMzOB0fN9KZygvpYgtI+3Mjrj+RmZUWSd+tQaaEoGVFTZAL uSBBhtJFyB1G5+fO3GxEbRUazzCo3zM= Received: from localhost.localdomain (unknown [39.45.145.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madras.collabora.co.uk (Postfix) with ESMTPSA id 8CF0B660304D; Thu, 9 Mar 2023 13:57:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1678370277; bh=xjF06wKtIpjGyLf20IlUgGfd9VWRBSB80gsUXsjOm7I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h6tj2UNoGmxsJnXR7rkEUAYxAXDjulvcbJmrMOuysjMwtQ8QaHZoTDdbLKGJ0/yNP 7bEuDeoVTAKq5MWHIcVhnfLZ3iqWXIcYXM9Jncn2wZzSlhnU2ENMbSh2AKw1w6R5am F2/NkVQE0TFAJdx5tuFB8K8W4YYWQ1bA18RxvhACd3KYWJEEgoN+ovMOUX1jxVLbUT vXmM3wMO85SZL/wlS/m6ElkKRVwqOJv3z/VT71zyR9ivPDCS3GdAZTDMdNrQi58XmN ruBHblisix6PVBpjtzc6CfJHoSlOGuivyQB6bKXvc65lVGL8hPpTWK3OAa858ZB0sc Y4oBQdKMYn+Wg== From: Muhammad Usama Anjum To: Peter Xu , David Hildenbrand , Andrew Morton , =?utf-8?b?TWljaGHFgiBNaXJvc8WC?= =?utf-8?b?YXc=?= , Andrei Vagin , Danylo Mocherniuk , Paul Gofman , Cyrill Gorcunov , Mike Rapoport , Nadav Amit Cc: Alexander Viro , Shuah Khan , Christian Brauner , Yang Shi , Vlastimil Babka , "Liam R . Howlett" , Yun Zhou , Suren Baghdasaryan , Alex Sierra , Muhammad Usama Anjum , Matthew Wilcox , Pasha Tatashin , Axel Rasmussen , "Gustavo A . R . Silva" , Dan Williams , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Greg KH , kernel@collabora.com Subject: [PATCH v11 3/7] userfaultfd: update documentation to describe UFFD_FEATURE_WP_ASYNC Date: Thu, 9 Mar 2023 18:57:14 +0500 Message-Id: <20230309135718.1490461-4-usama.anjum@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309135718.1490461-1-usama.anjum@collabora.com> References: <20230309135718.1490461-1-usama.anjum@collabora.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 68553120013 X-Rspamd-Server: rspam01 X-Stat-Signature: 5cisof4w3yuqjgt1p8rcj448w9czpqc1 X-H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Hmygo0yKMhUMLi7x/fti9gBimiU3xY8z8R6DAxdVV5uYlQBbgJJJhFOJE2raB79QtvX5OxXas298NHadxeDpakhTSwAU3HLAfFhyk42jQ/CekL56iyioSCLIyv+Fb9zT5VKGHU0VUxfxrCN/gPzLCIHlgXINZ4/cpuTOYmK10Fz/WEEb5LdE+aX0V3pRSWk6Z9wyK7Z7XVmpygcEDAlgw7zdzMO+WaJSeCaIY26WzlvGRSryGf4VJu5jg== 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: Explain the difference created by UFFD_FEATURE_WP_ASYNC to the write protection (UFFDIO_WRITEPROTECT_MODE_WP) mode. Suggested-by: Suggested-by: Peter Xu Signed-off-by: Muhammad Usama Anjum --- Changes in v11: - Update the documentation from reviews entirely from Peter --- Documentation/admin-guide/mm/userfaultfd.rst | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Documentation/admin-guide/mm/userfaultfd.rst b/Documentation/admin-guide/mm/userfaultfd.rst index 7dc823b56ca4..404d8aa8f09f 100644 --- a/Documentation/admin-guide/mm/userfaultfd.rst +++ b/Documentation/admin-guide/mm/userfaultfd.rst @@ -219,6 +219,27 @@ former will have ``UFFD_PAGEFAULT_FLAG_WP`` set, the latter you still need to supply a page when ``UFFDIO_REGISTER_MODE_MISSING`` was used. +If the userfaultfd context (that has ``UFFDIO_REGISTER_MODE_WP`` registered +against) has ``UFFD_FEATURE_WP_ASYNC`` feature enabled, it will work in +async write protection mode. It can be seen as a more accurate version of +soft-dirty tracking, meanwhile the results will not be easily affected by +other operations like vma merging. + +Comparing to the generic mode, the async mode will not generate any +userfaultfd message when the protected memory range is written. Instead, the +kernel will automatically resolve the page fault immediately by dropping the +uffd-wp bit in the pgtables. The user app can collect the "written/dirty" +status by looking up the uffd-wp bit for the pages being interested in +/proc/pagemap. + +The page will be under track of uffd-wp async mode until the page is explicitly +write-protected by ``UFFDIO_WRITEPROTECT`` ioctl with the mode flag +``UFFDIO_WRITEPROTECT_MODE_WP`` set. Trying to resolve a page fault that was +tracked by async mode userfaultfd-wp is invalid. + +Currently ``UFFD_FEATURE_WP_ASYNC`` only support anonymous and shmem. Hugetlb is +not yet supported. + QEMU/KVM ========