From patchwork Tue Jan 17 15:58:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13104838 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 61796C6379F for ; Tue, 17 Jan 2023 15:58:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0380C6B0074; Tue, 17 Jan 2023 10:58:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F2A1F6B0075; Tue, 17 Jan 2023 10:58:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA3B46B0078; Tue, 17 Jan 2023 10:58: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 CC2296B0074 for ; Tue, 17 Jan 2023 10:58:49 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9C48B140225 for ; Tue, 17 Jan 2023 15:58:49 +0000 (UTC) X-FDA: 80364749178.04.1947167 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2050.outbound.protection.outlook.com [40.107.94.50]) by imf05.hostedemail.com (Postfix) with ESMTP id 13888100009 for ; Tue, 17 Jan 2023 15:58:46 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=QPDKUQEE; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf05.hostedemail.com: domain of jgg@nvidia.com designates 40.107.94.50 as permitted sender) smtp.mailfrom=jgg@nvidia.com; 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=1673971127; 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=8KuMywXBvp0scjsK2KcpwVq8rhkQLG+F9pe1b2uQyI8=; b=TfodS19LU1or+zgzOS5JOLpx4U0nhaW63KQnZfR2nS6g3nwjGc0DQNfKoHDA1tw9AxBYFC BUdlmNwkRKA6y0Kd6vt+XyjFsRliLpY8tjxD70c9k8fhMAK21usMmBJgQeQsVWDU6noWIS aw1PvAU20gVRlnIvTvdDJfpI6zgXOL4= ARC-Authentication-Results: i=2; imf05.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=QPDKUQEE; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf05.hostedemail.com: domain of jgg@nvidia.com designates 40.107.94.50 as permitted sender) smtp.mailfrom=jgg@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1673971127; a=rsa-sha256; cv=pass; b=gnzsWQ7chaS9/Sd5aWwFDye42zvEpVjg25WKQ/6g5xWFPTae+qYWF7krK9ys1PpBYhh3g2 e5wLDXbr3cz5s4gDcNEw+wgXtyb2IeRqkOMYT5mZvRHh8/epU+YPTuDQBnvRsIU8zstnbs uxezqDIeEZQblXfgF1DfD2+uc4Srq7Q= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CasRme6km+nuUD7Cq8UySqIpFSCvwz/t9zfwcoyL4UxkqPeMO3ARpIxBHThc4KABGykw/zd713AHSQvmaPKfJsYEjErjVf1M0DQG71HxaGGY1rjV7xAbBxBImBn0HTxSXzGZKfMB6mO2im/d25fsuLi6ddjHXOMjNxwvw0dvuiM17dPzcJ0djK1f0koy1tpfi+JWiSLOgqmQY6aG4MVq8WZpRDKumapVTc4wqgA7rCuVl1Hw9ZEPynGsOlBtVZDkDdKFjKruza+N92EXCCwJBIw+yjP31m8Gnj9qrNq8MTnC4OSLwO0iG6MFngUU5xbDsNKFqeTNJAYMTmAd2INXng== 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=8KuMywXBvp0scjsK2KcpwVq8rhkQLG+F9pe1b2uQyI8=; b=APRIbNLW/69HxlxCGXWt0nAO4C5iN9rNz3J3sIWURSNwqEsLB75lcO8htU0H7I/Gn32pirwzI0VmauxmiY1DEjRwWmukIh4PB5gy3lMnqiUkb4GXrABjsO53SVcbrFs5BoNvAzLfXtQHRIyCEzex5LlnFHdSLWRadJ6R5iUQraBmWeGr0Kv4n6rTJRbUUtzRm/8+Kf0vx9SBs7AGULkrwStpHGjGRfK3GtkuEPHh0cZKSsXp9ZmZK2hWOxN7x8U0fcu8XGWW0a9qmO5LbBZv6AhfiSPON78KLnXA9RZzWS32Ml6iE/aFgKc5cfV+nzL/Ts/ZzO2AfrjIVSiRtFoPgQ== 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=8KuMywXBvp0scjsK2KcpwVq8rhkQLG+F9pe1b2uQyI8=; b=QPDKUQEE341giaz23RsOhZsrzO04df9BkhO6uN4DLLKtj0PVw3J1xK59u5RFs5lYQvaAI9/SbU4UqyJXCQe8jF54A9rJjgo1utlM5iX+urotZOm2YCoNKNG9zExCIuFR4qKuPiohtaI1I32OuVwhq/SIAPUc5hYQeXYT62h3qmlh1OLcBt19n3wdJMtLzC2GHAQOTeKvo2AR9N8MTKWTZZsvd5zmaqSKW5mWTf5l+bWPEP3IkN/M9Io9J3L9SglNWqB1azbE7u9bjFsC33mnOcFfHZS9sQvz3cBFJ77L02b0PY930XeXt0/7gXhrTi9IN8TPhWcVdP/MA4V60avOAg== Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by IA1PR12MB8334.namprd12.prod.outlook.com (2603:10b6:208:3ff::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Tue, 17 Jan 2023 15:58:41 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%9]) with mapi id 15.20.6002.013; Tue, 17 Jan 2023 15:58:41 +0000 From: Jason Gunthorpe To: Cc: Alistair Popple , John Hubbard , linux-mm@kvack.org Subject: [PATCH 8/8] mm/gup: make get_user_pages_fast_only() return the common return value Date: Tue, 17 Jan 2023 11:58:39 -0400 Message-Id: <8-v1-dd94f8f0d5ad+716-gup_tidy_jgg@nvidia.com> In-Reply-To: <0-v1-dd94f8f0d5ad+716-gup_tidy_jgg@nvidia.com> References: X-ClientProxiedBy: BL1PR13CA0079.namprd13.prod.outlook.com (2603:10b6:208:2b8::24) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|IA1PR12MB8334:EE_ X-MS-Office365-Filtering-Correlation-Id: 614e1bd1-6d26-43b5-ea91-08daf8a3b3ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EpuBz+ilGv0Ui1fQhqHiC8eYLrnDppoyo+5ocbrVKCH+NZOhTD4qBxuRKoPoEmwyi8saIqL5/fPUQmWu2jjj/Gn3teHOgQBKDfuZe+UinxinBM6dYdwf+qJ1xQbZzCU0is5xq8HAuDOtneZEh0NVUGsEa3v+JA1uLt29IgYdEMFvB6SG2Db6cIi7ZoVYjMeH62xsVXmImJsJ9NvKsMl+9GrqCYl6ghGJOgZYAng9DJwEdzKLmleLq4iseeiKbGUUHajRh8741otn6Nej7cZjH6psKUDuXkqagXSGTaZ9rg45f+qX7VppEfBbo6TFHNNynsPcMmxqgyAQan4BpifvlZgSbu9zTd4gQCdUvJpEedpWFcIjz2hbC/xDksC9D2yOe5D0YKSO7bz4zdZBXG2ggULTKYXN2tdOafTwaRpuLpePmlDHhJpVm8tBXul7KJnNon35CIIfY4p54TWaKyA/b3vN5u1LtWXhQ/hF618TrxRCcdaPm3j2Hux2u5clcLyMaGhfY1cOfH64EfHeV2hsVPvw4Vsc3bMrTr7FJgitgR/VolFh7fdKLlOBhrh/9cIhD/6uCbw91IL3onYaBKi9Dxc9Zf7ql18lY8vU5M3fsDSYKDWB6ov6LzzDDdEBC2dfPvp0D0vpSudMaNBwZNfF1asnQo39sPNAQDnUEyy92U2/jqYFk8GA+eYTezxhrZwi1khwAfPvyLV3308vfBHPRA== 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:(13230022)(4636009)(396003)(366004)(346002)(136003)(376002)(39860400002)(109986013)(451199015)(36756003)(86362001)(2616005)(66556008)(4326008)(26005)(8676002)(6512007)(186003)(66946007)(66476007)(41300700001)(83380400001)(6506007)(316002)(54906003)(478600001)(2906002)(6486002)(38100700002)(8936002)(5660300002)(4216001)(266003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-Chun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s8b4v6jqmnO5iFRBi1oeXYW4IMwN8zXMa6B8pBRYYvcKuxkGTesStrwk5t+1tTiBdfuzU7bWag3vaMfWiqioJ+jAzOcWhWTrz5oHpzFNSCGS+gt3cSOl0bLlIz3srJv/+saoTs+Ba2FizNUH+wPjdDieEzRWGmzKoe23orPDPzgHvwaVu9egfvsgjsug7swGj6tpxftWAxQDtAxIqa86Vc1rsVViPfWwQvdUVyy72thWWA92ox2/O9WhU9lRZK4SrZYf65qc+WMjSaPbHAxNldY44fKu1ZT+pzhbImozYubY7ma4EH1KXR/xTZfxkWDVvZ4a2gHdIV6O/JwnZ4I6FhYVUpikDqif9ggb8Uh9HMfiw5CI+YcSSS6O0Z0wkS7cTENRDKj6ccRzZWRAPjUnY7FpMtt1NFHpzp7MH60H1WEl7oLgvjjIa7zZ99XLVND7qp30bDolsYeVA7x22O9if6DZlpTmR3TcZ3QYWjVRWxrlcwSVttA+ENSamp71yhSG+Sewq5Xavqbu9mQsoEuD6ReelBwG/Rsw/Df+U9M8enQRv0N X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 614e1bd1-6d26-43b5-ea91-08daf8a3b3ae X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2023 15:58:40.5695 (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: bJbW2DxYbI4WPYs8icI5Jg5kalhZ0HdNZy38VrVNAPkhgH7OVdtz27ozzbXPxRV+ X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8334 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 13888100009 X-Rspam-User: X-Stat-Signature: 8p5yp3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ity: 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 -ve Remove the restriction against returning negative values. Signed-off-by: Jason Gunthorpe Reviewed-by: John Hubbard Reviewed-by: David Hildenbrand --- mm/gup.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index b260c182135587..20ebc4d1f0d719 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -3002,8 +3002,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. @@ -3015,7 +3013,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. @@ -3027,19 +3024,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);