From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751961AbcEIJBw (ORCPT ); Mon, 9 May 2016 05:01:52 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:17512 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750948AbcEIJBu (ORCPT ); Mon, 9 May 2016 05:01:50 -0400 Message-ID: <57304B9A.40504@huawei.com> Date: Mon, 9 May 2016 16:34:34 +0800 From: Xishi Qiu User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Andrew Morton , Mel Gorman , Michal Hocko , "Vlastimil Babka" , David Rientjes , "'Kirill A . Shutemov'" , Joonsoo Kim , Taku Izumi , "Alexander Duyck" , Johannes Weiner CC: Linux MM , LKML Subject: [PATCH] mm: fix pfn spans two sections in has_unmovable_pages() Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.25.179] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.573051CF.010E,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 644368e533875879647c4800ee4046aa Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the pfn is not aligned to pageblock, the check pfn may access a next pageblcok, and the next pageblock may belong to a next section. Because struct page has not been alloced in the next section, so kernel panic. I find the caller of has_unmovable_pages() has passed a aligned pfn, so it doesn't have this problem. But the earlier kernel version(e.g. v3.10) has. e.g. echo xxx > /sys/devices/system/memory/soft_offline_page could trigger it. The following log is from RHEL v7.1 [14111.611492] Stack: [14111.611494] ffffffff8115d952 0000000000000000 01ff880c393ebe40 ffff880c7ffd9000 [14111.611500] ffffea0061ffffc0 ffff880c7ffd9068 0000000000000286 0000000000000001 [14111.611505] ffff880c393ebe10 ffffffff811c265a 000000000187ffff 0000000000000200 [14111.611511] Call Trace: [14111.611516] [] ? has_unmovable_pages+0xd2/0x130 [14111.611521] [] set_migratetype_isolate+0xda/0x170 [14111.611526] [] soft_offline_page+0x9a/0x590 [14111.611530] [] ? _kstrtoull+0x3b/0xa0 [14111.611535] [] store_soft_offline_page+0xaf/0xf0 [14111.611539] [] dev_attr_store+0x18/0x30 [14111.611544] [] sysfs_write_file+0xc6/0x140 [14111.611548] [] vfs_write+0xbd/0x1e0 [14111.611551] [] SyS_write+0x58/0xb0 [14111.611556] [] system_call_fastpath+0x16/0x1b [14111.611559] Code: 66 66 66 90 48 83 e0 fd 0c a0 5d c3 66 2e 0f 1f 84 00 00 00 00 00 48 89 f8 66 66 66 90 48 83 c8 42 0c a0 5d c3 90 66 66 66 66 90 <8b> 07 25 00 c0 00 00 75 02 f3 c3 48 8b 07 f6 c4 80 75 0f 48 81 [14111.611594] RIP [] PageHuge+0x5/0x40 [14111.611598] RSP [14111.611600] CR2: ffffea0062000000 [14111.611604] ---[ end trace 9f780ed1def334c6 ]--- [14111.678586] Kernel panic - not syncing: Fatal exception Signed-off-by: Xishi Qiu --- mm/page_alloc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 59de90d..9afc1bc 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6842,6 +6842,7 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, return false; pfn = page_to_pfn(page); + pfn = pfn & ~(pageblock_nr_pages - 1); for (found = 0, iter = 0; iter < pageblock_nr_pages; iter++) { unsigned long check = pfn + iter; -- 1.8.3.1