From patchwork Tue Nov 8 05:44:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Shijie X-Patchwork-Id: 9416625 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CCA9B6022E for ; Tue, 8 Nov 2016 05:48:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9CC928B65 for ; Tue, 8 Nov 2016 05:48:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACB1928BCC; Tue, 8 Nov 2016 05:48:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4816B28B65 for ; Tue, 8 Nov 2016 05:48:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c3zFX-0007gc-IA; Tue, 08 Nov 2016 05:47:11 +0000 Received: from mail-ve1eur01on0079.outbound.protection.outlook.com ([104.47.1.79] helo=EUR01-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c3zFI-0007eQ-Of for linux-arm-kernel@lists.infradead.org; Tue, 08 Nov 2016 05:46:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=5c8SXStAg5stfBRotR/U9ZbDjRQ1fBNAQIVAurSySGQ=; b=BIycwAMaK66UZdZahPGHxGTnGsQhqnX3k7iDfo1EWpY21q1yE5OI8wVeEkjxZdcIyU1aPLvLxwb4hs23NJxkqtju5NcEkw9rTZez4sI1Y4HgcLrLyo32ZDVLFfjEOS3owGKq5EbNp4o3BYlJDaB6qgwZIeh0zLINYxDS1fidM4Y= Received: from AM2PR08CA0007.eurprd08.prod.outlook.com (10.162.32.17) by DB5PR08MB1221.eurprd08.prod.outlook.com (10.166.174.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.707.6; Tue, 8 Nov 2016 05:46:32 +0000 Received: from AM1FFO11FD012.protection.gbl (2a01:111:f400:7e00::113) by AM2PR08CA0007.outlook.office365.com (2a01:111:e400:843e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.679.12 via Frontend Transport; Tue, 8 Nov 2016 05:46:32 +0000 Authentication-Results: spf=pass (sender IP is 217.140.96.140) smtp.mailfrom=arm.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 217.140.96.140 as permitted sender) receiver=protection.outlook.com; client-ip=217.140.96.140; helo=nebula.arm.com; Received: from nebula.arm.com (217.140.96.140) by AM1FFO11FD012.mail.protection.outlook.com (10.174.65.101) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.707.3 via Frontend Transport; Tue, 8 Nov 2016 05:46:32 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:942; Count:13 Received: from sha-win-210.shanghai.arm.com (10.1.2.79) by mail.arm.com (10.1.105.66) with Microsoft SMTP Server id 14.3.294.0; Tue, 8 Nov 2016 05:46:21 +0000 From: Huang Shijie To: Subject: [PATCH v2 1/2] arm64: hugetlb: remove the wrong pmd check in find_num_contig() Date: Tue, 8 Nov 2016 13:44:38 +0800 Message-ID: <1478583879-14654-2-git-send-email-shijie.huang@arm.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1478583879-14654-1-git-send-email-shijie.huang@arm.com> References: <1478583879-14654-1-git-send-email-shijie.huang@arm.com> MIME-Version: 1.0 X-IncomingHeaderCount: 13 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:217.140.96.140; IPV:CAL; SCL:-1; CTRY:GB; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(438002)(189002)(199003)(5660300001)(50466002)(26826002)(7846002)(33646002)(76176999)(50226002)(626004)(575784001)(189998001)(86362001)(586003)(47776003)(36756003)(2950100002)(4326007)(87936001)(246002)(6666003)(8936002)(50986999)(48376002)(356003)(6636002)(110136003)(5003940100001)(104016004)(8676002)(92566002)(229853001)(77096005)(106466001)(2906002)(2351001)(305945005); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR08MB1221; H:nebula.arm.com; FPR:; SPF:Pass; PTR:fw-tnat.cambridge.arm.com; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM1FFO11FD012; 1:LExjphC311lARiW/aTu/k5zEpCkc9laStL3lh8D/WJYzJMelM9L635HDzxnYDrFDlT+9hyGUQAZiFZ9vTqaq2QBRxcyRskzZE1sMmDoC3d4nmf58wsdkDJSQVHSayq7z6ZhihAMigaRgXqAbMUe2jT/HJdO9KkJoCxn/8/IrcV55ChA0YFgf3sWKExIpBs/HR5MJ/luGySnWViESCGBEHi0YmXeJTTaKThFg3wcH1v9Gmpz3+rcdCsJkA9Y2tkMlTkBEtWGbYugrJyMYipXDVFeZj6BW3Y1YqivwNyIxDAnU//BXwANlR4Hiqf1sBKC/vQHpMWdWefWjB+dutT2sKgqKfTZ4ab1ksSRs/ZNz9OOdFUfLUUgM9P5n/9MsHoWYJX5LSr3u+ELvCwbBhoJ8lXMbJmhbP3Gm4hm0PcD+0ToOgeUTP4ALFVE787T18lZQWpbu7H0ypXlYHWfdW/ZLhtvL9b7l36V5Rqr19yutLkdUID4Prbb8lwbI0EqiH+G9xbqaDnAqZUExqJ9Zw2ZboyfNekTSw1i36frLtBPVGLIPw53KPWVOYpCsRjG3woOtDi47tDDYPbdtUR1jWEi0tDIh2whxK2tDYXpYasdXDzvh1sSixvhW578UW41KkHxG X-MS-Office365-Filtering-Correlation-Id: a9724178-ef17-4b3b-603c-08d4079a9801 X-Microsoft-Exchange-Diagnostics: 1; DB5PR08MB1221; 2:OBqVMtFFJhHa4AqsJ3lCngUJ6//qNWAybZtz9rWiNKC0LvizOvOrIfI2wIV+ToL6L54gtLPicrzrE9xWD7kQEYgvZysX0o4dhFHdte3lDJ32+YPGmgHaRXo6HI0f9nnyPHTTdJUFuyu+zU0lgp4kWIJvG7VpBDme0NVblIVGpCEQKhiAkUAsjN+qJpJ3JMQoGCeh/p95bzGOIhESKPs8YA==; 3:Pi+YyO+0WIp1RJtiJKWCuy02m2RyzUPe/+mgA5mNqv4TH+UwmixtifwGZr3sat8qfMIcITAmWIZQNIoeJJ1oj7Sih5x8abOW95TeJJ0qZCgTXPJjVH5cwQJps5QQq52janTU4AI188jSdUljsil6L7Jc/XCUxalWarC6TvBr9FZR53VSTaeyNIpVhsBoHHTAmwku7jwHEsjDjoBGny6YYiP4kyJbHY4p7PnJ0KpuXkP1Lze3627ws6/9QmmohwMz4JT0R9hKloOU8gw3nCU0JBocsl/s+0oEVjN5+HmVzgE= X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:DB5PR08MB1221; X-Microsoft-Exchange-Diagnostics: 1; DB5PR08MB1221; 25:5q+5643tBGMuHLRhmuLcmkmNbnk/PdLyL+g4oj9VDZdfFjUILtJ51vmKLl4WCuGtBAftPkjSjba6hcyaSlxz2Hgo+8xxtqiyg7E39nyyQSy7KmNLCAodazuabGQvjvFKjbvDAFtc9qbA6DR8zCJwaIF1eCO7OJGumj1xgg9rL2ohBNfE447eLZIQRMQ/l9MMpTBx/D3rc9RCLKASURP5NVY6wQGnNiQPDT6y2SnPlUimw+2Mycmqxnw9NP/5RWcBAYEk7tgtOc7NOj8vE7BzinAG+jWfOqnjS13ttTbedfJJrJOEuAz3VfjWQU/rpFoOgfL9c00L1Gsye7AKQVfzHFpN1eLV7hW6Tpz+NzzGQDUmLxm4LCo4J0sIGCHDsh0hs//OEfKGBCMv/3T+3o1ni9DAlXSM9qiO3cxWuNb8YsQ=; 31:jNaFFI2VGfZfXbb9BIH+Ctyks0FULQ/FKc8n9awI4CkAeNwh6I6HMEyDfPaUvEfSS66goD28nyk1qIz4kmttjAP6eE06ASTRDH6XGjXbUXsUE5at7lLzegM4Ncn+2bBKRnbQf0FABn9cwFTIMlr0uLroiPEsPyrJJIBxxMENDHut9PeXTy7+Wv9Ish6qfDZPGCRfI/HEYOXMKcS7tmsv/2dTiEeBlL5e4+QAQYkXNZYi9YQ1tqrQGqA8yhfg/uxq; 20:zpcabTEVie4TiEL1HYRtA2TQ4MOOLG9/Oo0GbU2vKORHzqXvFt9hGMAcJh49J1Kcin/yIR++CASuBrHApn0fxmc7348ZQZc+X2/f2OQJnPRz838qnPUYT0kKCUu9N/5y2Jswg3ZFSIkhNsM9GEQEFJuP44rvQQ27oNUjU4ZpEzzRh6ZM9ipARJFIBnaKNFCN5NV6Q5perWmjK/aFdw+2zDGKYkmJJ+mUqAo7N7sk/8gAPATELPWFGWnMJNZfRWBV NoDisclaimer: True X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(13024025)(13013025)(13020025)(13023025)(3002001)(10201501046)(6055026); SRVR:DB5PR08MB1221; BCL:0; PCL:0; RULEID:; SRVR:DB5PR08MB1221; X-Microsoft-Exchange-Diagnostics: 1; DB5PR08MB1221; 4:4SW/qzl/pvc6eyERkSebeEbkcvtFLkcqubdBhBnp+9ULIwHcyzaRd0msF4mp8MELhq99eueootGx2p5AGC6pdX6Cs5sCohwSZWkfVmgBr7NkDMIBpu9Irv0380rL+NlBpRRszUUt1N3w5U7LSyEXKpGb7A23dQN0LjkQkRhFuJ60W7WN0oIH1QI+7/1jQ7PLoL7Vxiqx0EPY73FTcJumiRAKggdeV2SsLHvdjQmpS7qoCmyrE8JzFxzJisFSUI3Yy8hEpMfzubgcDoWryLa1+ZY59GjWO4rlmiSZOuxKDjth0c1Hn0U+BYSTvJ9oS5Jwi0KutBhYjp5PBYyyqCZnu2jiJSKJ8VgomCI5/q9kgwoCNySOTkVpyEfAX3pF8s9eb0C60oIzHHVHFWd3l6X7SzEzCaKDb4XRIDrVdU5+b7RnTtxMcB2Rit+9tSYudABeFob+t59EXYgCRxprvpwmajQOsEBu1SSMc4xsK3fCh0LHgxG2M9QnGMk7hRJQBzOuHpC8+lwyF8MVcMO/fLYWdulIs0ime9sJcPLJ19qoBZQ= X-Forefront-PRVS: 01208B1E18 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB5PR08MB1221; 23:CzWyCGtnKSvztaim84xYbD5qgfy4z6cybGLqaZlNy?= =?us-ascii?Q?+xYHegBymyBWb8HeEqmMdwgEGQ/frGho7N0I2rRmrK4wwmmhWP1gYbLIB0k1?= =?us-ascii?Q?QpuUC1oxplUppjgq7KdptV7dJGGBnR7SSAU5HDPaMbZpZ9oj6V6zriSNDS4G?= =?us-ascii?Q?APUsxQOK9+9Yw2SNr8FDoKQEB7Fv+agkVKzFBu4CoCMmjZGgAtqHR2+y4Q98?= =?us-ascii?Q?Be1X0//h39fw4LEsxiS1dtO3SXier+mFDQcEhPoXqRMRA2hjjS6YlhHi5rFe?= =?us-ascii?Q?IiEMYcgyfjJYXFNDEVIULqlaWGnBGepcR+JfNqanI9fSY/BmOisRuC6QIwse?= =?us-ascii?Q?Mq5GUcw13KX1WpmoBAHCoFQne44VGW7AaSe/mcrG828CLaCk7nULoxdFiiKj?= =?us-ascii?Q?pBpkrjs+IrUpeuTYszgDbyT2t8gm8cJcbRFvIlWs3HDDgmnlBBJlyLPAo7TF?= =?us-ascii?Q?r6WEJMeS4a1Yw/k31JLPUJL8JZZjSzWUpnhBqgDiRdljAQcGoPw/TJR2p8E7?= =?us-ascii?Q?TUkHp/ccCH+kFFoCK8ITL+1N04nh05pgofEmRDljgtgefP5PsS2TZRb3erNp?= =?us-ascii?Q?KjjCvwAUwktVZkVrFf1bxNf1FS6eqKam/fJAJw66H019eJLSfWwUY47nMdg6?= =?us-ascii?Q?CSwqe9AKlgWCKeIVTdrErdGUasLgTYxxEreQcvagvKorXymj23iA/xrOk6qU?= =?us-ascii?Q?7iq60xBjFr+lW4H4DPR+x+DE6xE2e/OFk8ISLW8sQE+mRVDo+q8hSqaqLPXL?= =?us-ascii?Q?jmKFG/Wux/EbB6+trNZ7tuQK5d8FTCubFCoKR410r9qsp/6O5TaN+7GWARJv?= =?us-ascii?Q?bZBV86AkHsycx+522Uhr00913ISutumCBMkkE2NQ4Dwj/gnEdddbPZiMvinh?= =?us-ascii?Q?IGBHP5SGDDY6krPKkDzWYhqr+5so55BZAhNMUBy50zuyv1uPM8tGlQbB/lmq?= =?us-ascii?Q?jHzhcAr2r8KtcB2lFXV5NqNbiCCoJBsyJl3wJvNGKltTzht1mo0Ea0vL6Nb2?= =?us-ascii?Q?dMxmrRdlPRADX3fukiO9B6V?= X-Microsoft-Exchange-Diagnostics: 1; DB5PR08MB1221; 6:I6YcMRjJ2wQA1LsY8g6r9njTzAP9r2s1iJ7k15H5dtWlWoiCZbpJvb4MzQ78l+vCBmmU/8nzfxDHGsD/Bn2XPGurgp1IskzdD4IC1h2oZ22hpLdtJiHYmFw6G2ljXbLR+AgUBYW3SdZXnFDkEGoWnF1olY1/VjofpqQpT/IrtIsakibJvd1Yn+ZUKl9ZxxBnk4CwzR9sb9kLDWphaxQrqeSOHpEZ08zRIm4dkTSyzUbNk6SkcZO6WSgUmNOYgIS+/h5npDRrfr0B4FHjBjq4F/e+IEJtBm+qbK3tcfPG6Tpyltu08VIy1PqgH7mTdjBuxY3zYWDq5rHbs/lVmVE/Mw==; 5:5O9sUbuWvW6TnlEK1/2fmugioAJuFtHW9cQIpjr7AcLmaU1Tb6EJOywXRRkzXbEw+6jYApOvTc5qtHxwaoIwgyeHxKNwtXAAEDlVSLCYOKN5gtjCWLOflg1Orrj65LYCqpVnU54cvvgZLKebg6H0MQ==; 24:4mEPFO/Y3z/JbNP1ei77Zlm/7jZekHNoCvs3GXco/0WNQanRuxBYVv4bpg2/DsehSLFwRZeLwlPeE8ZYFU2/3IxFpmAyIWSBzNy+tEhgbmI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB5PR08MB1221; 7:PMpjnrT83njpViMipfSbWm00t1hJmd5un/Zr34dxdEABzBzRE/W6vzhQLG0twPzYAJb4sp3sJKoDAzQbkub4wJU/dH23+k0YUKfisoiWg05JHUmNswYk24NHPL6Gd+sQRFf4N/rs5KrlFz+UehlLNg56fmwtDne3SlR5BH85dflRNexJZRUXV2Rkm85xsyqQu0knbSBt9jC7FEq8Uhv0Hs3QGm6CbatIOSqWMuIut4qnx7jRMQ5lTw8QQ0WJz9zY6HfGmQ5YLD3PylmX1WPUJ+UFmWqKp2ItNbBNgDkOtAHQ1rzzHiepYejTQ9NhJsFG5b5jRhcfssQmNsoUpR6zuR6sBLJxu4W+f8U4W/DR2Sw= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Nov 2016 05:46:32.0327 (UTC) X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[217.140.96.140]; Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR08MB1221 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161107_214657_304853_44367E92 X-CRM114-Status: GOOD ( 10.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dwoods@mellanox.com, steve.capper@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, kaly.xin@arm.com, Huang Shijie , akpm@linux-foundation.org, nd@arm.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The find_num_contig() will return 1 when the pmd is not present. It will cause a kernel dead loop in the following scenaro: 1.) pmd entry is not present. 2.) the page fault occurs: ... hugetlb_fault() --> hugetlb_no_page() --> set_huge_pte_at() 3.) set_huge_pte_at() will only set the first PMD entry, since the find_num_contig just return 1 in this case. So the PMD entries are all empty except the first one. 4.) when kernel accesses the address mapped by the second PMD entry, a new page fault occurs: ... hugetlb_fault() --> huge_ptep_set_access_flags() The second PMD entry is still empty now. 5.) When the kernel returns, the access will cause a page fault again. The kernel will run like the "4)" above. We will see a dead loop since here. The dead loop is caught in the 32M hugetlb page (2M PMD + Contiguous bit). This patch removes wrong pmd check, and fixes this dead loop. This patch also removes the redundant checks for PGD/PUD in the find_num_contig(). Acked-by: Steve Capper Signed-off-by: Huang Shijie --- arch/arm64/mm/hugetlbpage.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 2e49bd2..b0d3f8b 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -51,20 +51,8 @@ static int find_num_contig(struct mm_struct *mm, unsigned long addr, *pgsize = PAGE_SIZE; if (!pte_cont(pte)) return 1; - if (!pgd_present(*pgd)) { - VM_BUG_ON(!pgd_present(*pgd)); - return 1; - } pud = pud_offset(pgd, addr); - if (!pud_present(*pud)) { - VM_BUG_ON(!pud_present(*pud)); - return 1; - } pmd = pmd_offset(pud, addr); - if (!pmd_present(*pmd)) { - VM_BUG_ON(!pmd_present(*pmd)); - return 1; - } if ((pte_t *)pmd == ptep) { *pgsize = PMD_SIZE; return CONT_PMDS;