Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp5236228rwb; Wed, 17 Aug 2022 13:45:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR5P2B/I+9OuB5sLpx/BspnwsiX96JfrRJCLRuPuNIfsUnln/O1Jlm2oNbiJ9lKb5cgBoXus X-Received: by 2002:a17:90b:3a86:b0:1f7:2103:a8c5 with SMTP id om6-20020a17090b3a8600b001f72103a8c5mr5479710pjb.64.1660769105486; Wed, 17 Aug 2022 13:45:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1660769105; cv=pass; d=google.com; s=arc-20160816; b=MXatN5PVAKOcynEYubgKVbfkHCol758nLiSAKxr14jpYHL2SvkPPrbx6JD77tFV+7O FjeRIfIlHkw/CDqr03yPaZJbRdCeKx15823bLvekQOBzTvPG3gnLPFp00KKtr9DzckNj ulmGoHlKQQcxYUQmSBcAoim266TSP7H5Y1FQQImvdmiTGVw7jWf8xQj6FwlM1oGgA4Tl 90t+CTQ7lTCPJkR3A8eHkzO5rEfagJdrj3M87voatrXiht923mYpeFeMl6DpoGAk7P7J rvzp5FDedLMtZUGEbkZ1vvCO4rcttFhQcPstTxGkItLwnbH3fkfNHCuBQahAOdfZfz31 8/dg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=XUNp77XI4N/1ISnqWFd9LaLp99YGxqaqrpB9jD61VXg=; b=St4aCKXYGFBhhIwBm9hbs3q+4+NDezdA6oNTx8QKqISe9CWv7cHFEvdzyp4ziNmkSN 9e8Z7jYwYcw2CxgvDQvO34aWwdKPSDcs/Z4vdCoxhOostTWX2TwUvS7EgoX/IPENrqju 9zrpwowbpv+k1sRhLt2PbH5xQu/sHZ0DzJDA5aGPBgk8P5nrSAHG0EdDkvELevt2TTPS Bkv/k7acAropMuF88SPAEQg8UFWRAN4rnsv9F6RM2TaMU/Mow71TmJKsdo9pWuewlPHg iwNarzPcSRs/ViMh3bl6SpStEaU5H/JeOVBUnKuD7A+I4wHkertF8JPsYhYYjKdLUC3V NxhQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=LTCtw7Jb; 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 j190-20020a6380c7000000b0041d64505cd9si15553617pgd.620.2022.08.17.13.44.31; Wed, 17 Aug 2022 13:45:05 -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=LTCtw7Jb; 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 S241991AbiHQUfu (ORCPT + 99 others); Wed, 17 Aug 2022 16:35:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241999AbiHQUfS (ORCPT ); Wed, 17 Aug 2022 16:35:18 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26FD2AA3C3 for ; Wed, 17 Aug 2022 13:35:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KY6hNaf+af7kUilT/pJdyesjGHF9H2Su4EO21pzu9IE5GE8eZX92V7mkTcJUw0Rd8A/vhuTbkchfhbbnMqOqf0Wf1DpCKXLc9uNhztl0eKlwIoV8E6QA1ivRckACx/HwIWYDv5p6ZRbK/PHWp/ExEu9RlEx9wVvl5zAZgtvA3B4gbxbSo/paz+2osS36SfngddZ7e7dSZFWJ38D9+x5IPsL6bHHX/IWWN3KNBY49ncmlFV/r29gVZx5zPAYy1qwzhgJVNB/FrYBTMCHwApQsHV2/JSEWznqqHBf+WSJWR0TLCZeO9JDNpvLxDdw/brWtJzVmen9BvMvWvEhcgMPgBw== 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=XUNp77XI4N/1ISnqWFd9LaLp99YGxqaqrpB9jD61VXg=; b=oFO8aX0Y0VK+sNt0VafIWtjogFdwhIwKPhRKAS9qGJzR1kqGIOKPMBRM1VHNbdXEzMC8kGYNZuw0MKENcIrOF3d/myGNE4ddm/0QJdP5s68muj9x6JYx4kDRoItLajv/FpZJCfCGLHn9t8FjtnFf2PTnjjbyKuD6GpvwZM7u0zLZBL3bZUOHjVwj/0Ko6Ui2rKmuJJco5+IIU5R/2oxdOQCgrRTeSKHdi+DGaPDNqjmdaM2txh87+CxV8hxY9Ati+kVQgLjRQeE3SARmRXDhES890Gr3GZxmzSHAXaeGIdfOh29O4m2Bq8gQ1YItK0d60bRl6mLMjqamohPUh1jBLA== 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=XUNp77XI4N/1ISnqWFd9LaLp99YGxqaqrpB9jD61VXg=; b=LTCtw7JbvtXuoxM2zraSMLurlmpPgCX1KaaxMHMFqwr3yjAIrMll73jPUkX1ItxE9cNW3P8/jnvsq+OyYuIOjgHVn3F38ZRSDriRdNgAXovhGfhZfDP7zN9J1uEK+LIcQWcHxtGxgTOdyeEVnhylSy7IZVgULSRRnG9qLY95wchte+tnoHD++WBNi+5p+O9dS/wVhrkjCXz1qk+NCGN1u5EaTqPyF1mf1WJdjxcJqwsCgigfT431vETBgYez+0sUHonbruZh6tJfAxhEXV7URJ+1ytkccMSgFEMlSKNQ3DWEW7nkajO8b49i2z+rOmp7rlElmrKkY9Tu5Eg589yG/A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) by MN2PR12MB3870.namprd12.prod.outlook.com (2603:10b6:208:166::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.15; Wed, 17 Aug 2022 20:35:14 +0000 Received: from BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::508d:221c:9c9e:e1a5]) by BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::508d:221c:9c9e:e1a5%9]) with mapi id 15.20.5525.011; Wed, 17 Aug 2022 20:35:14 +0000 Message-ID: Date: Wed, 17 Aug 2022 13:35:12 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH v4 2/2] mm/gup.c: Refactor check_and_migrate_movable_pages() Content-Language: en-US To: Jason Gunthorpe , Alistair Popple Cc: 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 References: <487960bf67c7273ff5606c76f73bb51271bc7b90.1660269441.git-series.apopple@nvidia.com> <6b61e9bf7c65f78524db32ba3e65a7eb6b8a76a0.1660269441.git-series.apopple@nvidia.com> <87edxgvixy.fsf@nvdebian.thelocal> <87wnb7tycb.fsf@nvdebian.thelocal> From: John Hubbard In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SJ0PR03CA0159.namprd03.prod.outlook.com (2603:10b6:a03:338::14) To BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d0c0d8c7-347c-460d-cc87-08da808ffd6a X-MS-TrafficTypeDiagnostic: MN2PR12MB3870:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XrxCu/VAWCeYEsVEVMpctjjHKtYK+FXP5z4nbkGHhaatgt+CLhIJXayjAYvpx0xcsvW8Xwxl90R5x5eR9GDXswhu40sJ6lKAD5kYJI6VNB4iJtyTWeEbw+0LFqziZJZkz/wSwSBDbevn+MYku0KmJtCbIV0hiXnGDJk9pWr7u0vQE8xlR1oZtC157op6yXmaQnAnk5V+f5DOurWcXY37tPi57P7052uT+NWB5YEj2Q1KjUMK3gA+j2DoGXXkmpldRimCJrFUW09fJHOBwMEbJUSGW/Cr1yrOPW3+Wo6ibZ5OriBmmX7qBWwF6zS8Sy1Yy+mKKqX31h3dtHm3OnZIk4tA0r5fUIUxdrYWG27IMxDrd9Hnvpd+gpFxPjlJ2Frcx4nngL/QO+eXtU6Seaypm1Hc1M6pVThQmc7xWuxe1CWuCBPdFcJEesCZhAopcRxRoMSu/LYjTOOCSoh2IVlX9JEm9sYF7wPQuLnLNt1i2XmH9GKW5jnKVSIolzVnAnQuD2FG+KbTT4udoiBX4y1jc+gSANwwis/hJQBEaRCMVFumSfwPcYhYxC6kTTsZ+6yCgzp1YdlsJdjwxHda/XCr5AZduwNhkdo5xYYPaniThsF6nSy9sk4slhGFbwQru+ibK6FOZoGTUKxYEFRNaASVnZFGQY3pq2PX2RBiGbZH31OlPKZYD+66OZmsvGFSR2GHKoJrGCMvoOv7s5ocuteQ0Y+s3g1JALOtFAXYtuiEqtsUZnj8nzdFfe12QHwDqChMhG1TzfcO+Hw8vX7lH0mwXXSU6ZZE0agdA2+Ryr4Q4v8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR12MB4130.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(39860400002)(366004)(346002)(376002)(396003)(186003)(31686004)(86362001)(2906002)(6506007)(53546011)(478600001)(31696002)(2616005)(26005)(36756003)(6512007)(6486002)(41300700001)(83380400001)(6636002)(5660300002)(316002)(54906003)(110136005)(66476007)(66556008)(8676002)(66946007)(4326008)(38100700002)(7416002)(8936002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?UWJtTUdxNWpEclJQWFJoZE9NZDZXSzBzZjhxSmZ2aHk1dk5TcmUxZnNzcnJD?= =?utf-8?B?Q1QveTUzWGZXOFl1R3daMDdVVWJVOVlmWXphbkhraHhtNzUwblVqOUhIZmFa?= =?utf-8?B?Y0JOcU5ZN2FxcExJYU5Gc2JiQUZhRT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1Qw?= =?utf-8?B?c2NwSHZTUGRCczhCdTJuU0srdXB3eC9jZFF2ODBvdHZGeHpXbk5kSnhGYSsr?= =?utf-8?B?VFNGaUhUYVhuOWxLSVVxTnVodUxzMXd0d2tlTXFxU3lGTFB6S0gzYWRaWmVm?= =?utf-8?B?VlNUZkhidUlpcHlLOUR0WnVyNzF3bVRQRjdFVlp6OFdsbUU5N2ZQLzZHaFI3?= =?utf-8?Q?WW2+xlX7jfFjIUUUgqytArdgB?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0c0d8c7-347c-460d-cc87-08da808ffd6a X-MS-Exchange-CrossTenant-AuthSource: BY5PR12MB4130.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2022 20:35:14.8547 (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: HSMA8TZkIalG+FVcgjbLJHaZktr9yW7VUTCbn/d7rNmswqNF6Cyp75TalNN7JEBuZPvXcZeStYdcg3Rg5ADFQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3870 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, NICE_REPLY_A,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 On 8/17/22 05:09, Jason Gunthorpe wrote: >>> if (!ret) == if (ret != 0) >> >> Huh? Unless I'm misinterpretting you or am really behind on coffee >> if (!ret) is equivalent to if (ret == 0), not if (ret != 0). Although the !ret idiom is a huge, huge part of kernel coding practice, it also adds a slight bit of unnecessary mental translation (go ahead, flame me hard, I know I'm asking for it...but...see above, after all. Pixels have been spilt working through it). And also... > > Oh Dear, maybe I am still a bit jetlagged > > Regardless, it is confusingly written :) > ...this is a slightly tricky and unusual error case, so it helps to be extra clear by comparing against zero, and even adding a few short comments. How's this look to you: 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 ret; thanks, -- John Hubbard NVIDIA