From patchwork Fri Aug 9 13:45:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13758828 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 16361C3DA4A for ; Fri, 9 Aug 2024 13:45:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BCC86B008C; Fri, 9 Aug 2024 09:45:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 76CC66B0092; Fri, 9 Aug 2024 09:45:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E6946B0095; Fri, 9 Aug 2024 09:45:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 3B5696B008C for ; Fri, 9 Aug 2024 09:45:16 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D4318A7BC0 for ; Fri, 9 Aug 2024 13:45:15 +0000 (UTC) X-FDA: 82432828590.11.891A426 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2059.outbound.protection.outlook.com [40.107.101.59]) by imf05.hostedemail.com (Postfix) with ESMTP id 0738710000F for ; Fri, 9 Aug 2024 13:45:11 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=EQqu9iwF; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf05.hostedemail.com: domain of ziy@nvidia.com designates 40.107.101.59 as permitted sender) smtp.mailfrom=ziy@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=1723211045; 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: references:dkim-signature; bh=NvnbZeuLHTHpSug6cb+x+Y/tB9okijkgpTT7Nrwnscw=; b=upXyvB7UP+/ecdSCUO2FHjaL0dga6RmoUI2psRzJ15e7HU3YLa2d5HWXz2jJ/e1witfiwH NWWN/kLQpPpASiwti2jP8J/VNzZQgb4jNaKzsZPgrpyZgd6ijE3tcmz7bDLXOGfhPZGvCc 7rH1d67x6iSmiWj81cM7rl+/XT3pEDA= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1723211045; a=rsa-sha256; cv=pass; b=5L0UVnkcyioL72jwT36Aj7Uv6XjWEa3GBF5xH9IilmxKfCXLPm23MgUj+Gb82vGceYThfO BtGFTfZo4dWLSubhzNKbuJOaCpxoDAhjsZt+iazhjTyb5jtEO0jT10ulRrbLQMdG15Ahin ++Ilec1NS2b5FJocPLZ3U7BBVzFBGHE= ARC-Authentication-Results: i=2; imf05.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=EQqu9iwF; arc=pass ("microsoft.com:s=arcselector10001:i=1"); spf=pass (imf05.hostedemail.com: domain of ziy@nvidia.com designates 40.107.101.59 as permitted sender) smtp.mailfrom=ziy@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=okLWDu2ek7878GHRJU6Zf81I2Roy94VIYdgUNgAn2rW9EJXRC7on1heISkdfb/tXG/IOezl/tp6YU/5PLVXMtCoLNK/CACcinMLM3jlK7tf1lA5LKut8/8KbBeRj3K64eouMNTzMg6OYiVB5yqEp7oZ4mReYWuf8m8jBx+vhPAOcMoWeR4W5Ect00Q0n8A4KLvzDd7K3hTloTxXxmhuj9Oh6+76jBCsPRfevClv0wJgJDZJfB3eJB2GCMZzaM+SDQ5/NKp7xzaXN3+dwxRD9WZoM7OtYBQjEgGoVA/O+6am9JpkXfx1pjLLyVo0ziktqRh9w6JcGOLpVj3W+5ak6zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=NvnbZeuLHTHpSug6cb+x+Y/tB9okijkgpTT7Nrwnscw=; b=bALG/HNvvYAuMJmRjjrK63paPSe6JuDuayBC3QTMvTTeIDb0S1DI3XimGUhYbKjgg6sZ7X5rtwz73Mz6KPkdqc8zqx34cjJx+yaAsu+3Z6I1a+z7q2Cgur7EwKafT862Msn2zUuhDbZGyU64k1mBSDA6xWLopI+CDJvx1fK2W6V7+ZpvbMtScGAs0YqUYHnN/9UTf65vr1M9TH8ZaTfxBKLy3r8kyrFc/Sp3tsnag5H86tJVzhKVCk6n8F2BXzVfr/dqMIMINQ9yVa2u99X6kWqHzzj1i3mxc9msU7g8VzWzoOWhHBkzy75zDUHucuTRBwFLbVMQaks1OQQcXlbGLw== 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=NvnbZeuLHTHpSug6cb+x+Y/tB9okijkgpTT7Nrwnscw=; b=EQqu9iwFlmvzwPjG1F5rld1DtqA04EePGQl5nDYS/JWvZu+PoXk27Bq6zo7ahuabppvgHnl7nsvQ5YF79jg27Etw954eiGh9wILVBkl3kXywOkDkeNdgOPN3jUxpuDL5dr1tL13CZMJElaZYQooAijunNeeNSQoXtCMagSIyHO77XMB8OzGxqCu499yxLD7ATczVwceeRUaEzAGZcQPv/G7MP4l7fYfT8wy7od3SvEZtNmI7PM3qnOSk8jkLLnLy9UT2VGukAR/SgqE2KxO7ojSvxWjVoR3WmyqsJa5F6ty7wcJq43wP+k+2mhDMExvRw8HV4oF0zRwC7/5jmzaNyA== Received: from CYXPR12MB9320.namprd12.prod.outlook.com (2603:10b6:930:e6::9) by IA1PR12MB6650.namprd12.prod.outlook.com (2603:10b6:208:3a1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.17; Fri, 9 Aug 2024 13:45:06 +0000 Received: from CYXPR12MB9320.namprd12.prod.outlook.com ([fe80::9347:9720:e1df:bb5f]) by CYXPR12MB9320.namprd12.prod.outlook.com ([fe80::9347:9720:e1df:bb5f%3]) with mapi id 15.20.7849.014; Fri, 9 Aug 2024 13:45:06 +0000 From: Zi Yan To: linux-mm@kvack.org Cc: Andrew Morton , David Hildenbrand , "Huang, Ying" , Baolin Wang , Kefeng Wang , linux-kernel@vger.kernel.org, Zi Yan Subject: [PATCH] mm/numa: do_numa_page() do_huge_pmd_numa_page() code clean up. Date: Fri, 9 Aug 2024 09:45:02 -0400 Message-ID: <20240809134502.1504111-1-ziy@nvidia.com> X-Mailer: git-send-email 2.43.0 X-ClientProxiedBy: BL1PR13CA0319.namprd13.prod.outlook.com (2603:10b6:208:2c1::24) To CYXPR12MB9320.namprd12.prod.outlook.com (2603:10b6:930:e6::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CYXPR12MB9320:EE_|IA1PR12MB6650:EE_ X-MS-Office365-Filtering-Correlation-Id: 4ed59a1a-b0d5-44e0-5614-08dcb8797a7c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0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Ksi+AjiozZITZ11Cb+bRYmTIqI9lyub6QEEAmUZu3FEj/BvcgnqghABkJSjeteQGVeiY6MzT1+qZFEDr+xW/wN0iVq8q/fFqnDpB1tm0gukwr8Ww9UQb+b/z3VV9tgCw5XoSEwSwGTlKi9poGx/llnHj7Bj4IHYJOfSdNgYax/S4QXzW19tFUdIVLrwwOSv2Nz7ktFfNuRFP2INuR+4F4QGlRFmsUfuorHBBVj6yJX/FC6QK3SvXDvRifTQA0yFublzKl9kE5SMHUij7ljnzToCTXB+qdOaEWfidI6isytovufFFWa06n8Hkojmhw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CYXPR12MB9320.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iwHgmIBbJhmNWb3H0r70b0TUPfaB5oSAvklkvwfk4/LmTeY33C12HowsDahoo4BmiHF/V8KtS+NzN+UDWttzC/5CuPaIj30ywD0EABbkEZKjqz1s32BRjmOdPIkP6qHGcPIwrbUKoztUXktdYgu3BH38VjfLLUPnxoMZg7Dham9nedA1PqdG7y+MMQKJ3YWTYpHpDIos8i2Pt7xqxMvnhEBfB1LQHmaOn7jSXwXRqw0fpe04E70SUqCPgv/1TXDIwq1TmJikPxODtYRygaAgHcZkfxKvPA9oZCUMLjTiPaKAjf8e9CWSmVCuTzIa1gmoGR9Ic7h4ZxhrjTNTtxjbP43/yC/DXU1K2U9dnp5bNg4hur3vltapmJfkyuFaGlmglJsob5MIbPdr3nWTwwT5HL/zVIcwP09C/arfG0NaheDJEIquXcEXjW0+X4N9AfWDa9An/EevZibTmxGLCDXyiwQ9woPUasClmDdTdouOVbGQFvh+m6kwgAvNyT9qEC3JYSUfQFumpY8xzwH750MHeC7CUfkOyMEbnXXkgn1T/bHujWLpn5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ant-Network-Message-Id: 4ed59a1a-b0d5-44e0-5614-08dcb8797a7c X-MS-Exchange-CrossTenant-AuthSource: CYXPR12MB9320.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2024 13:45:06.6443 (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: /JChmzHLM5iNVUqaDZanzS/qLkq1Z/YBJew8TRai8xg2kaJ3IolkoC0vZovrbhfp X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6650 X-Stat-Signature: qss83p4ff1oty9sm5bs6gnsfdzzw9u6j X-Rspamd-Queue-Id: 0738710000F X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1723211111-341233 X-HE-Meta: U2FsdGVkX1+HXZ73KvxBKD2oZhHok9H9wAQWM2Xym7Pe6+BusUlLFPJUwm0iXc6VsjLgXhwYrTmtKrWorn9+i2PpxF88m1rgu/hHHi+W/PMNfoGCDSRC9JUzOMKoobX1nwm/QkJdC/hCDu0QIoEWY93WiBdg1PAF/q2uaYAjbMQ0ff96h8UKt3dT3E+szYVljW10CDNUUvvwUg1HU0BLKc61QyDazMc2a+e7+KaT8HqjmuXr4rszVj2waGqKlRqPbHudKBqpWMW8KQMTGSH+QFiOrZ1ABOz3lFMmuWeSisoL8c/LLASYOJnEGFeNTTkuFWyNw1LY84wNUBx+JiP5ZkIqaTA5y76x+aPYgpRTrWh5blzwbJjeuDNQS4BXw+hN99z73ewyItlrBM8iEpbtjrVM5sfWJ8K/2Mm73n9jyJbvZ3mbYX5z5YuNxu0RlGFWq8rYsEomTLm4vr8cYp/pISCEEk8tivdO4h4FeoOhlFcdN8OZd36CuuARC6P4l7go1RrEMcrTt+/zyoClhqa49WFhn9FMfuO51LwVUjhl4zrO9WiBmdKXK31UR6vnsWvRHDjShoaPmUGLd1wlSr8FZ4JMDxFHYWO3Huu2n9E/1K+VCSsy8FaxV+gCTNsVWMRAPewdO9s9YnxyMi3T+lIx4t50zSLfHa9SiWNlLAHy2FF4YwH0Z57+s76ixTxQ873+sfUazMAkaaOlT7TmER6L2LWzZoS1cktNcgFK657Bu/GDDyKjB/+EB9D0HTcQRb4FY4zrIF2kGFWbK/mhZcv16lW57vhxNOzYDQ2zp7dsCHUqEpJarDks/55DJmvC+TmURKBMqcIuxwSHTbtt6MCMvKdzAospaMz6aKjanenEbEhxE6iXQJ8eEbN2dSuPuxPhkqzznDH0gF7ks9Qq4peG8YatfmtT8LpWPN1CVM1ztmm551xEFS+mb5rLdaGbbmtkGdYMy9Ef1B8przrHIsd 8BDn1PrN Q8FuEVxJX7aZx2KP/AHwH+8AZUtIvXS28y/NFCyuTbX6RY9GiQrkfml+ZNFKTrhZfjsSgF0Yea7XNxRAZ2dUVI/QqsfQ+k26aDbgc9JkcCEZjvt6VSyr448zrRmbZ5S8oaA1Afu1g7h8SrNRbBhd2yMrQz4Qc7tEqGWjoZdPWtdLQbYWStB0QkNYweCpkHx+5yOCXs5yzPOAVQvg5GN09P9RBs8fL1r4mPIrDfzulPvE0n48MjbjeiwVSI/AaS1ZPFG3wXoNiM1hDy0H5DpCcTWLZTG4vdu5REIqX 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: List-Subscribe: List-Unsubscribe: Remove unnecessary else branch to reduce code indentation. Suggested-by: "Huang, Ying" Signed-off-by: Zi Yan --- mm/huge_memory.c | 13 ++++++------- mm/memory.c | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 14f314bfce10..f2fd3aabb67b 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1719,15 +1719,14 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf) nid = target_nid; task_numa_fault(last_cpupid, nid, HPAGE_PMD_NR, flags); return 0; - } else { - flags |= TNF_MIGRATE_FAIL; - vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd); - if (unlikely(!pmd_same(pmdp_get(vmf->pmd), vmf->orig_pmd))) { - spin_unlock(vmf->ptl); - return 0; - } } + flags |= TNF_MIGRATE_FAIL; + vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd); + if (unlikely(!pmd_same(pmdp_get(vmf->pmd), vmf->orig_pmd))) { + spin_unlock(vmf->ptl); + return 0; + } out_map: /* Restore the PMD */ pmd = pmd_modify(pmdp_get(vmf->pmd), vma->vm_page_prot); diff --git a/mm/memory.c b/mm/memory.c index dd993fb3f654..e4f27c0696cb 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5528,16 +5528,16 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf) flags |= TNF_MIGRATED; task_numa_fault(last_cpupid, nid, nr_pages, flags); return 0; - } else { - flags |= TNF_MIGRATE_FAIL; - vmf->pte = pte_offset_map_lock(vma->vm_mm, vmf->pmd, - vmf->address, &vmf->ptl); - if (unlikely(!vmf->pte)) - return 0; - if (unlikely(!pte_same(ptep_get(vmf->pte), vmf->orig_pte))) { - pte_unmap_unlock(vmf->pte, vmf->ptl); - return 0; - } + } + + flags |= TNF_MIGRATE_FAIL; + vmf->pte = pte_offset_map_lock(vma->vm_mm, vmf->pmd, + vmf->address, &vmf->ptl); + if (unlikely(!vmf->pte)) + return 0; + if (unlikely(!pte_same(ptep_get(vmf->pte), vmf->orig_pte))) { + pte_unmap_unlock(vmf->pte, vmf->ptl); + return 0; } out_map: /*