Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp5382921rwb; Wed, 17 Aug 2022 16:56:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR7GLaXX57QLzRnYuTOmDjvnxo0gJDYe3Ou/9AD8AQR6TSyeouROtcItCpaQogCn11T8Eqyj X-Received: by 2002:a17:907:28d6:b0:731:5d0:4401 with SMTP id en22-20020a17090728d600b0073105d04401mr232085ejc.765.1660780619241; Wed, 17 Aug 2022 16:56:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1660780619; cv=pass; d=google.com; s=arc-20160816; b=fT0kfoO6xcAbghQUyuy9QMloSKGbEZJOD69z9qPwC4LLSRkl5Q2bH7BMzkD/exp/XY XybnQss2h3I29IyDgn8WR3DbmgwCmjYFf5LmnRl4zzUA5V/M5Fm4loNAgzcizelj18Be b3ll9UceasT0NzKUZjHMYyCMcpNhEORMkZVECFZvHUqmvvXtredxD8ffzX0gy2Rk+34K tgMX1Bq2r3XJcdASS/hBJJIX/y41eXVDxveey71nBh1g+55grYSNj6x7SHv7C2gPW0Aw ZsEn9gZbKBO9BrJMZbpsfZqlNDlYo9nKakzhXZPfG0PTdCW0qosp/8Zhb/xleT3tYlCw Qfcw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:in-reply-to:date:subject :cc:to:from:user-agent:references:dkim-signature; bh=/VMOS0FjmU5+p9IyJ/437gcbGEStjAklyhod3mlZ9hY=; b=lvQ78lNJ7Od7EHhRDeCNThkgqY2SQtlGDBXGH9G0sSVgdOe7mYvcAbBnCE7K/kE+VQ 8TiFrtORie/7SUH4KMN0FSPPfIb+5Bt0TZnUn4yK9M+ePNApXC0yR3572Tpe2ZpV8FVU GbmLISU2YWYh4492ri7zwEFzRt1Dyf9PdHzusH3bQfW32oSL/66Gn+w1JSpZhy+nvuTU qh8AERGHm3a6EjJTzYD3mML1W3fA0Q/E275sPYCIFluf41LmTibbjF6aJ3MWvyMeLw7D m5+SBRWg6BH2PMWrzIfmjWHbEmcHUE26YfQAc15epiX6icGbv75WNx+9SHKmpPH0Ttww tXDw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=VHFlNdBV; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v22-20020a50d096000000b00441d115ed67si83603edd.494.2022.08.17.16.56.34; Wed, 17 Aug 2022 16:56:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=VHFlNdBV; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242447AbiHQXgB (ORCPT + 99 others); Wed, 17 Aug 2022 19:36:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232063AbiHQXgA (ORCPT ); Wed, 17 Aug 2022 19:36:00 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2082.outbound.protection.outlook.com [40.107.94.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FDE552FE3 for ; Wed, 17 Aug 2022 16:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Iy0YG1+9syXx5BiAji+iMFOUQb4LhRRoxlZkVbvJBJRoWuS1Q+lrgeY88efkRwHsJjFWYGPtvHiOc442aRCGlBoeco4BAp59sSE1kzYoyzwP5wN69HV3GHgBdWcCqi0qUd1HB3IKKVUaE3zV6Lz4EgzjOT24NE0J5+8z8tP4NL2OaMcHHr7UMFAw/fWyb+s+0dyjixp9VEWdiygLHUWZYVRfMkApM5uOxvJSPTVGKHpZOK+4D0lzatXNh+0YiES8gZNq3qw97LdaLD0OAG3clnd1tG9XUfG8yVZHWB1oxjttATqsHC2ES7iAtPurM3Oanl/QEcbWw5HG+5Hgsg06Ng== 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=/VMOS0FjmU5+p9IyJ/437gcbGEStjAklyhod3mlZ9hY=; b=H0wzSaubuSf5KfEZYKoRRaoCqpsFkPV4TXozt0e4GdQvoQ3cp1QsvJnyL1rp743bY7PKxaY0mo3MBZZz3iXoKbj9QVoi1yiD7JbnvrZOLEVK6DYR66elcLhg/Yib9Cgc4D5p8e8X0K8qt/6Oq0nxG/YJHUtRrWm+vRg/AKb+sBWQ1HrKQ21UDDJ4g1hE9odnQzSci8LnxySIuCuIiruj8w5l8QuEjdGY2FLA8H1kKKoOwlLaDSRNd1fZMuy7utVuhVBVYwXFbei5lPG3HsX7sk1e+GsHFKqax/8f5XqxekeJOqZBwq8uAm4vJUQixbBwFwMBOiqM/KtX84VfuKlQKg== 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=/VMOS0FjmU5+p9IyJ/437gcbGEStjAklyhod3mlZ9hY=; b=VHFlNdBVIf51DA0m8LFDoWvnRBiERCRyULU2WXhdsfkyDfv42Q/n2tXHFbMDVWCTRFdlXfInQUTnV20kh6tb80J3y4ejhuL0udMX4YlKDsBBNFyiIbvBUI+2FMK2Ofjq0VI2L/DJhhHKvqLZMdDbSxbUdmycPvNlrbxD1HOAg1+5ZHfgq9H1N5HYHBeyOF6gC4z1yhI0H/ifmnhwpUe1yCV4Yvgnqa4qakHPPiPP2dmzO0ptA0VYker+dYNrCTX4Xb/Z8W4X5caoBoFNnRoAD0nqIV736a4tss2+T3ruy7q5QJszhan/6AsY1IOUI93fQGcrqjEH+7Rg3rC/8ztJxg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) by BN6PR12MB1794.namprd12.prod.outlook.com (2603:10b6:404:100::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Wed, 17 Aug 2022 23:35:57 +0000 Received: from BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::eca6:a4a7:e2b2:27e7]) by BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::eca6:a4a7:e2b2:27e7%5]) with mapi id 15.20.5525.019; Wed, 17 Aug 2022 23:35:57 +0000 References: <487960bf67c7273ff5606c76f73bb51271bc7b90.1660269441.git-series.apopple@nvidia.com> <6b61e9bf7c65f78524db32ba3e65a7eb6b8a76a0.1660269441.git-series.apopple@nvidia.com> <87edxgvixy.fsf@nvdebian.thelocal> <87wnb7tycb.fsf@nvdebian.thelocal> User-agent: mu4e 1.6.9; emacs 27.1 From: Alistair Popple To: Jason Gunthorpe Cc: John Hubbard , linux-mm@kvack.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, "Sierra Guiza, Alejandro (Alex)" , Chaitanya Kulkarni , Dan Williams , Felix Kuehling , Logan Gunthorpe , Miaohe Lin , Muchun Song , Ralph Campbell , David Hildenbrand , Matthew Wilcox Subject: Re: [PATCH v4 2/2] mm/gup.c: Refactor check_and_migrate_movable_pages() Date: Thu, 18 Aug 2022 09:24:28 +1000 In-reply-to: Message-ID: <87k076tpd1.fsf@nvdebian.thelocal> Content-Type: text/plain X-ClientProxiedBy: SJ0PR05CA0139.namprd05.prod.outlook.com (2603:10b6:a03:33d::24) To BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f3a6358c-d3e4-4aaa-b885-08da80a93c3b X-MS-TrafficTypeDiagnostic: BN6PR12MB1794:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ac4qLezlBz11jtvW8d2gpy3I2xauA5LUB2+x0uSnIKQ6oWITMDcIp8/fChjNFV3pfkwmFol3cpRwq/4EPllfgVAg2zN2pep2SuMmIGQbC8VYpxFuh5ehiZSTPYvoYfl8akdbIXwZTSdA14dLZyoPuxoJL2qyClDHdrPXx3CCua4etObBl9/bSZSv3dAXrjH36ReOYHgEW4zMWVmMbT/GNlnjqXm1PZP/Cm8ObyoBCphPEB601HKH1JoElGdYlq6jjQevgluwsgTU3LioYOi0R66Cn78sZ6FzdwU0M1ADjnzTmRYO3KPVyR6+qTsKmIaefojg6CPY9zK0NHCdJcqoRrBrL0WDnXw0l21F2RFAgkOLPElIIvsRYqo+0WohLKq9r372ajFwubNS64H7Xbjm2j9L4XDuQAGnHvMhAnA33CjLZ+Kg+XVfWcTzRVp8x2ZciYiOaPHxfAIxvo42dgbxkRSi9VIK5+5H9X6EYbGoxnVT71aPHP09gXgkvtrOT1zHToFtjXzGXOGAGWK4yJmnJiqVgHqrjMibpW87w3EVJL4dXt7aeGUxHAN9XCXEIoLnWbfnzvM8VNG7CCMMqKV0fn7Q2ogGmRObPqOxn4F6k4K56uXXA4eb624dHwAbr66w9IhGSFLWMeCfFGrBFrklrbwNf2o0WTqDXboHz/6R8fBcJ6+3UPCiHV8flcTmY7trE9j3AXT1Fntr5Efov53+gQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB3176.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(396003)(39860400002)(346002)(376002)(136003)(366004)(5660300002)(6862004)(6506007)(9686003)(86362001)(6666004)(41300700001)(26005)(8936002)(6512007)(66556008)(66946007)(66476007)(478600001)(8676002)(316002)(6486002)(6636002)(54906003)(2906002)(4326008)(83380400001)(7416002)(38100700002)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?49femT3W82mYpNttyOZ4vfl6RJFbQ5rQajrDYJYGIh6SF7lHPXKsGIuUS8BC?= =?us-ascii?Q?la63DcRGFArIeU/ghTDCAJX6kVauUBudBnmSyIQzj4Mj3gnjtXzPtuJK7WlJ?= =?us-ascii?Q?OfcclqoK1vECQcuLlLQ7oZ/hAsl/4O5b8iUVf7AYJ6D25bcL1kYNNcDm6Ljm?= =?us-ascii?Q?tImK5Soyw73rnFAhH3Jx6UxXxRJwAS8H15D1zYs6qB2q0QA6mmKGIvsXTdci?= =?us-ascii?Q?vqklAmkI8rjFWuZSQmAlOJ49P/SU0qodxfYLcGsTHK8ncPDGh5svYd8p1FVD?= =?us-ascii?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4ep6p4W44wv5e?= =?us-ascii?Q?CIV4le1jk2/IKh15gGL8FZ5pB2IPoHpl8fozL6qtpd38pBc4PUw9rE6Ef1Ql?= =?us-ascii?Q?UH64C2hpNIbpvE/PkXKI6Ytl3ccXsGH2ea35+SwuQCmg5BqmktPwDojj4LL4?= =?us-ascii?Q?0YtCsXvCKy61kefnEl7OTZ+UdTMDtksXl0bfXd4CcLnlsCWk7zY3jj1sOLpU?= =?us-ascii?Q?hH64Wip8fyFfBBu0kHA4WwIPkcB+UIFnIqzp0vXboIVUfbK1vZipylBEO7tn?= =?us-ascii?Q?CB62spdvyBd+/5vtqCV8Da2ucV3QtUIXiP42SaOil0wOE5FbfZAZ7b/vgTtz?= =?us-ascii?Q?oKN/BatkHAt/j35m61fl4vgLXyjrTFFYbF3NcdwKUv2ymfEKC8iwB31e4gii?= =?us-ascii?Q?Pl7bNxZiMTKIKC2KiiClGHfdJmxyMdlqfzDgMAb0?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3a6358c-d3e4-4aaa-b885-08da80a93c3b X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3176.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2022 23:35:57.7221 (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: ifAjRnMxSEmXByv5cPp43D0goMAsy1Fy9rJPWwa2axW60ZFVpVzLCtfcKyiGZE1YWirwmxTyA2vgTR/JJasnbg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1794 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jason Gunthorpe writes: > On Wed, Aug 17, 2022 at 01:35:12PM -0700, John Hubbard wrote: >> How's this look to you: I agree, I think all the refactoring left this written in a weird way. I was going to suggest this though: collected = collect_longterm_unpinnable_pages(&movable_page_list, nr_pages, pages); if (collected == 0) return 0; ret = migrate_longterm_unpinnable_pages(&movable_page_list, nr_pages, pages); if (ret) return ret; return -EAGAIN; Which IMHO looks at lot more normal and sane than what I had. >> collected = collect_longterm_unpinnable_pages(&movable_page_list, >> nr_pages, pages); >> if (collected == 0) >> return 0; >> >> ret = migrate_longterm_unpinnable_pages(&movable_page_list, nr_pages, >> pages); >> >> /* If we got here, we have some unpinnable pages... */ >> >> if (ret == 0) { >> /* >> * ...and we successfully migrated those pages. Which means that >> * the caller should retry the operation now. >> */ >> ret = -EAGAIN; > > return -EAGAIN > >> } >> >> return ret; > > But why return 0 from the helper function in the first place? To stick with the paradigm of 0 == success. Ie. migrate_longterm_unpinnable_pages() successfully migrated everything requested. I don't feel particularly strongly about this though - happy to return -EAGAIN directly from migrate_longterm_unpinnable_pages() and just pass that return code up the stack if others think it's clearer. > Jason