Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp423980lqm; Wed, 1 May 2024 05:10:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWKqrz8tHC8XtDv9Z8Evy6kbrhoDdDqKbwGXTTvrlse0K0+V9ufd+Xpd2RnIKjzH0daH1Ii6150b1OAQDLXFu63/j6Ax3koYj8C+pypaA== X-Google-Smtp-Source: AGHT+IGJFqsov4xYKcOmhnjqfcTYCdtmQUmZof7VFvj8OW+qdDRjFEKpNt9NlxgYLR08kOhKku/p X-Received: by 2002:a17:906:fb8e:b0:a55:609a:d6cb with SMTP id lr14-20020a170906fb8e00b00a55609ad6cbmr1614555ejb.33.1714565450683; Wed, 01 May 2024 05:10:50 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id o13-20020a17090608cd00b00a587ba51bbasi10324843eje.433.2024.05.01.05.10.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 05:10:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165213-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=ZAZF0PbY; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-165213-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165213-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4271E1F2376A for ; Wed, 1 May 2024 12:10:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D71F784D35; Wed, 1 May 2024 12:10:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="ZAZF0PbY" Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2067.outbound.protection.outlook.com [40.107.93.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 460774437; Wed, 1 May 2024 12:10:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.67 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714565440; cv=fail; b=d31Zme5lupzFu3Yw/8R5XqYv7uPNQkRrauyXAtxOw5V6QVLF98l2/NnXH2bZDZCmlTumkL0cpgRdprWTX6g7/wOSZHA5TH7Upsi7ns/leGm6uw2GOcSC++qZ5VjJb/vUH03+1FDAcLyvcWlv6IrzxOpmhjmp3mRChvwdIRZhAbM= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714565440; c=relaxed/simple; bh=6jBngJ+iy2VGj/xWmxGjLQ5lnLrx4MpBoH6W9fT9QnU=; h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=gtEIaVfkZJqvVgyu+tN4ihw1NXVtibaUx9BVPXxNQ0w8wbH5gqWnf6GZYOsahHrlNM445RYZjAGlXfj5fRm3A/JMo02oOSE7hWRQTW7MOY9Ywt2ezBZeQLc416KwL7gZBWPJP8t7SCY47E4wxnOeLJmZ7af4WnZ5Cwp9ZJ+CfAI= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=ZAZF0PbY; arc=fail smtp.client-ip=40.107.93.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ns2qT7Yx3IClk6eq+mWQfjg/lQvVxQF/Hevhy02QZcZw6Uosb+lJjy8H6ARl7k+WZoMJT4n/gt71fdQVz9JgTN/dYjZdjxEsIHZKdihSlhvic7/9PCHHPAmGEdqj2R74EzMvDzDX7kCnhM3bhTPnmhgY02SxAG+F8B7DQPaEz3tUGDYqBQcK6fPrCNUDiP48nXD8Nn9aDFKWerOEBC4fJ7j0vHB9Sf0TXeyf0f+ej6QGnOY/GpmTCi5lfii+JmFVgXG5VA+yKEqJrQZ/sQb2bR9x0+70muxD6yBibZkmIANftnI7KCfA3FucV1InX2WJv0GRLAIa8gU+BgulO558Wg== 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=ZnJkJO7orUqyoqrS/FjEYW9dopHDcxHV/lfxRSrGFSs=; b=LndbW8qIkZhXBXrAIp/kJ3xBVkfLEbuKV3gVyG1AZIhsx7IgELjsK5ehIjkaJxoITsqPjQ2e9UKHkv2Gor61mApFKKSL616jjZk3VqmFjUKh+UsXUGdzesUsxCQh/jqkI7M763+JXV/JJzhjN+skNFR49tD48UT5jJ+JIGsTGULfzUYEMINKi74wcz7P2YE4lCNpOJbB1K/V1YX3k+CewSgGBapoB7Qk8UIhTAEsm40s28ZwnPosqS59HTAWocnuYMKhMSexuGuxCGRoEHGGb0wBR0jck6mw4+qJyOfKD54l7BhlIiEE9Xu0BnzVoZPIR6Sb3TcSDvV6Mk8O7fhFdg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZnJkJO7orUqyoqrS/FjEYW9dopHDcxHV/lfxRSrGFSs=; b=ZAZF0PbYpAukV01czbfEiKIvGruRHvOrrO3Lx4u8/akmNIfMbKZtGWtEC5NR+iB+8NuiJV316fIFsMnonRAs0iMlwwjY+Nhmgv9BZ9F0rf3e8l2tpX1UmNWxcvXuINZvfco7i1PrvA1wKgMawcMH/OOBgCMn1GDwGk6Ikq3TuGguBkynAtqiIdNZ3JdUc/h5FzsDI/2tMhUm5EqEV4Ue0eiMe5bEF9hBTG7OSBTSE3AovlOh6tPrceWOBfmyXCtkb++vRsc9j+HoZNoL7o+kN852Cz/ChSYsfwff2UAZLp1MXVH7ofMKaCZvqagBnQaszfhcYWwY5LGrC3FB5LjX0g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) by PH7PR12MB7283.namprd12.prod.outlook.com (2603:10b6:510:20a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.35; Wed, 1 May 2024 12:10:35 +0000 Received: from DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e]) by DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e%3]) with mapi id 15.20.7544.029; Wed, 1 May 2024 12:10:34 +0000 Date: Wed, 1 May 2024 09:10:32 -0300 From: Jason Gunthorpe To: Christoph Hellwig Cc: John Hubbard , Andrew Morton , LKML , linux-rdma@vger.kernel.org, linux-mm@kvack.org, Mike Marciniszyn , Leon Romanovsky , Artemy Kovalyov , Michael Guralnik , Alistair Popple , Pak Markthub Subject: Re: [RFC] RDMA/umem: pin_user_pages*() can temporarily fail due to migration glitches Message-ID: <20240501121032.GA941030@nvidia.com> References: <20240501003117.257735-1-jhubbard@nvidia.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: MN2PR13CA0009.namprd13.prod.outlook.com (2603:10b6:208:160::22) To DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB3849:EE_|PH7PR12MB7283:EE_ X-MS-Office365-Filtering-Correlation-Id: ad664f03-e733-4e47-5f08-08dc69d7b41a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|1800799015|366007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?mtAEUFuSCuTQwbFH3joNXrkHVodfkMxG796g80mnGMT+bGnSyeCYb1sQZpX+?= =?us-ascii?Q?ch5xNtgdwjLxocicSl2zJzXbiIXqqI3bI0O7FV3jDo792onPjbiq3lFWmIE0?= =?us-ascii?Q?D25dJ9yoj3sLUCFE1hJ5F0MLTXQEXDnEUHfrFEy+V+qQ8QGF5SYQWHmy2qZz?= =?us-ascii?Q?YmP+HRS+Qxcfdqa1iGF7uFz+8OEaRpHGHJgqZ4e/EN4Z9qQxVU013qacHj8e?= =?us-ascii?Q?8SJV1jv25sqOHf8ng9WgdiKWMHHp8MIdhBxkcbZF5Sl+nUOVyEKDbCDtMcla?= =?us-ascii?Q?j/RDcg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yQwbH8Ex7zXF?= =?us-ascii?Q?U34bYqdNo8/x21J9tlCXTkGDk7IyA605dGY2hwI/iBOqOwNJ0wPmqgOaRwRY?= =?us-ascii?Q?W7sjTD/lCn7J8gjF+c/akSOF8q3UWHwuRzEGcpQoMA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3849.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(1800799015)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?mDcEyuKOVjIAERu9Qxo8GmTEsJYBGtc/cDf06KkCC9JpTmGG7XgM97VH6zbs?= =?us-ascii?Q?Mwk39pjsAL5kZXOXp0KHliu4HEyP+EoO2iAvmedD4ezpp9w5Dk4Rn62MxvBE?= =?us-ascii?Q?l91uICDVp0gQpHPgFnC7/+LYUzRGG7PBEQAQINqPADSruQ3DkMLSABrNsWCF?= =?us-ascii?Q?xwVsF8ERED593Q0u4qyTauh0ufA/juSMFLr6kqkFAjUSdXNoeu9Jhaqsm3Lr?= =?us-ascii?Q?75ZGVmDH5hCG6IFp3xQDwHqMRL9m+DIOUSbs17ETfI+jpP5c27lXXFnjyolQ?= =?us-ascii?Q?YsxLHeR2iWddh/8nlNJ3DNBPbPv+7BDuc/t70fHkJXXs0pNlF+9G4VfWnfoL?= =?us-ascii?Q?TpD1ILLXE26OyyG7SSoXxIm4NgsdtdqYGnUkhj68WYQ55EviivG6ZOcee79H?= =?us-ascii?Q?ktDxippODFe+kx2ItaWX6qIjLOQkRG/FIEnNhulwu24kH7wWMc8MgvK60Xdf?= =?us-ascii?Q?QjFqdMYB/dwsV4eDw4SVJz3I7vZLZoEBVl8elJg04BEcFXAO+/g89EtlPgEM?= =?us-ascii?Q?beFzmw9vvwXstXyVCcDN3gBiZ9iS9GlJ7CPO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ZHV7MnTqxzyYqyMLwDXlDZE6FtrsUcxIu2ssfixSMUg0rC1U?= =?us-ascii?Q?OEkhnmLem71wigsApUvya33kFIlUyvs84c/PZt51Zn0PPQVov2GTzdE0div1?= =?us-ascii?Q?TTJqaYE65A5AzQGEnEIclox+czBaXFQEKI9aMeR+?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad664f03-e733-4e47-5f08-08dc69d7b41a X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3849.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2024 12:10:34.1953 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: V+r7PVpf1xn4kawtTN5uNQ+nybR9mNnPhUukwuhUcVqjbZxhSU+Ipm0bS4SPBbon X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7283 On Tue, Apr 30, 2024 at 10:10:43PM -0700, Christoph Hellwig wrote: > > + pinned = -ENOMEM; > > + int attempts = 0; > > + /* > > + * pin_user_pages_fast() can return -EAGAIN, due to falling back > > + * to gup-slow and then failing to migrate pages out of > > + * ZONE_MOVABLE due to a transient elevated page refcount. > > + * > > + * One retry is enough to avoid this problem, so far, but let's > > + * use a slightly higher retry count just in case even larger > > + * systems have a longer-lasting transient refcount problem. > > + * > > + */ > > + static const int MAX_ATTEMPTS = 3; > > + > > + while (pinned == -EAGAIN && attempts < MAX_ATTEMPTS) { > > + pinned = pin_user_pages_fast(cur_base, > > + min_t(unsigned long, > > + npages, PAGE_SIZE / > > + sizeof(struct page *)), > > + gup_flags, page_list); > > ret = pinned; > > - goto umem_release; > > + attempts++; > > + > > + if (pinned == -EAGAIN) > > + continue; > > } > > + if (pinned < 0) > > + goto umem_release; > > This doesn't make sense. IFF a blind retry is all that is needed it > should be done in the core functionality. I fear it's not that easy, > though. +1 This migration retry weirdness is a GUP issue, it needs to be solved in the mm not exposed to every pin_user_pages caller. If it turns out ZONE_MOVEABLE pages can't actually be reliably moved then it is pretty broken.. Jason