Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756227AbcJ1JfI (ORCPT ); Fri, 28 Oct 2016 05:35:08 -0400 Received: from mail-bl2nam02on0066.outbound.protection.outlook.com ([104.47.38.66]:28236 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755671AbcJ1JfG (ORCPT ); Fri, 28 Oct 2016 05:35:06 -0400 X-Greylist: delayed 939 seconds by postgrey-1.27 at vger.kernel.org; Fri, 28 Oct 2016 05:35:05 EDT Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Robert.Richter@cavium.com; Date: Fri, 28 Oct 2016 11:19:05 +0200 From: Robert Richter To: Will Deacon CC: Robert Richter , Mark Rutland , Ard Biesheuvel , 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: <20161028091905.GM22012@rric.localdomain> References: <1475747527-32387-1-git-send-email-rrichter@cavium.com> <20161006161114.GH22012@rric.localdomain> <20161017185801.GT25086@rric.localdomain> <20161027160136.GD24290@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20161027160136.GD24290@arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Originating-IP: [92.229.90.219] X-ClientProxiedBy: AM3PR07CA0023.eurprd07.prod.outlook.com (10.141.45.151) To BY2PR07MB2343.namprd07.prod.outlook.com (10.166.114.145) X-MS-Office365-Filtering-Correlation-Id: 83854c1a-c87d-4fe4-9599-08d3ff1381d1 X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB2343;2:AxPYpizkgpudLAV4Z4O4dykMzem5tiKEX28HpOwAqgh9mhMZuyKBZcGxpWN0n8mSk2/WUaPXvnPzuu6rN65qMa9H27npBLD4ceNSakfn0/zJin3rUsf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==;20:h77dLt/QM1K5M1NR8eMuhLqpU+gZyuHEXp7jqlZUdnngvGThVA3cMaKhqtbadf9x36QxtSEV4TsKD/ug8hWfHyF4rlD/uLw8DeWCDNjfC+dSpPn4j1JLzIcrLFGl2vcKOZTwgjaxxdky0a2zkI1UX8xOMhfaTmn/m2kKTpCNCjFGp4dUScILjbBpmEIQap/6I2J7DNW8zuMCby4eGekxUJ/j0MuECK5s3vpX6AZdtRXqWYVzT1I/BtrwpA9HL7+TATtFs7klkmMEwMlgYFEcE3rZcUXn6nOZLCY4XD/Q9nDcDaH1QkTunGN1peYHRQ9olfx9DXWHxKZlpcYg87CzQLNeR52sPtZGreMTOgMB0rkYoMES57/2bgz7odfYXriw9mhf/LrgIqn9XM69+mZBMFnNaiVMSkquicjhlShvS6ppzO8bRSNDRfKXuf0Eo8JsVqkRsLK80cg5GnCCOPYE43fP9E21WZN9wM2llFL44CvIHvd6V/I/hkT7v2/5pH4q X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(83566789882024); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046);SRVR:BY2PR07MB2343;BCL:0;PCL:0;RULEID:;SRVR:BY2PR07MB2343; X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB2343;4:c9uWwCXv1kskMe1NShrJ6r+Kk8D9P1oXydrddvPE+zATSiCbRvEkJPoMegLLnwz4auJBwPM3hxDPU5BkpFtjCj/ylYI9r7t/ebqaXsv54CqRupXA0tPIiH4FRG9MIwG4tU/gPo4nyEs/D71+emKBfasNBkD/qUf/RhAnXCrLCOg4OZxpkUwfxocJV9A0Ja/aSK9K9omEDcxxhiTWIWRIS2SplancbDKuiqq+dCHTpspwOyCem4OOvdYUGHM0sKBMS/79Wsaw0L8Jt8xRwtSMBOwSN+zPR/gz7a4hgTNFrgxKixFS3vCzL8mXN7xOJVwTGMYL7azCmcr1vSM7tHndj26y9oFmDZp2EewXd0IL89fJn6RsKHWQlUJP9VNMr4JE0KWmm0PCyH7M5phsSjp6mKhmz94BHqeEY5I12tCKPMLatiLEbxXl6vdnzgSyg8wzJSXJTYYZxmX+BP4gZr6r2A== X-Forefront-PRVS: 0109D382B0 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(7916002)(189002)(24454002)(199003)(101416001)(19580395003)(68736007)(76176999)(66066001)(2950100002)(47776003)(6916009)(6116002)(6666003)(42186005)(3846002)(106356001)(93886004)(46406003)(92566002)(50986999)(54356999)(23726003)(1076002)(586003)(7736002)(105586002)(4326007)(83506001)(15975445007)(77096005)(5660300001)(110136003)(7846002)(8676002)(81156014)(189998001)(9686002)(97756001)(86362001)(4001350100001)(81166006)(305945005)(50466002)(2906002)(33656002)(97736004)(18370500001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR07MB2343;H:rric.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR07MB2343;23:jEHBUuAQMnqhnhzAIHAeOqtXoeCFot6Cat4StUUw6?= =?us-ascii?Q?yVofmn8ZnPaX09LEBVGYBC5xjfqZu7u+Xo7e7NmXGjSxinOVn4NXLIg0EP3D?= =?us-ascii?Q?Nyswmeoxf5nAyS2T+JxluAi+lsco1H0SYldzpRP7JbKYA1DcukerKu6Mwa0q?= =?us-ascii?Q?I6u0gWnzwOfxQXPB6V8dueYk+qhM9KBdk8IeiRyPPOzEEHgPA/c+gMn5XFeD?= =?us-ascii?Q?a93lnmHKOSsthzxNxgvCcCM3AFx7Hm/ko2wMDI1eQzTQmO3bebES8hfm9fy4?= =?us-ascii?Q?HK6BM/7bEOSAw0vyiauhRP0xeoeDRJmk1wI+nLVx1lo6FTcLSy5ctXsE9PNe?= =?us-ascii?Q?9/RETwG97N+pao55bJ1jhnSCdcrWHQfgn7T5+6/VoLV04ACDz8BB1WLOTcAS?= =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change-Diagnostics: 1;BY2PR07MB2343;6:h/HrrTVHIb4eCOFH8fLxwOkPLcx4YIlnvd1lDEGpJYLYGU3p2Rva+ebeQHUwt7rrJHmf+O2F5x5J6QoL0IZ3La1RJ4Vy/xRJGI6S9ar4/Wc63Opty4XJT7XF6e4llhbMflwVhiJo5uOwdbcqL7wQAR0nwO4E+l4q+c8df6Im+WyCYNfqKYzD8EP63zjXVyRI4NvoVdP0losN5UdXeheB2JnfUWuggvARTDmax6Xh+iBCPrc4zJpztmbRCaTb9FddBli3xBq6wMNAjqMZ461SbPvy36DVCk3htHwkLFxuGduCbfTVQq9gP/Lny2L74gA+;5:zZulbnemsdzDvtIcxT/wwG53enO1FF3wMJMDzqZJSU/2TyVxK1VtR6zbIoFjp7ybQnOKOmlFFZcWmEzsEVozGqnaI8iWEVatrdyFfju1dGNJ0EX8ith7r4zH72oICQNFkrjvfYRfcz8xpsPvKvCKUa/nVdOI5Hy9xH1zS97BPU0=;24:sd0T5ltOAAWYit4HbbDdcYJ+2o8nvdKXLpZGTWfzPP9tO3aD+11Yf3vsRId+FUs79DKXtOYOtdJIDwZKFHpAnZDM6Ryoz4VGrsIhunBse/U=;7:uC7MFjFHcSB9Z7iy/0cWfaxlO2zWxzWGvTKLCqZK1GTpTRAEHiUi9fadX3NLKWCua6o5uppWLTspitllucCnNFBIQcclBdBtb2Bueta+4+rxyZyBCu03tihrByxl/EI5mkIE5b/O29z7he2iKDwEuhZYyLRQyurBfEXDIj88LpJU6xJ2A7LLcLfQs2385fhDZIvZtwwJlp3uBbS6eybtiIO9Gtcc1FCtQiBGspVJ6dJfg9LnCzXQI4GlLKoOhRtG59nwCFFRrHbGEe01UewEkQ0kspiCEqjbgz4oxMULqzyVvIUvP8oHuQzlA2uxQNFvwP39HLHXF/JAVKZh8A4eJ7gC0PyR1X98zXIvsz4kv5A= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2016 09:19:21.4642 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR07MB2343 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3570 Lines: 88 On 27.10.16 17:01:36, Will Deacon wrote: > Hi Robert, > > On Mon, Oct 17, 2016 at 08:58:01PM +0200, Robert Richter wrote: > > Mark, Will, any opinion here? > > Having looking at this, I'm inclined to agree with you; pfn_valid() is > all about whether the underlying mem_map (struct page *) entry exists, > not about whether the page is mappable or not. > > That said, setting the zone for pages representing NOMAP memory feels > like a slippery slope to losing information about them being NOMAP in > the first place and the whole problem getting out-of-hand. Whilst I'm > happy for pfn_valid() to return true (in the sense that we're within > bounds of mem_map etc), I'm less happy that we're also saying that the > struct page contains useful information, such as the zone and the node > information, which is then subsequently used by the NUMA code. Let's see it in a different way, pfns and the struct page assigned to each of it is about *physical* memory. The system knows all the memory, some is free, some reserved and some marked NOMAP. Regardless of the mapping of the page the mm code maintains and uses that information. There are assumptions on validity and checks in the code that now cause problems due to partly or non-existing data about nomap pages. This inconsistency is dangerous since a problem may occur any time then the page area is accessed first, thus a system may crash randomly depending on the memory access. Luckily, in my case it triggered reproducible while loading initrd during boot. I also think that this is not only NUMA related. E.g. the following bug report is probably also related: https://bugzilla.redhat.com/show_bug.cgi?id=1387793 > On top of that, pfn_valid is used in other places as a coarse "is this > memory?" check, and will cause things like ioremap to fail whereas it > wouldn't at the moment. IMO this is a misuse of pfn_valid() that needs to be fixed with additional checks, e.g. traversing memblocks. > It feels to me like NOMAP memory is a new type > of memory where there *is* a struct page, but it shouldn't be used for > anything. IMO, a NOMAP page should just be handled like a reserved page except that the page is marked reserved. See free_low_memory_core_early(). Thus, NOMAP pages are not in the free pages list or set to reserved. It is simply not available for mapping at all. Isn't that exactly what it should be? I also did not yet understand the benefit of the differentiation between NOMAP and reserved and the original motivation for its implementation. I looked through the mail threads but could not find any hint. The only difference I see now is that it is not listed as a reserved page, but as long as it is not freed it should behave the same. I remember the case to handle memory different (coherency, etc.), but are not sure here. Ard, could you explain this? > I don't think pfn_valid can describe that, given the way it's > currently used, and flipping the logic is just likely to move the problem > elsewhere. > > What options do we have for fixing this in the NUMA code? Out of my mind: 1) Treat NOMAP pages same as reserved pages (my patch). 2) Change mm code to allow arch specific early_pfn_valid(). 3) Fix mm code to only access stuct page (of a zone) if pfn_valid() is true. There can be more alternatives. IMO: * We shouldn't touch generic mm code. * We should maintain a valid struct page for all pages in a sections. * We should only traverse memblock where really necessary (arm64 only). * I don't think this problem is numa specific. -Robert