From patchwork Tue Jun 11 18:27:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Oliveira X-Patchwork-Id: 13694120 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 F00ABC27C65 for ; Tue, 11 Jun 2024 18:28:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84A956B00BE; Tue, 11 Jun 2024 14:28:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D2746B00BF; Tue, 11 Jun 2024 14:28:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5FE946B00C0; Tue, 11 Jun 2024 14:28:06 -0400 (EDT) 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 3B66A6B00BE for ; Tue, 11 Jun 2024 14:28:06 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B4A09C1056 for ; Tue, 11 Jun 2024 18:28:05 +0000 (UTC) X-FDA: 82219442130.04.B078370 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2127.outbound.protection.outlook.com [40.107.236.127]) by imf23.hostedemail.com (Postfix) with ESMTP id D96B0140004 for ; Tue, 11 Jun 2024 18:28:02 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b=HEJve3rE; dmarc=none; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf23.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.236.127 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718130483; 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:in-reply-to:references:references:dkim-signature; bh=ltSVTnfSQLBLzvKgi3YJev86956nJV0gsu1ICDHeH08=; b=Tkr47xWnAKVUHwxeUt4Y3TZ9/FzVHS3k3QDCCgpZHsWasleOAMuIQh3YXHTti5JpcDoFdE q2FHnFK+8uLG29YS1QDkg9tDk1/GOqIz2StLfY4W18GzmDQOVtwHk8VpVVYuCcuV+wYk7C hbcQvh/B7/XKWU5H4HIxvQPqA8S4nMo= ARC-Authentication-Results: i=2; imf23.hostedemail.com; dkim=pass header.d=eideticcom.onmicrosoft.com header.s=selector2-eideticcom-onmicrosoft-com header.b=HEJve3rE; dmarc=none; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf23.hostedemail.com: domain of Martin.Oliveira@eideticom.com designates 40.107.236.127 as permitted sender) smtp.mailfrom=Martin.Oliveira@eideticom.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1718130483; a=rsa-sha256; cv=pass; b=2uUrigwVD9PD43QjzU9F0ih+EH4qZF6RzZ8QgMFQxt4Z47mETwlp5CvABiqZj8E+VrLvXy BrsmQIYKJUw2EHlr67DKzaFfyn+CwdLIB6ie796YqjOaz66GPrMuWDtMJOs/KteFXzgleC wgRa2fib8xGRv0uRtFyx5aMS9TRxjAg= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aTy3VFsaMVs9IA4dnVMq1VHuRujiPjQGjQHgVIKcyPw6b+uabjIKMIh/5UenG0q8ja2R1cxV+fB2mDpdJmZgdK6ydF8n+Z/3R1tbORElAJZ5V82bek+V+szUPC3Ws7Cf9ywcQZnfmEiiKW+geTB36408WQTisJNBVI/Fx0CQlUaBQp49HIr5rBvUshzd9l8QsVfDDKslTU7igN6dO0gPwGGHiaRQnWJJWmn49lmBVotLSmbpPqa54pbCl/mRjIxOmcHuyGOwAADX73tdVCEn1fhApHIyXSyz2UEE8zkVTJ8yCbdwl7iozna+zqHfeHH5a/eOCD7jryVITvf5wA0skQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ltSVTnfSQLBLzvKgi3YJev86956nJV0gsu1ICDHeH08=; b=meZlq2UEv68OI0eWIgMUPr0STfLcz96Ewe2fcCcBYlLJSpBJno6nn1EBqNULjsGduoRrLcQ+Ot/ufMMaeMrIzpWhhOcpw+tMHCkayZVvP7PJnUr9B+xzaFhhMBEll7y45qHUsdhP8jrUI7VaYyCmjxgVnuwljSMj4oqVREG3M24gEusP2WtPqHI/8FRiGfeLI6sxywMr5d6GgfR3yGNZnPL25dttmfJl9uea8b0gCxo/dohLfVgGLENEXVW4wwiMW3QpJH2Wz9FGYZ+xFHML/D7n64pVsIA7xTLoKR8khp5W7ZfnG3i6b67n3CIr699alL8j8/75GtKX0KpouLzJTg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eideticom.com; dmarc=pass action=none header.from=eideticom.com; dkim=pass header.d=eideticom.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eideticcom.onmicrosoft.com; s=selector2-eideticcom-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ltSVTnfSQLBLzvKgi3YJev86956nJV0gsu1ICDHeH08=; b=HEJve3rENKbMbnHsMLEdUMGIApejn1xirNlUhkBn+o6RVl75vidmlG+8T7qwcXSq6H8VIRpetsF9ZJrNsdITs/prFiKGzOKX3pmHIFSeYqQjKDhH+Gx9YXsJaf+5JNO3Hx49MX4oRMCG4zPGsb5VZmEsQbIolzXKTd1N3HstWMg= Received: from MW3PR19MB4250.namprd19.prod.outlook.com (2603:10b6:303:46::16) by BL1PR19MB6105.namprd19.prod.outlook.com (2603:10b6:208:39c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.37; Tue, 11 Jun 2024 18:28:00 +0000 Received: from MW3PR19MB4250.namprd19.prod.outlook.com ([fe80::3280:d8d:de43:6376]) by MW3PR19MB4250.namprd19.prod.outlook.com ([fe80::3280:d8d:de43:6376%6]) with mapi id 15.20.7633.037; Tue, 11 Jun 2024 18:28:00 +0000 From: Martin Oliveira To: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Jason Gunthorpe , Leon Romanovsky , Greg Kroah-Hartman , Tejun Heo , Andrew Morton , Logan Gunthorpe , Martin Oliveira , Mike Marciniszyn , Shiraz Saleem , Michael Guralnik , Artemy Kovalyov Subject: [PATCH v2 2/4] mm/gup: handle ZONE_DEVICE pages in folio_fast_pin_allowed() Date: Tue, 11 Jun 2024 12:27:30 -0600 Message-ID: <20240611182732.360317-3-martin.oliveira@eideticom.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611182732.360317-1-martin.oliveira@eideticom.com> References: <20240611182732.360317-1-martin.oliveira@eideticom.com> X-ClientProxiedBy: MW4PR04CA0113.namprd04.prod.outlook.com (2603:10b6:303:83::28) To MW3PR19MB4250.namprd19.prod.outlook.com (2603:10b6:303:46::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW3PR19MB4250:EE_|BL1PR19MB6105:EE_ X-MS-Office365-Filtering-Correlation-Id: 78715319-eaaf-458b-c874-08dc8a44392e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-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qj/7KpkrhaDPpS8Adl/WVONHo0RfgvAoDQdRTec8nospGiOo5I7rp5WFHlxEVlSd5s+sdv6kAk9KfuCU6nLFUIxNFSAfOnet1fFe7vh4DYIsCtm/z2/qMQs0MKshG9Q+w9HrLpRRNNrqYEVJtZGSovF5UbW2HBGvaTCBys7LczK42lbiqPhQBIBco+Y+6C0wa60hbRFiXnuMpmJzRR6+4nrw01Tc4PALIl6C/evMR1gNgbfP9gv38mQAH1rvo3aMRxYRf1cZNoAX/AaWem74/WfdNtAnpPi0tKnEJa7Oc65HeYQI5rvyF6wffJ07vtenUWu0dbqjnl0ZAFDwy0M1qeFKN9jC2g1TvMBsGa/U2Gb06elXdZvTImFsqldRpRRzXBYdUlGhazYlUNrrqK75a/Sihls= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR19MB4250.namprd19.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230032)(52116006)(376006)(7416006)(366008)(1800799016)(38350700006);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: snBOHwcygg3ghtGStEnwZeut5s/ucWDTffUeYOj0/XiePGJcChY+GeAguWriPHjMft0sYKlz0fngc2dvxIlKny8GXIS7shkH37g5jynub55pM3o9byVgYui/kEqn1egQi4x0TJRJh8hV73MZa9Qs/kt/jlq2PBuIQrgVJ+gTGg9jdQffXGU4qoN54mmFAwNIuIXtNFUhqd1wxmjgTui2lNbesL+h0TzT4/lmRd6Np0Z5hzhJ14aqyx4VWR8QUqfe98dNA3MUrmerr/+5mBve/0Q3i3P658tiDlDA3/29+fGrobSlxMdygWbinmj6kX85AB3JnM2xh40vnji3Rco8vNVCjpyrv+EMGuZBB81nnlLgf+HeUpunT9xcCha0pmKcz1ZjSPvgNCjkNGlT1qzhrvgfSr3n4+ieR7RMW7IaiRh0QBbnusVWXjR9MIdGSF5NMTLVY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VcnuLwEO5Oq4YnY5sGjAStYMqTNsyWCB+yBlkSSgEGQyGM1FaJv/A/Dh7SFIi3T8lZ9SYauFQT3LFv/ITGrsqqG6H8kj2K6I1j+1lpOGzripXR9+tIRr03db0QQHSIM= X-OriginatorOrg: eideticom.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78715319-eaaf-458b-c874-08dc8a44392e X-MS-Exchange-CrossTenant-AuthSource: MW3PR19MB4250.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2024 18:28:00.2550 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3490cd4b-0360-4377-abb1-15f8c5af8fc2 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 28F4sPdzuvBC2Gu7EfwX1vd1OefLwuatUANqLPCkgcNSXLk/1YNGYZcFKH3LbMYIFwF0Skd7GwqtwXn8w/S5WdIvm6Hl160g+3/tnL8/PuQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR19MB6105 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: D96B0140004 X-Stat-Signature: hs1h3534i3hnqbhpjsfrecyy4pf75uid X-Rspam-User: X-HE-Tag: 1718130482-455832 X-HE-Meta: U2FsdGVkX1+LsIhr+HuPvRdbzWI/ti81lazDb5IZ1ZnxsO/mxQA2KZ5sMogkzpQSgfA0ErfVAUPqf01LUQw2QW5a352flPt3l4Zqw6yl8z+CWp8jxdjPCjLvK05PxLdjrR+225zN8GHjf2fmm4C+du8hzaeXSyjlr+YeA73zy3TFcIdjE7MpAfGYrsb9zqk8Z8RGvd3R2CdRsXt5keT8d1USnv5sHumiI0Ob2MbR+xyQWP6G0D4Clc+XaJaUbH1hxu6J2sIrknJ3O0rR30cZpAwymPuwH0/PxKrGBtOHFkanlZ02dOl95ztqwSLAmP+gd0a6CsTi2TP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Wvx7CaP7iGk86Uj8= 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: folio_fast_pin_allowed() does not support ZONE_DEVICE pages because currently it is impossible for that type of page to be used with FOLL_LONGTERM. When this changes in a subsequent patch, this path will attempt to read the mapping of a ZONE_DEVICE page which is not valid. Instead, allow ZONE_DEVICE pages explicitly seeing they shouldn't pose any problem with the fast path. Co-developed-by: Logan Gunthorpe Signed-off-by: Logan Gunthorpe Signed-off-by: Martin Oliveira --- mm/gup.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/gup.c b/mm/gup.c index ca0f5cedce9b2..00d0a77112f4f 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2847,6 +2847,10 @@ static bool gup_fast_folio_allowed(struct folio *folio, unsigned int flags) if (folio_test_hugetlb(folio)) return true; + /* It makes no sense to access the mapping of ZONE_DEVICE pages */ + if (folio_is_zone_device(folio)) + return true; + /* * GUP-fast disables IRQs. When IRQS are disabled, RCU grace periods * cannot proceed, which means no actions performed under RCU can