From patchwork Sun Oct 1 16:00:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13405429 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 4982FE748EE for ; Sun, 1 Oct 2023 16:00:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7886F6B018D; Sun, 1 Oct 2023 12:00:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7383C6B018E; Sun, 1 Oct 2023 12:00:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D9256B018F; Sun, 1 Oct 2023 12:00:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4C3866B018D for ; Sun, 1 Oct 2023 12:00:13 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0E31CC01BA for ; Sun, 1 Oct 2023 16:00:13 +0000 (UTC) X-FDA: 81297354306.26.60E8372 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by imf22.hostedemail.com (Postfix) with ESMTP id 1CD70C001E for ; Sun, 1 Oct 2023 16:00:10 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="c8Vj/kPv"; spf=pass (imf22.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.128.51 as permitted sender) smtp.mailfrom=lstoakes@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696176011; a=rsa-sha256; cv=none; b=Fk5k2Riqe1JEIOxjCN1s87Fztbp22JW9l+JlH4VhB1ZfsBPtmxmu4EYxUWRCdYYTe9DUFx O9AhYV3sX6zC5yOvymoxb3xotzYIuHOIUUblwIFFirt6wzz0l5BXIQVUrgwCLyUQefJKn+ iwfkRI9DGIjtl+BlXjUuafso9qKgZOo= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="c8Vj/kPv"; spf=pass (imf22.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.128.51 as permitted sender) smtp.mailfrom=lstoakes@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696176011; 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=qbQ2+MNx7iQKlTg6jhWJ9e8ngVQbdAZdbk2tukIrGRw=; b=I7F5aJ/mSKRV25W0Pgu3i5NJd0Av7HYBvX6rRiJgeuiMZFcSsqLViT5e3FaWMCGxS26x3Z 0jtIgRM7c6ETEl1wxaGPgpohCIUlYDKhlGoR4rpZb0Upm/1Yaz24+hlGK9brU8k5NEKiRX tlCjr/rinw4vvewzjIBuZSgD3graNto= Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-406402933edso73933115e9.2 for ; Sun, 01 Oct 2023 09:00:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696176009; x=1696780809; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qbQ2+MNx7iQKlTg6jhWJ9e8ngVQbdAZdbk2tukIrGRw=; b=c8Vj/kPvVizzwnIA087IkyO/GWcbr7gFw8dGoS1Om189lNCCBr9yj9J4ztYMTzgb2k x5K1f/CCGvQtEmJVQUD4uGtxtrRmY/72r8cQzQN3fOTTTye0bK2iJq56+fS0FRVmFBkt m4pw82RC/WwXZRbhY5WrrMPULCc5jucNfIj9ECbWOZjhzFK/b8G8fr6OURpeFbIH4Wei k/1fHvbQg6kvk4Cp6Kmv6HOhFnSpeqTESpIF6tTr5u2Ja1yRUS2lgpwBwHibOzVrOfcM p687cvu3BdzleWaceGGG9ZxxbtTQQTJPC7UB4jtT9GiLElCLeZFYdwpoh5iJQDxvo9U7 +N9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696176009; x=1696780809; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qbQ2+MNx7iQKlTg6jhWJ9e8ngVQbdAZdbk2tukIrGRw=; b=sWVW/Y+YasoeaCcXHiWuq0p/tn1NsM4QDIMVMR7zU1ziB9C9evv4ldfBZ2CRLWG/gL 7BH5sCTcEVawQvOMjfrFx3m+maj8ExvtxZHeNkChAOE+tu/TxaGhjGzj8lq2fy6/rEuC Js8KpKH0Eeddx5nFe5fg5E7bOc5J5ER0O7HVPcuLZFAQgU1BO2HPmTb6B+m0vHLnyn6g zQkidORvjNNudhltFuTkOt4KMZIGCzcRhYwYhdXCXdMxNBF0a/2gySiD1/zTqXnMksfY +MnGHr7mJdYG9kHd5BWM3y8CO+QiMHx6t8WB0iuVJV5QaInv8t5qi92+CFz0/WxmvrzU PQdw== X-Gm-Message-State: AOJu0Yw5faBsR0PS9ow6UpuzTTmQiSrDiE4UYT6/uDRBXJkl8lkuJJP2 Hy3jTeRslx9zt0gETjQ5tFBX7kTo3Tc= X-Google-Smtp-Source: AGHT+IGsBTJNp2/AtL0YHzJ0LwsCxVV5d5j9nxOnHW1suaWojSlQ/S2cfF5NquVDInPTiVFlnC6r1A== X-Received: by 2002:a05:600c:6027:b0:406:535a:cfb4 with SMTP id az39-20020a05600c602700b00406535acfb4mr7987766wmb.1.1696176008738; Sun, 01 Oct 2023 09:00:08 -0700 (PDT) Received: from lucifer.home ([2a00:23c5:dc8c:8701:1663:9a35:5a7b:1d76]) by smtp.googlemail.com with ESMTPSA id s16-20020a05600c045000b0040536dcec17sm5487695wmb.27.2023.10.01.09.00.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 09:00:07 -0700 (PDT) From: Lorenzo Stoakes To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Catalin Marinas , Will Deacon , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland Cc: Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Oleg Nesterov , Richard Cochran , Jason Gunthorpe , John Hubbard , Arnd Bergmann , Lorenzo Stoakes Subject: [PATCH 0/4] various improvements to the GUP interface Date: Sun, 1 Oct 2023 17:00:01 +0100 Message-ID: X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 1CD70C001E X-Stat-Signature: x86uxwzym3fi7zntqcq6kahtnp5bpf6s X-Rspam-User: X-HE-Tag: 1696176010-582347 X-HE-Meta: U2FsdGVkX1/a3ZMfP2dXukxGcrkU8jIqFRwbiqxJRKX4uDbCATU5LgydEKy0Pq0Fs5IkZNrpwjVAkaKvavyj4QIh3E6D2ULRL5PH7qi91kfxdC+1a+0Ird8SAn1vm73gp+tNYgasKirbRW+GjDt498VkJNoP1Y4NyrY8n4IhiKbBKDU6PnvwbF/DWte60bqqclY8BbetM2BGZLi6rYMHrv5q5mQM9H+omyUvNOqyhHtCO6LZ+HRHfUnkRVk9OoLlXOlnzwaRyl4x/RzRehhP8JtnXhI3lddLl8U7A8wKckc5bbd77T0muh/bPEUUHV17PGNBun9+Se6nu9yMGWyzh1eTE9GQ3Y5CtXHi76P4I7SiifjtXRljoxpLH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ner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: A series of fixes to simplify and improve the GUP interface with an eye to providing groundwork to future improvements:- * __access_remote_vm() and access_remote_vm() are functionally identical, so make the former static such that in future we can potentially change the external-facing implementation details of this function. * Extend is_valid_gup_args() to cover the missing FOLL_TOUCH case, and simplify things by defining INTERNAL_GUP_FLAGS to check against. * Adjust __get_user_pages_locked() to explicitly treat a failure to pin any pages as an error in all circumstances other than FOLL_NOWAIT being specified, bringing it in line with the nommu implementation of this function. * (With many thanks to Arnd who suggested this in the first instance) Update get_user_page_vma_remote() to explicitly only return a page or an error, simplifying the interface and avoiding the questionable IS_ERR_OR_NULL() pattern. Lorenzo Stoakes (4): mm: make __access_remote_vm() static mm/gup: explicitly define and check internal GUP flags, disallow FOLL_TOUCH mm/gup: make failure to pin an error if FOLL_NOWAIT not specified mm/gup: adapt get_user_page_vma_remote() to never return NULL arch/arm64/kernel/mte.c | 4 ++-- include/linux/mm.h | 18 +++++++++++++----- kernel/events/uprobes.c | 4 ++-- kernel/ptrace.c | 2 +- mm/gup.c | 16 +++++++++++++--- mm/internal.h | 3 +++ mm/memory.c | 7 +++---- mm/nommu.c | 4 ++-- 8 files changed, 39 insertions(+), 19 deletions(-) Reviewed-by: Arnd Bergmann