Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756089AbcKWVs4 (ORCPT ); Wed, 23 Nov 2016 16:48:56 -0500 Received: from mail-by2nam03on0062.outbound.protection.outlook.com ([104.47.42.62]:33136 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753807AbcKWVsy (ORCPT ); Wed, 23 Nov 2016 16:48:54 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Robert.Richter@cavium.com; Date: Wed, 23 Nov 2016 22:15:38 +0100 From: Robert Richter To: Ard Biesheuvel CC: Will Deacon , Robert Richter , "Mark Rutland" , Catalin Marinas , David Daney , Hanjun Guo , "linux-arm-kernel@lists.infradead.org" , "linux-efi@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] arm64: mm: Fix memmap to be initialized for the entire section Message-ID: <20161123211538.GH10776@rric.localdomain> References: <20161006161114.GH22012@rric.localdomain> <20161017185801.GT25086@rric.localdomain> <20161027160136.GD24290@arm.com> <20161028091905.GM22012@rric.localdomain> <20161107210514.GP20591@arm.com> <20161109195132.GZ22012@rric.localdomain> <20161117142528.GJ22855@arm.com> <20161117151805.GJ2151@rric.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Originating-IP: [92.229.81.63] X-ClientProxiedBy: AM4PR01CA0012.eurprd01.prod.exchangelabs.com (10.164.74.150) To CY1PR07MB2346.namprd07.prod.outlook.com (10.166.194.145) X-Microsoft-Exchange-Diagnostics: 1;CY1PR07MB2346;2:4NX+0lv/vAsDrIFUhsaK0CF8ilApT6+JYLxGgWZj/Twxuh0087ifToAYoEK88w2ph3uGoeeMWr9+FU2wrthIqhqKpcMO3AEEkzE4vGWBq6GAtddsz6VXkQHc5r+zAoTcng6LxLYcIh3hZt2oXRQ7dQbA75vTuGoSqH3MDaUoi7o=;3:Ibx9ulYVaJu8RVLwXcMrUIMISC3cbhMuAL4So/YXpiA07eIACTllSqJgDlMD5sebiaHBn0THBe5qNc1TTWlZ9aPGRSZZKgb3n0ZILwIU2Zl9/nI+C4TM1bMQDwTQa3swHHNlX8mLHu+XXq3ybWP38g1PKmPeqzHszGgdNXYzkWY=;25:nnGWu/PquoBwTF8RTi9LKfgkFq5Ey76Od4RPzON+pxdIEIZZJxvEwDqgEbx6gA5w0yB+J1+xhcpBJmzWk44Ep+QpApkUZViDCC5MXY6UGNDo4lMAtjDExfmW8sCkC4DdLmKOZtK1SHLsNxLPusdcqxbG8Kjhox/MZXg6HzZeJzAAusmmI5NWdozMqhE8Ay+V1MIDtzZcOz8RBHlzolEakPRSnRhYgw1GBhZqjE2OhWGIQiLF9mUfD1s2+1BVh1k4GUJ9ZkyFKj5ffWYdoF45B1xcOW0F6QsQQYf7GOt+G8c0Hac8PX4SYlbwBao6LKMlCj8RhnqaX3xT+vUOCx158wyhwm8RGtDcSLaF5QqRH7Wo6+cdwROPL2paCW8a2qSdHlZM1wWuLxDhYFHmzndlSd44GmvJlTkTOMc5TM9PxWth7G/MkJpeH7MXTRx28YI4+aLUQ4nXn/AFoGlfwM4a5g== X-MS-Office365-Filtering-Correlation-Id: 2fe0559c-9bf2-47e8-133d-08d413e5e70c X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR07MB2346; X-Microsoft-Exchange-Diagnostics: 1;CY1PR07MB2346;31:PbPszuLZ1Orj7C2VqdaV391VDLMdb8bVtkcPfIueC3IMbcDPDI7YZalOXRkTj12WAJt9FQS3a1QvZB+eMqiKfkWC+DWd0n+3JfQv3vyxdPjY3zPXvw5UYoSWr/RsFHpOpKyKxxckwOaua1KICB18icDcqtbxmbnGQRXKTD7R41pHiHi+ChQQmfXkuayP3r7iNJHnkulZ4I5bEZtY7GuZI/hZOorc7Ev1muZnzkE+Q0khW6TJKQ3oKFfLGB6PZ5vt8UCIjnRBMLFcZoco+mWpaM84iet6bedPt5Es9ShLRaY=;20:9qyFVgl65u7TYCKxOLdUPoRYMy0NvmC3tAQXVXG1gJlh4Hw+5dYcAfgAV/Le1G1erxcFqNa8leerwJorudQE/GU2K2kcnE9deh2eXSAWwdSNDO0p9zm2r03tUxDD9gDd3O43K+c+dCS8XevT0ZJli1dQ9q1VIsmHibVnv27NuGzg8THGMR/LuFRf3vMGaciTgMCDGwjWU9pDzav26JCzNae5r4rOihAwLyxr1zkyvVp+LNN5a6WSC3JRWkIlnS75yN5NKUksQ9G1aYAQompJ2alkvxMNnJi7u7iowU2Y8jDZtfLzAv4NYPQ6f0rxqRX8vPwpEByAjEVtaITh2BRj0T0b5j8zrThg0LnhYYgHz+qwO6fntqD4T5Vz1HbSObnLtZu3vn8FNtX/sHMct0iU5IPaAZDRwqrrsU9gHhpVdv2Mc/DEK6+oywQTDBcFvCO6BNbKma+AgcRCwExLlTh9Juz7qEr+QNzui8Q+wT4wXRUZ6WX16YXj/bOVNdnvAlvV X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040307)(6045199)(6060326)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6061324)(6041248);SRVR:CY1PR07MB2346;BCL:0;PCL:0;RULEID:;SRVR:CY1PR07MB2346; X-Microsoft-Exchange-Diagnostics: 1;CY1PR07MB2346;4:anRNtLzZnLlH6WFTR3oa0DYVO0uhT5Dy9OPuF6aWI+pYbILGRGRErbYnyaq2UVUCxf5B8BIrFddWiIN4ULmKURsYhVbldCFUS+yegr0sVn4YKRMRoOKcVEcHiY4YfT8VksY6dv6KCCK55ZQUGjs/ZvQzBvj5RLjnbZmX0JsgDGW8ywF1EXpojLiiE07d76tCSfpiLTRYHXdP6WK0ZQRhvv1lnU4Hwp2ywAHAf3YN1ZmzJpJdYi6ooDJIFFah5Bl0AyJr9CgzNyyueY40GZP0RBv0lsnDaYeeR7jSBFKT1dyJ7fPY6MdoGrE8C0LltL+7bZosd8uEJ75sC8P3Opq9UEIcOHAG2B5qhCHdsm8t3JRlcvGychhrvGnnhtq2C4XqqMP4+z+dpC0dqYdFKfloknSbFs8JZLR8FD7z+rHkkk1tJfYGnJ74kVy2XMoSu58zYU0GZDKTxRhnlKUfgdzw/u6dcuKPdj/VwYRav+upY1E= X-Forefront-PRVS: 013568035E X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(7916002)(199003)(24454002)(189002)(50466002)(81156014)(68736007)(86362001)(83506001)(6116002)(81166006)(66066001)(4001350100001)(189998001)(23726003)(305945005)(97736004)(92566002)(77096005)(4326007)(3846002)(2906002)(46406003)(7736002)(47776003)(7846002)(9686002)(6666003)(101416001)(97756001)(93886004)(8676002)(1076002)(38730400001)(50986999)(33656002)(42186005)(76176999)(2950100002)(54356999)(5660300001)(229853002)(6916009)(105586002)(110136003)(106356001)(18370500001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR07MB2346;H:rric.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY1PR07MB2346;23:hnbjcVPkXvQKEnf/Bsk7F5JhslgMiP8IN4ClfMfWI?= =?us-ascii?Q?bTC8OR3996uvmVGzRZZ0Bb3Si0EdNsBAfP66onWkSsZ+QJ+W+UAo30jiAzxS?= =?us-ascii?Q?f4VoVYkqg+j4DyoNXjLUUWUoGMvHeYzMzYzMzjszpGckBrcgJXvmDMp3HmHf?= =?us-ascii?Q?9OQq4oRN4ipEm5la5fnVkoSwY1/ObNH/9LgJ4ChGROacnd/6VePek+BK0gaE?= =?us-ascii?Q?sGRaPit68RRZfC8VATt6Wu0DzO+cpvXXGxMfjAKjbzDp/uaVo6WZm1e+H+Ob?= =?us-ascii?Q?Y908NNEszHUOBKbiB9TnT7TS8dBY/Cd2o312AKl3Y35679fcgHPb/sLkuj0G?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Ryy+20a4vlpSKdXnPA21wyA92X6GxU4pBdRbvH3BCZCF3P8yMptkwNu5mdFgIOlKyK+179klLugj2DXCqf6vGs84ijbp2Q3UNnuqVSv866Lwo= X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2016 21:15:49.0993 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2346 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2146 Lines: 45 On 20.11.16 17:07:44, Ard Biesheuvel wrote: > On 17 November 2016 at 15:18, Robert Richter wrote: > > The risk of breaking something with my patch is small and limited only > > to the mapping of efi reserved regions (which is the state of 4.4). If > > something breaks anyway it can easily be fixed by adding more checks > > to pfn_valid() as suggested above. > > > > As I noted before, it looks to me like setting CONFIG_HOLES_IN_ZONE is > the correct way to address this. However, doing that does uncover a > bug in move_freepages() where the VM_BUG_ON_PAGE() dereferences struct > page fields before the pfn_valid_within() check, so it seems those > need to be switched around. > > Robert, you mentioned that CONFIG_HOLES_IN_ZONE seems inappropriate > for sparsemem. Care to elaborate why? HOLES_IN_ZONE is of rare use in the kernel. I think it was introduced to save memory for the memmap and only some single systems enable it. There is no architecture that enables it entirely. For good reasons... It introduces additional checks. pfn_valid() is usually checked only once for the whole memmap. There are a number of checks enabled, just grep for pfn_valid_within. This will increase the number of pfn_valid() calls by a factor of MAX_ORDER_NR_PAGES, in my config this is 8k. So, this is not the direction to go. My patch fixes a regression in the kernel that was introduced by the nomap implementation. Some systems can not boot anymore, beside of that the BUG_ON() may occur any time depending only on physical page access, we need to fix 4.9. Here is a reproducer: https://patchwork.kernel.org/patch/9407677/ My patch also does not break memremap(). With my patch applied try_ram_remap() would return a linear addr for nomap regions. But this is only called if WB is explicitly requested, so it should not happen. If you think pfn_valid() is wrong here, I am happy to send a patch that fixes this by using page_is_ram(). In any case, the worst case that may happen is to behave the same as v4.4, we might fix then the wrong use of pfn_valid() where it is not correctly used to check for ram. -Robert