From patchwork Tue Jan 24 20:34:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13114783 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 791E1C54E94 for ; Tue, 24 Jan 2023 20:34:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B8F8C6B007E; Tue, 24 Jan 2023 15:34:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B1AA76B0080; Tue, 24 Jan 2023 15:34:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D8DB6B0082; Tue, 24 Jan 2023 15:34:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 642626B0080 for ; Tue, 24 Jan 2023 15:34:49 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3159B120C59 for ; Tue, 24 Jan 2023 20:34:49 +0000 (UTC) X-FDA: 80390846298.25.8A53BA1 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by imf12.hostedemail.com (Postfix) with ESMTP id 49D964000F for ; Tue, 24 Jan 2023 20:34:46 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=tDVL8zKo; spf=pass (imf12.hostedemail.com: domain of jgg@nvidia.com designates 40.107.236.41 as permitted sender) smtp.mailfrom=jgg@nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=reject) header.from=nvidia.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674592486; 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=jJcEkWTumjbrcdOLZr40qLuiQxxPvJ1xACBtTcmfS1U=; b=xYSbGb9auZz65UtSM+JOh/OAcq1FiDx9omzPl+KesCHY95KMFJxEYKnWMejxYUV3OiME1v vnWadwrmZjmSRLhHlI6Bh1PtNEmN62A+Wg/TbhJDh+g3pmcGc8tjsdigtCF5yNKAQN3T5B VcvvDOCG3R9Uxlh3BLPVIiIrbfIg51Y= ARC-Authentication-Results: i=2; imf12.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=tDVL8zKo; spf=pass (imf12.hostedemail.com: domain of jgg@nvidia.com designates 40.107.236.41 as permitted sender) smtp.mailfrom=jgg@nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=reject) header.from=nvidia.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1674592486; a=rsa-sha256; cv=pass; b=EZWx0+H1YyX+tMY4FgjIJKunC0cC/ZJvMCmOgQlhPDECMNbF4goZfGxVNqPX6j+P4fuLRe M4yrCN+YEHyLy2GIVqt5zDenb2WdpMI6SwO2NzU6g+c0JnZAq7lbFE6AepZ0Eyt/Vz3b8o AAXtYdDbO6I9Qt+sCcYdx2b052pgm3o= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cHq/ro606SCfoTbN9DCcX1rhgE2PZKwC0eOVJlMYwYID/lRx9afGTAsvw9JxAlXsXZKOfmTQ4q5hmr2hhPzy4bjSGZjt+g4Iu2DU85oUJ234VPVkiv9ahOicp2FdcYOWn9QF4Uuv8LrL3lgM+ZHE131pfr/rX/M6oa1PPdMULZdssnFKqDK/lg6ZyoKAE1oZzdkWdxzC5Ifx4SX3NPbZKKu8Zr3WU3wpbnSWwCr+KlL6CykFtEBibmLUx86XaHZGXI9K/TvWFj0JYTC1VUUMYExNjDnsRc7eL9eqzB9UntHyScD8ribqL583boYv+gwOnZQvVkTw9aZwLtVGdiunWQ== 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=jJcEkWTumjbrcdOLZr40qLuiQxxPvJ1xACBtTcmfS1U=; b=Pk9m5A1aGWArkuCCPG0iot38eeEc9p60u0XqmBUeLJnWOfQhqy5tAvulI8XXjrX6DavMopilbBs0FoTRsJkkP0tXcxp8JsQMXulWaV3a1jyMQSPjeu07incawT9WBz+wF6uUFSJiIReo3sILiPGw5T2QFXeREVvdMBeEALp30Tvi4amiAaeFSIiD4MkMsn6oLhb882pNHBebpHvwipHWA6NE60Y+jxMN9td+k18/nxTZ3CO13nwKr/l2TBnZbQlWfaboaKAFwBOTgZ4Lgig6FodmJFynwxobif8BBCjRv5o9w36JyvEBojYH3liJt7ZY+EKaqiGYwBh0tkWQ+SZ5/g== 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=jJcEkWTumjbrcdOLZr40qLuiQxxPvJ1xACBtTcmfS1U=; b=tDVL8zKo50/i9NBmhD1tNfwF9aGlhHYVdQ24OQJE4LmaUqlmuj0fXs8UkJQh06OFYpWzeEJbjZLXPjD3hx3SQ0WZj5tcYmhkBO/KmRQcOHPqhuLSNdH6gJoYmlqEBqq0VadM/kkgmeIO+j9HwSX5iGAxsMASxTx2r3RCA66viBWWjWasxYWEdFuO/2agoJGC4K7sl9qGKDzt/vxh2OVPtAXkQrMZOFrX0wQqwbDLT34HWfOPi0NfCy8Cle4rpg6x39UQ9Jj0OKB0Hrp+xXWxAzTaHIEGYg+P4eByYF+J2qcQFmev8tSw1gflgn2F7tqtPilEErUC/YpvvtloQya/KA== Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by MN2PR12MB4095.namprd12.prod.outlook.com (2603:10b6:208:1d1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Tue, 24 Jan 2023 20:34:37 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::3cb3:2fce:5c8f:82ee]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::3cb3:2fce:5c8f:82ee%4]) with mapi id 15.20.6002.033; Tue, 24 Jan 2023 20:34:37 +0000 From: Jason Gunthorpe To: Cc: Alistair Popple , David Hildenbrand , David Howells , Christoph Hellwig , John Hubbard , linux-mm@kvack.org, "Mike Rapoport (IBM)" Subject: [PATCH v2 11/13] mm/gup: make get_user_pages_fast_only() return the common return value Date: Tue, 24 Jan 2023 16:34:32 -0400 Message-Id: <11-v2-987e91b59705+36b-gup_tidy_jgg@nvidia.com> In-Reply-To: <0-v2-987e91b59705+36b-gup_tidy_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR20CA0038.namprd20.prod.outlook.com (2603:10b6:208:235::7) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|MN2PR12MB4095:EE_ X-MS-Office365-Filtering-Correlation-Id: 39a4a4a9-330b-468f-9931-08dafe4a6842 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3AWv8qFAQVHdcJQ0FiRDQBRQ00aXW+YfblrGNsHzUensYtf9Hj83wsUJJr8y8kSLJlLeigIIYIDN1+IFp4hLfAX4DZThlsBHWuV7x3iFw/44YArvIo8T2VZ/2AEbM8MQjQu2pzurz5yV4UINWP+RpxwWO1jziQbju2xHQjyXX/1tvV27KA74doI99HYupgWDom7UxDh6Ii3qzWxfuEThzCkUmZruS+S77lJi/Pd1zOS/uSGhXSmkmZx3SHigfcaRLtiQ8vL+Dr4np2zLq5lrcuTO39Ei3smbOiiYa6PLe0D1wFHzimTvbFJ051db/+7BJNC4GNdiDITVQJ091r7vBj7UoGGAb6FEmwBh2aCJB2EG0XTWxL0H1aEwhnwzXkkOqr4ir+jlCALQGIqynWpte7GRTb4HxGFu/dszqONfO7b/sclVeP3Ae7tWyqYOcRB/ZSXr8etkgV72DML6rhdsDhpd1vc9DnAvPHtWkdzKlWpUT3RBQTiuvpoPlenNDPsOdEtnm+aJc1I+KiXNiHODSKblJ3N38Ilh6TuHGumnnBXLPZsTFUjCK7yveqbWf2geVYsYBzR/UUbSopesmTaFBsmbtMsfmLNxZ2S/uKIdtYpA8Ft/j3qtTQxS/C74a/oN0iLkj2ReQPvIo+ioqlhwvkJHrHP1OhQ92Spv3/N0WI5ERIyjQRlDK7Rhr49NFLaS X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(396003)(39860400002)(376002)(346002)(136003)(451199018)(109986016)(38100700002)(83380400001)(5660300002)(41300700001)(86362001)(2906002)(26005)(4326008)(8936002)(316002)(6666004)(6512007)(6506007)(8676002)(186003)(66476007)(66556008)(54906003)(2616005)(478600001)(6486002)(36756003)(66946007)(266003);DIR:OUT;SFP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Sx69PF+qsmfvq8cbiJ6JQ6DqN1dGOL/SYk55F0/l4FOpoi5Sl2+N+5nzroaCFmW5nHTvr3drEvhGMd9mdfCjYRM/NBKHgMPJHIQ2yvYuhchQkaDMnGWIPSUD4p4qSqofaYdm6CbYhu91KuWHg7SJq9A1EYBkCLG+U3RZ4JfbeXFUw5Q80LdxKZkKFwwZ+TT0lWHA349hat3i+KakCnrOz9eiQKERLOGWhcQLxxQII2tZvcMyIe5fT1qLkWUdcVCeHfcyu56c6IXLVeJUogtcxa2zxol6wDWIiND3ABm5PY2al7xmrNYUlNaL/kGKySRk1fiHOBimCZ1BCaW46FoT7IbvrCV7T9VlLLwcj+euooBlhzOJIm2INLAL8BARSKjkbmGvdy+cMT5a5//jfCCIDWJExpB4lYIcmWUZRnzvWc/oXASN6GSb2JhKOsoipB51G+LQoJFSxn1kawRMgrfSZGbRVOeGJ79GNVyjKJbUHPZF+g4QZhYySLgidb1yRYik0TxbeIvIshOmBKM+XzRJTahPwmAVFGp1cRLwIEwcvk8p5IK23I+BfKp1osTnR6/lobEIq4nmW8 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 39a4a4a9-330b-468f-9931-08dafe4a6842 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2023 20:34:35.7671 (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: MYcXvDnSh6fSjlmzkMqqCaR2o+gUQ8crPYU773OisfmbAw42ddX4vntBGM4Wzk2F X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4095 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 49D964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/pLPDBo8Z67C0zINAgZzpaXBm78yICy5rDgVbdmuSwaeUWIVw5IXMNhW5rhX2kDJ35zObti5gVpwDtZRfnO3JXF4I2ANGqsbM14kBQIDMvMOlinRmcM+GZZcgvjaRZfNja9QODCd57jUtLrbeQen9wbPSmIbNhPJKKRQazb/zThadHHa+pLeWjKX56KHNQQCWTclRbB5K24R+/BtITYGmDZZq/0QEOijuLSfMj+Hk1DFu+Vpv3NVoyMVe5lWjuaS2JxyM2hTobvGDEBlKgOFV180RbnqaH1+PcvgRg5j380iGyaGhVshu2DnJrCFdMbuymUlVWURFyz0u7w8r/cdqj8RzKV+0OZ0QrAOSXL0nw== 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: There are only two callers, both can handle the common return code: - get_user_page_fast_only() checks == 1 - gfn_to_page_many_atomic() already returns -1, and the only caller checks for negative return values Remove the restriction against returning negative values. Acked-by: Mike Rapoport (IBM) Reviewed-by: John Hubbard Reviewed-by: David Hildenbrand Signed-off-by: Jason Gunthorpe --- mm/gup.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 8edfa66277fe20..05ca9b0a06c8c5 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -3005,8 +3005,6 @@ static int internal_get_user_pages_fast(unsigned long start, * * Like get_user_pages_fast() except it's IRQ-safe in that it won't fall back to * the regular GUP. - * Note a difference with get_user_pages_fast: this always returns the - * number of pages pinned, 0 if no pages were pinned. * * If the architecture does not support this function, simply return with no * pages pinned. @@ -3018,7 +3016,6 @@ static int internal_get_user_pages_fast(unsigned long start, int get_user_pages_fast_only(unsigned long start, int nr_pages, unsigned int gup_flags, struct page **pages) { - int nr_pinned; /* * Internally (within mm/gup.c), gup fast variants must set FOLL_GET, * because gup fast is always a "pin with a +1 page refcount" request. @@ -3030,19 +3027,7 @@ int get_user_pages_fast_only(unsigned long start, int nr_pages, FOLL_GET | FOLL_FAST_ONLY)) return -EINVAL; - nr_pinned = internal_get_user_pages_fast(start, nr_pages, gup_flags, - pages); - - /* - * As specified in the API description above, this routine is not - * allowed to return negative values. However, the common core - * routine internal_get_user_pages_fast() *can* return -errno. - * Therefore, correct for that here: - */ - if (nr_pinned < 0) - nr_pinned = 0; - - return nr_pinned; + return internal_get_user_pages_fast(start, nr_pages, gup_flags, pages); } EXPORT_SYMBOL_GPL(get_user_pages_fast_only);