From patchwork Wed Jun 19 00:05:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 13703200 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 F0732C2BA1A for ; Wed, 19 Jun 2024 00:05:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 984786B02CB; Tue, 18 Jun 2024 20:05:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 79C1D6B02CA; Tue, 18 Jun 2024 20:05:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A4126B02C6; Tue, 18 Jun 2024 20:05:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id DD0E26B02C0 for ; Tue, 18 Jun 2024 20:05:31 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 913B480B80 for ; Wed, 19 Jun 2024 00:05:31 +0000 (UTC) X-FDA: 82245694062.10.DAD278F Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by imf02.hostedemail.com (Postfix) with ESMTP id 6EE2A80008 for ; Wed, 19 Jun 2024 00:05:28 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=Rq2gAR6M; spf=pass (imf02.hostedemail.com: domain of quic_eberman@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_eberman@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718755525; 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-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=99dxeZteqvg7p6OK+iLSX+t95KV+cPhMZG+8mrLXaF0=; b=FAlvIbx7w/L2Wcorbg3mhLGZXJg7NziEJ+PqtFsIQN7BzDwdXjG9el/ue50yzdXbmOWm8e Jqzoh+jDr2OQojLrM1RgBqDWwvUI0SRgGMcYO4AOUeaUhfaC8W5Y87uVut3a7Dd9TYjcO/ iJZZ9k1jYEIC5Uj4sQETVRYOzEy6lAQ= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=Rq2gAR6M; spf=pass (imf02.hostedemail.com: domain of quic_eberman@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_eberman@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718755525; a=rsa-sha256; cv=none; b=QNOxXBBf8pc1q6raONnlCyFeBoj4+jVnDsbLWeuHdxXX94pq51/Z/Ep34VDzUtU5oGtcep xkDwk2BFwQQPniyh1BSmPrEs4jjr8RsI+F7y0CxWH5dLAQaPpBgy/Gy2g1SJGmJJEpilXr WaIvTjqKrD73W8ThnAij30Gl34kOnPU= Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45ILZtP4014346; Wed, 19 Jun 2024 00:05:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=99dxeZteqvg7p6OK+iLSX+ t95KV+cPhMZG+8mrLXaF0=; b=Rq2gAR6MGC5ASfUIiUgOEBf6rgrvpIIQ04lNg+ z8+1/YZst/Fi3Uh80pivG949nkNPAZYi74wnq4iQGxN+ExSME9Wrl0cNIhA24JrL OW5X3xcst+hWwJRbd60we0x9Lh7qoYbh+Z2KyGy6pmQbIPyE88Wfm3l4ZFJgi7F5 R9SjVJpDLvlkqVVbP5Cs4EWsV0Tlw8VfkeEPxvwV/GND9+Kdd65uKKcyPnl1CUPb z41Vg1eyqXp2Zj/S7RlY8eov6jwmyyyTJ3UpJMv85DdsjK6htVqG/HvHIwEA9MO5 0lFmKWXkxlFeE/451QvIygwlIoA/bKWYfGDNOe1vLrBgL1dw== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3yuj9x07a4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Jun 2024 00:05:17 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA04.qualcomm.com (8.17.1.19/8.17.1.19) with ESMTPS id 45J05Gn5011372 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Jun 2024 00:05:16 GMT Received: from hu-eberman-lv.qualcomm.com (10.49.16.6) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Tue, 18 Jun 2024 17:05:15 -0700 From: Elliot Berman Subject: [PATCH RFC 0/5] mm/gup: Introduce exclusive GUP pinning Date: Tue, 18 Jun 2024 17:05:06 -0700 Message-ID: <20240618-exclusive-gup-v1-0-30472a19c5d1@quicinc.com> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIALIgcmYC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIxMDUwNL3dSK5JzS4syyVN300gJdMzMjU0tDY4ukpLQ0JaCegqLUtMwKsHn RSkFuzkqxtbUARQcl3mQAAAA= To: Andrew Morton , Shuah Khan , David Hildenbrand , Matthew Wilcox , CC: , , , , , , Elliot Berman , Fuad Tabba X-Mailer: b4 0.13.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: ZLQQIfutOgsOTLordQhA7a2Ch1vdnYp4 X-Proofpoint-GUID: ZLQQIfutOgsOTLordQhA7a2Ch1vdnYp4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-18_06,2024-06-17_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 impostorscore=0 priorityscore=1501 suspectscore=0 mlxscore=0 adultscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 bulkscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406180176 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 6EE2A80008 X-Stat-Signature: bcak6dwnohcuww8aj3wio84gq8e5ez5q X-HE-Tag: 1718755528-860165 X-HE-Meta: U2FsdGVkX185RimK1XEenLxfhGEylQF7PCZANgg2DRpdk8G5gsaY79tN1J4rO5bGe7c5TymFiWAlVDp4CiQKLZ2JwPGM8YnZwTny3TmovQj7emLdxb1mrrMpayKSUDgewG/d5qIz3YzFBwdzqN2ElXycFQplIJL6edsJsGvDAAIncXJh32CJuxvIIlNfdke5uAghGVpJX/yjAdTWb+3Zh69FuMFzzAMgDdFuRPY8d8NQhbs0XSD98UTlwLfpVWWT90uvfvxLf2ejOhA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NYHvsnoNcz8ioNuxaWVMyPJGbA9s0yPR0OTaJWLG1XTjvYX19MTHw6Lf2c8IBpqHqXdY+SZbxUOg2ovEoiSXkpaeWB6ygo37KhDeJ9n4K4gvYqJ4X1cFtoOEllcAlG8Q/axXGvVbfpC4Nmf5sZu6DDKdP0AR8dQ1y1FcvBRAhkN9yR9pY59Sp50UaqLK14GFZIkbzYVPC1wu2Mf6BxGkpcivr3hinXpOFHAcQZ8YjRTE5F2X93LNjEilgqiI3G0YhH4CIHz3uXOjivNb8bKAB/6l0yWu2HIOkUJFxR5VG2Tp9yl5CxYGLvKKoVte+vTkjhFW57qppLki62VksW6CtvHkeX7uyVxg6z04sZC2UWgXinLA+2d84+NzpcM3QtLJFVRGkMMLoI62FSqpCDHXBEtpCksf7Vuxgz4/Ui6nZNY1AgLCYklanRs/gutxf297z/6uHKwiYQIx+pInm407ykltUnj66HNYZiMuDwDbky5lF0HRLUMbH5em0JJI5vH/r1/rAy63DYkWeyDwpJ2QdK2hQTlmIZZIko1XayDRg896Iw0FCWpdiMsGz+hBUpAUogzeZhPv/G1CGzM8FZdXg34H8s7iVP2TUDDftq/OU4+38bgMM l3X4l1/1 L5Ma09rUamtVK1Bc+BKQ1HGweHFN75ZaPeDV7TDgvqxYOlvBq97i+VjbKjFdXND70GQLLccJVcUE/nHbprbDrQ== 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: In arm64 pKVM and QuIC's Gunyah protected VM model, we want to support grabbing shmem user pages instead of using KVM's guestmemfd. These hypervisors provide a different isolation model than the CoCo implementations from x86. KVM's guest_memfd is focused on providing memory that is more isolated than AVF requires. Some specific examples include ability to pre-load data onto guest-private pages, dynamically sharing/isolating guest pages without copy, and (future) migrating guest-private pages. In sum of those differences after a discussion in [1] and at PUCK, we want to try to stick with existing shmem and extend GUP to support the isolation needs for arm64 pKVM and Gunyah. To that end, we introduce the concept of "exclusive GUP pinning", which enforces that only one pin of any kind is allowed when using the FOLL_EXCLUSIVE flag is set. This behavior doesn't affect FOLL_GET or any other folio refcount operations that don't go through the FOLL_PIN path. [1]: https://lore.kernel.org/all/20240319143119.GA2736@willie-the-truck/ Tree with patches at: https://git.codelinaro.org/clo/linux-kernel/gunyah-linux/-/tree/sent/exclusive-gup-v1 anup@brainfault.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, seanjc@google.com, viro@zeniv.linux.org.uk, brauner@kernel.org, willy@infradead.org, akpm@linux-foundation.org, xiaoyao.li@intel.com, yilun.xu@intel.com, chao.p.peng@linux.intel.com, jarkko@kernel.org, amoorthy@google.com, dmatlack@google.com, yu.c.zhang@linux.intel.com, isaku.yamahata@intel.com, mic@digikod.net, vbabka@suse.cz, vannapurve@google.com, ackerleytng@google.com, mail@maciej.szmigiero.name, david@redhat.com, michael.roth@amd.com, wei.w.wang@intel.com, liam.merwick@oracle.com, isaku.yamahata@gmail.com, kirill.shutemov@linux.intel.com, suzuki.poulose@arm.com, steven.price@arm.com, quic_eberman@quicinc.com, quic_mnalajal@quicinc.com, quic_tsoni@quicinc.com, quic_svaddagi@quicinc.com, quic_cvanscha@quicinc.com, quic_pderrin@quicinc.com, quic_pheragu@quicinc.com, catalin.marinas@arm.com, james.morse@arm.com, yuzenghui@huawei.com, oliver.upton@linux.dev, maz@kernel.org, will@kernel.org, qperret@google.com, keirf@google.com, tabba@google.com Signed-off-by: Elliot Berman --- Elliot Berman (2): mm/gup-test: Verify exclusive pinned mm/gup_test: Verify GUP grabs same pages twice Fuad Tabba (3): mm/gup: Move GUP_PIN_COUNTING_BIAS to page_ref.h mm/gup: Add an option for obtaining an exclusive pin mm/gup: Add support for re-pinning a normal pinned page as exclusive include/linux/mm.h | 57 ++++---- include/linux/mm_types.h | 2 + include/linux/page_ref.h | 74 ++++++++++ mm/Kconfig | 5 + mm/gup.c | 265 ++++++++++++++++++++++++++++++---- mm/gup_test.c | 108 ++++++++++++++ mm/gup_test.h | 1 + tools/testing/selftests/mm/gup_test.c | 5 +- 8 files changed, 457 insertions(+), 60 deletions(-) --- base-commit: 6ba59ff4227927d3a8530fc2973b80e94b54d58f change-id: 20240509-exclusive-gup-66259138bbff Best regards,